15#include "ns3/packet.h"
16#include "ns3/pointer.h"
17#include "ns3/simulator.h"
18#include "ns3/string.h"
19#include "ns3/wifi-net-device.h"
32 TypeId(
"ns3::MeshPointDevice")
37 "The MAC-level Maximum Transmission Unit",
41 .AddAttribute(
"RoutingProtocol",
42 "The mesh routing protocol used by this mesh point.",
47 .AddAttribute(
"ForwardingDelay",
48 "A random variable to account for processing time (microseconds) to "
50 StringValue(
"ns3::UniformRandomVariable[Min=300.0|Max=400.0]"),
102 uint16_t& realProtocol = protocol;
121 NS_LOG_DEBUG(
"Forwarding broadcast from " << src48 <<
" to " << dst48 <<
" with delay "
160 NS_LOG_DEBUG(
"Forwarding unicast from " << src48 <<
" to " << dst48 <<
" with delay "
172 NS_LOG_FUNCTION(
this << incomingPort << packet << protocol << src << dst);
183 NS_LOG_DEBUG(
"Request to forward packet " << packet <<
" to destination " << dst
184 <<
" failed; dropping packet");
220 NS_LOG_WARN(
"Manual changing mesh point address can cause routing errors.");
314 uint16_t protocolNumber)
392 if ((*i)->GetIfIndex() == n)
401std::vector<Ptr<NetDevice>>
416 "Device does not support eui 48 addresses: cannot be used as a mesh point interface.");
418 if (!iface->SupportsSendFrom())
421 "Device does not support SendFrom: cannot be used as a mesh point interface.");
432 NS_FATAL_ERROR(
"Device is not a WiFi NIC: cannot be used as a mesh point interface.");
437 NS_FATAL_ERROR(
"WiFi device doesn't have correct MAC installed: cannot be used as a mesh "
440 ifaceMac->SetMeshPointAddress(
m_address);
448 m_channel->AddChannel(iface->GetChannel());
460 "Routing protocol must be installed on mesh point to be useful.");
479 NS_LOG_FUNCTION(
this << success << packet << src << dst << protocol << outIface);
501 if (outIface != 0xffffffff)
503 GetInterface(outIface)->SendFrom(packet, src, dst, protocol);
509 (*i)->SendFrom(packet->Copy(), src, dst, protocol);
518 broadcastDataBytes(0)
527 os <<
"<Statistics" << std::endl
540 <<
"/>" << std::endl;
a polymophic address class
bool IsNull() 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)
static Mac48Address ConvertFrom(const Address &address)
static Mac48Address GetBroadcast()
Virtual net device modeling mesh point.
void AddInterface(Ptr< NetDevice > port)
Attach new interface to the station.
Ptr< Node > GetNode() const override
void DoSend(bool success, Ptr< Packet > packet, Mac48Address src, Mac48Address dst, uint16_t protocol, uint32_t iface)
Response callback for L2 routing protocol.
Address GetMulticast(Ipv4Address multicastGroup) const override
Make and return a MAC multicast address using the provided multicast group.
uint32_t m_ifIndex
If index.
void SetPromiscReceiveCallback(NetDevice::PromiscReceiveCallback cb) override
uint16_t m_mtu
MTU in bytes.
void SetReceiveCallback(NetDevice::ReceiveCallback cb) override
Ptr< Node > m_node
Parent node.
bool IsPointToPoint() const override
Return true if the net device is on a point-to-point link.
void SetRoutingProtocol(Ptr< MeshL2RoutingProtocol > protocol)
Register routing protocol to be used.
void SetIfIndex(const uint32_t index) override
bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber) override
void DoDispose() override
Destructor implementation.
bool SupportsSendFrom() const override
Ptr< Channel > GetChannel() const override
Ptr< RandomVariableStream > m_forwardingRandomVariable
Random variable used for forwarding delay and jitter.
Ptr< BridgeChannel > m_channel
Virtual channel for upper layers.
void SetAddress(Address a) override
Set the address of this interface.
Ptr< NetDevice > GetInterface(uint32_t id) const
NetDevice::ReceiveCallback m_rxCallback
Receive action.
bool IsMulticast() const override
Statistics m_fwdStats
forward statistics
std::vector< Ptr< NetDevice > > GetInterfaces() const
void AddLinkChangeCallback(Callback< void > callback) override
bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber) override
std::vector< Ptr< NetDevice > > m_ifaces
List of interfaces.
void Forward(Ptr< NetDevice > incomingPort, Ptr< const Packet > packet, uint16_t protocol, const Mac48Address src, const Mac48Address dst)
Forward packet down to interfaces.
bool IsLinkUp() const override
void ReceiveFromDevice(Ptr< NetDevice > device, Ptr< const Packet > packet, uint16_t protocol, const Address &source, const Address &destination, PacketType packetType)
Receive packet from interface.
MeshPointDevice()
C-tor create empty (without interfaces and protocols) mesh point.
static TypeId GetTypeId()
Get the type ID.
uint16_t GetMtu() const override
bool IsBroadcast() const override
void Report(std::ostream &os) const
Print statistics counters.
NetDevice::PromiscReceiveCallback m_promiscRxCallback
Promisc receive action.
Statistics m_rxStats
receive statistics
bool IsBridge() const override
Return true if the net device is acting as a bridge.
uint32_t GetIfIndex() const override
bool SetMtu(const uint16_t mtu) override
void SetNode(Ptr< Node > node) override
Statistics m_txStats
transmit statistics
Mac48Address m_address
Mesh point MAC address, supposed to be the address of the first added interface.
Address GetAddress() const override
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.
uint32_t GetNInterfaces() const
Address GetBroadcast() const override
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.
~MeshPointDevice() override
D-tor.
bool NeedsArp() const override
Basic MAC of mesh point Wi-Fi interface.
Network layer to device interface.
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()
Destructor implementation.
AttributeValue implementation for Pointer.
Smart pointer class similar to boost::intrusive_ptr.
virtual uint32_t GetInteger()
Get the next random value drawn from the distribution.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
static EventId Schedule(const Time &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 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.
#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< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< AttributeChecker > MakePointerChecker()
Create a PointerChecker for a type.
Ptr< const AttributeChecker > MakeUintegerChecker()
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.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
#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.
U * PeekPointer(const Ptr< U > &p)
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
uint32_t broadcastData
broadcast data
uint32_t unicastData
unicast data
uint32_t unicastDataBytes
unicast data bytes
uint32_t broadcastDataBytes
broadcast data bytes