22 #include "ns3/packet.h"
24 #include "ns3/simulator.h"
25 #include "ns3/string.h"
26 #include "ns3/pointer.h"
27 #include "ns3/mesh-point-device.h"
28 #include "ns3/wifi-net-device.h"
29 #include "ns3/mesh-wifi-interface-mac.h"
42 .SetGroupName (
"Mesh")
44 .AddAttribute (
"Mtu",
"The MAC-level Maximum Transmission Unit",
48 MakeUintegerChecker<uint16_t> ())
49 .AddAttribute (
"RoutingProtocol",
50 "The mesh routing protocol used by this mesh point.",
56 .AddAttribute (
"ForwardingDelay",
57 "A random variable to account for processing time (microseconds) to forward a frame.",
58 StringValue (
"ns3::UniformRandomVariable[Min=300.0|Max=400.0]"),
60 MakePointerChecker<RandomVariableStream> ());
68 m_channel = CreateObject<BridgeChannel> ();
107 uint16_t& realProtocol = protocol;
122 NS_LOG_DEBUG (
"Forwarding broadcast from " << src48 <<
" to " << dst48
123 <<
" with delay " << forwardingDelay.
As (
Time::US));
143 NS_LOG_DEBUG (
"Forwarding unicast from " << src48 <<
" to " << dst48
144 <<
" with delay " << forwardingDelay.
As (
Time::US));
159 NS_LOG_DEBUG (
"Request to forward packet " << packet <<
" to destination " << dst <<
" failed; dropping packet");
195 NS_LOG_WARN (
"Manual changing mesh point address can cause routing errors.");
226 NS_LOG_WARN (
"AddLinkChangeCallback does nothing");
283 uint16_t protocolNumber)
357 if ((*i)->GetIfIndex () == n)
365 std::vector<Ptr<NetDevice> >
378 NS_FATAL_ERROR (
"Device does not support eui 48 addresses: cannot be used as a mesh point interface.");
382 NS_FATAL_ERROR (
"Device does not support SendFrom: cannot be used as a mesh point interface.");
393 NS_FATAL_ERROR (
"Device is not a WiFi NIC: cannot be used as a mesh point interface.");
399 "WiFi device doesn't have correct MAC installed: cannot be used as a mesh point interface.");
401 ifaceMac->SetMeshPointAddress (
m_address);
419 "Routing protocol must be installed on mesh point to be useful.");
432 uint16_t protocol, uint32_t outIface)
434 NS_LOG_FUNCTION (
this << success << packet << src << dst << protocol << outIface);
456 if (outIface != 0xffffffff)
464 (*i)->SendFrom (packet->
Copy (), src, dst, protocol);
469 unicastData (0), unicastDataBytes (0), broadcastData (0), broadcastDataBytes (0)
478 os <<
"<Statistics" << std::endl <<
a polymophic address class
bool IsNull(void) const
Check for null implementation.
Ipv4 addresses are stored in host order in this class.
Describes an IPv6 address.
static Mac48Address GetMulticast(Ipv4Address address)
static bool IsMatchingType(const Address &address)
bool IsBroadcast(void) const
static Mac48Address ConvertFrom(const Address &address)
Interface for L2 mesh routing protocol and mesh point communication.
Virtual net device modeling mesh point.
void AddInterface(Ptr< NetDevice > port)
Attach new interface to the station.
void DoSend(bool success, Ptr< Packet > packet, Mac48Address src, Mac48Address dst, uint16_t protocol, uint32_t iface)
Response callback for L2 routing protocol.
virtual bool IsLinkUp() const
virtual Ptr< Channel > GetChannel() const
virtual bool NeedsArp() const
virtual bool IsPointToPoint() const
Return true if the net device is on a point-to-point link.
uint32_t m_ifIndex
If index.
virtual bool IsBridge() const
Return true if the net device is acting as a bridge.
virtual bool IsBroadcast() const
uint16_t m_mtu
MTU in bytes.
Ptr< Node > m_node
Parent node.
void SetRoutingProtocol(Ptr< MeshL2RoutingProtocol > protocol)
Register routing protocol to be used.
virtual bool IsMulticast() const
virtual void SetPromiscReceiveCallback(NetDevice::PromiscReceiveCallback cb)
Ptr< RandomVariableStream > m_forwardingRandomVariable
Random variable used for forwarding delay and jitter.
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 bool SetMtu(const uint16_t mtu)
Ptr< BridgeChannel > m_channel
Virtual channel for upper layers.
virtual uint32_t GetIfIndex() const
virtual void SetIfIndex(const uint32_t index)
std::vector< Ptr< NetDevice > > m_ifaces
List of interfaces.
Ptr< NetDevice > GetInterface(uint32_t id) const
virtual void DoDispose()
Destructor implementation.
NetDevice::ReceiveCallback m_rxCallback
Receive action.
Statistics m_fwdStats
forward statistics
std::vector< Ptr< NetDevice > > GetInterfaces() const
virtual Address GetMulticast(Ipv4Address multicastGroup) const
Make and return a MAC multicast address using the provided multicast group.
void Forward(Ptr< NetDevice > incomingPort, Ptr< const Packet > packet, uint16_t protocol, const Mac48Address src, const Mac48Address dst)
Forward packet down to interfaces.
MeshPointDevice()
C-tor create empty (without interfaces and protocols) mesh point.
virtual ~MeshPointDevice()
D-tor.
static TypeId GetTypeId()
Get the type ID.
void Report(std::ostream &os) const
Print statistics counters.
NetDevice::PromiscReceiveCallback m_promiscRxCallback
Promisc receive action.
virtual Address GetAddress() const
Statistics m_rxStats
receive statistics
virtual Ptr< Node > GetNode() const
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
Statistics m_txStats
transmit statistics
Mac48Address m_address
Mesh point MAC address, supposed to be the address of the first added interface.
virtual void SetNode(Ptr< Node > node)
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Ptr< MeshL2RoutingProtocol > m_routingProtocol
Current routing protocol, used mainly by GetRoutingProtocol.
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
uint32_t GetNInterfaces() const
virtual uint16_t GetMtu() const
virtual void SetAddress(Address a)
Set the address of this interface.
virtual Address GetBroadcast() const
void ResetStats()
Reset statistics counters.
Time GetForwardingDelay() const
Return a (random) forwarding delay value from the random variable ForwardingDelay attribute.
Ptr< MeshL2RoutingProtocol > GetRoutingProtocol() const
Access current routing protocol.
virtual bool SupportsSendFrom() const
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
virtual void AddLinkChangeCallback(Callback< void > callback)
Basic MAC of mesh point Wi-Fi interface.
Network layer to device interface.
virtual bool SupportsSendFrom(void) const =0
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)=0
virtual Ptr< Channel > GetChannel(void) const =0
virtual Address GetAddress(void) const =0
virtual uint32_t GetIfIndex(void) const =0
PacketType
Packet types are used as they are in Linux.
void RegisterProtocolHandler(ProtocolHandler handler, uint16_t protocolType, Ptr< NetDevice > device, bool promiscuous=false)
virtual void DoDispose(void)
Destructor implementation.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
uint64_t GetUid(void) const
Returns the packet's Uid.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Hold objects of type Ptr<T>.
virtual uint32_t GetInteger(void)=0
Get the next random value as an integer drawn from the distribution.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Hold variables of type string.
Simulation virtual time values and global simulation resolution.
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
Hold together all Wifi-related objects.
Ptr< WifiMac > GetMac(void) const
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Ptr< AttributeChecker > MakePointerChecker(void)
Create a PointerChecker for a type.
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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...
U * PeekPointer(const Ptr< U > &p)
uint32_t broadcastData
broadcast data
uint32_t unicastData
unicast data
uint32_t unicastDataBytes
unicast data bytes
uint32_t broadcastDataBytes
broadcast data bytes