|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
22 #include "ns3/packet.h"
24 #include "ns3/pointer.h"
25 #include "ns3/mesh-point-device.h"
26 #include "ns3/wifi-net-device.h"
27 #include "ns3/mesh-wifi-interface-mac.h"
40 .SetGroupName (
"Mesh")
42 .AddAttribute (
"Mtu",
"The MAC-level Maximum Transmission Unit",
46 MakeUintegerChecker<uint16_t> ())
47 .AddAttribute (
"RoutingProtocol",
48 "The mesh routing protocol used by this mesh point.",
61 m_channel = CreateObject<BridgeChannel> ();
100 uint16_t& realProtocol = protocol;
113 Forward (incomingPort, packet, protocol, src48, dst48);
132 Forward (incomingPort, packet->
Copy (), protocol, src48, dst48);
146 NS_LOG_DEBUG (
"Request to forward packet " << packet <<
" to destination " << dst <<
" failed; dropping packet");
182 NS_LOG_WARN (
"Manual changing mesh point address can cause routing errors.");
213 NS_LOG_WARN (
"AddLinkChangeCallback does nothing");
270 uint16_t protocolNumber)
344 if ((*i)->GetIfIndex () ==
n)
352 std::vector<Ptr<NetDevice> >
365 NS_FATAL_ERROR (
"Device does not support eui 48 addresses: cannot be used as a mesh point interface.");
369 NS_FATAL_ERROR (
"Device does not support SendFrom: cannot be used as a mesh point interface.");
380 NS_FATAL_ERROR (
"Device is not a WiFi NIC: cannot be used as a mesh point interface.");
386 "WiFi device doesn't have correct MAC installed: cannot be used as a mesh point interface.");
388 ifaceMac->SetMeshPointAddress (
m_address);
406 "Routing protocol must be installed on mesh point to be useful.");
419 uint16_t protocol, uint32_t outIface)
421 NS_LOG_FUNCTION (
this << success << packet << src << dst << protocol << outIface);
443 if (outIface != 0xffffffff)
451 (*i)->SendFrom (packet->
Copy (), src, dst, protocol);
456 unicastData (0), unicastDataBytes (0), broadcastData (0), broadcastDataBytes (0)
465 os <<
"<Statistics" << std::endl <<
Virtual net device modeling mesh point.
virtual bool IsPointToPoint() const
Return true if the net device is on a point-to-point link.
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
NetDevice::PromiscReceiveCallback m_promiscRxCallback
Promisc receive action.
virtual Address GetAddress() const
virtual void DoDispose()
Destructor implementation.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
void RegisterProtocolHandler(ProtocolHandler handler, uint16_t protocolType, Ptr< NetDevice > device, bool promiscuous=false)
static Mac48Address GetMulticast(Ipv4Address address)
virtual bool SetMtu(const uint16_t mtu)
Ptr< Node > m_node
Parent node.
static bool IsMatchingType(const Address &address)
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
virtual Address GetAddress(void) const =0
void ResetStats()
Reset statistics counters.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
MeshPointDevice()
C-tor create empty (without interfaces and protocols) mesh point.
bool IsNull(void) const
Check for null implementation.
virtual bool IsBroadcast() const
virtual void SetPromiscReceiveCallback(NetDevice::PromiscReceiveCallback cb)
Ptr< MeshL2RoutingProtocol > m_routingProtocol
Current routing protocol, used mainly by GetRoutingProtocol.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
virtual bool IsLinkUp() const
uint32_t unicastData
unicast data
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Interface for L2 mesh routing protocol and mesh point communication.
virtual uint16_t GetMtu() const
Ipv4 addresses are stored in host order in this class.
Describes an IPv6 address.
Hold objects of type Ptr<T>.
uint32_t m_ifIndex
If index.
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)=0
void DoSend(bool success, Ptr< Packet > packet, Mac48Address src, Mac48Address dst, uint16_t protocol, uint32_t iface)
Response callback for L2 routing protocol.
virtual void SetAddress(Address a)
Set the address of this interface.
U * PeekPointer(const Ptr< U > &p)
TypeId SetParent(TypeId tid)
Set the parent TypeId.
void ReceiveFromDevice(Ptr< NetDevice > device, Ptr< const Packet > packet, uint16_t protocol, Address const &source, Address const &destination, PacketType packetType)
Receive packet from interface.
virtual Address GetBroadcast() const
Statistics m_rxStats
receive statistics
Statistics m_txStats
transmit statistics
Hold together all Wifi-related objects.
Ptr< AttributeChecker > MakePointerChecker(void)
Create a PointerChecker for a type.
virtual void SetNode(Ptr< Node > node)
Ptr< BridgeChannel > m_channel
Virtual channel for upper layers.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
virtual Ptr< Node > GetNode() const
std::vector< Ptr< NetDevice > > m_ifaces
List of interfaces.
uint32_t broadcastDataBytes
broadcast data bytes
std::vector< Ptr< NetDevice > > GetInterfaces() const
a polymophic address class
static Mac48Address ConvertFrom(const Address &address)
virtual void SetIfIndex(const uint32_t index)
bool IsBroadcast(void) const
Statistics m_fwdStats
forward statistics
virtual bool SupportsSendFrom() const
uint32_t GetNInterfaces() const
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
virtual Ptr< Channel > GetChannel(void) const =0
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
virtual ~MeshPointDevice()
D-tor.
uint32_t unicastDataBytes
unicast data bytes
virtual uint32_t GetIfIndex() const
virtual Address GetMulticast(Ipv4Address multicastGroup) const
Make and return a MAC multicast address using the provided multicast group.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
NetDevice::ReceiveCallback m_rxCallback
Receive action.
uint16_t m_mtu
MTU in bytes.
virtual bool NeedsArp() const
void AddInterface(Ptr< NetDevice > port)
Attach new interface to the station.
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
virtual bool IsBridge() const
Return true if the net device is acting as a bridge.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
void SetRoutingProtocol(Ptr< MeshL2RoutingProtocol > protocol)
Register routing protocol to be used.
uint32_t broadcastData
broadcast data
Mac48Address m_address
Mesh point MAC address, supposed to be the address of the first added interface.
PacketType
Packet types are used as they are in Linux.
Hold an unsigned integer type.
static TypeId GetTypeId()
Get the type ID.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
void Report(std::ostream &os) const
Print statistics counters.
virtual bool SupportsSendFrom(void) const =0
Ptr< MeshL2RoutingProtocol > GetRoutingProtocol() const
Access current routing protocol.
virtual uint32_t GetIfIndex(void) const =0
virtual bool IsMulticast() const
Ptr< NetDevice > GetInterface(uint32_t id) const
virtual void DoDispose(void)
Destructor implementation.
virtual void AddLinkChangeCallback(Callback< void > callback)
void Forward(Ptr< NetDevice > incomingPort, Ptr< const Packet > packet, uint16_t protocol, const Mac48Address src, const Mac48Address dst)
Forward packet down to interfaces.
uint64_t GetUid(void) const
Returns the packet's Uid.
Network layer to device interface.
virtual Ptr< Channel > GetChannel() const
Ptr< WifiMac > GetMac(void) const
Basic MAC of mesh point Wi-Fi interface.