26 #include "ns3/packet.h"
27 #include "ns3/pointer.h"
28 #include "ns3/simulator.h"
29 #include "ns3/string.h"
30 #include "ns3/wifi-net-device.h"
43 TypeId(
"ns3::MeshPointDevice")
48 "The MAC-level Maximum Transmission Unit",
51 MakeUintegerChecker<uint16_t>())
52 .AddAttribute(
"RoutingProtocol",
53 "The mesh routing protocol used by this mesh point.",
57 MakePointerChecker<MeshL2RoutingProtocol>())
58 .AddAttribute(
"ForwardingDelay",
59 "A random variable to account for processing time (microseconds) to "
61 StringValue(
"ns3::UniformRandomVariable[Min=300.0|Max=400.0]"),
63 MakePointerChecker<RandomVariableStream>());
71 m_channel = CreateObject<BridgeChannel>();
113 uint16_t& realProtocol = protocol;
132 NS_LOG_DEBUG(
"Forwarding broadcast from " << src48 <<
" to " << dst48 <<
" with delay "
171 NS_LOG_DEBUG(
"Forwarding unicast from " << src48 <<
" to " << dst48 <<
" with delay "
183 NS_LOG_FUNCTION(
this << incomingPort << packet << protocol << src << dst);
194 NS_LOG_DEBUG(
"Request to forward packet " << packet <<
" to destination " << dst
195 <<
" failed; dropping packet");
231 NS_LOG_WARN(
"Manual changing mesh point address can cause routing errors.");
325 uint16_t protocolNumber)
403 if ((*i)->GetIfIndex() == n)
412 std::vector<Ptr<NetDevice>>
427 "Device does not support eui 48 addresses: cannot be used as a mesh point interface.");
429 if (!iface->SupportsSendFrom())
432 "Device does not support SendFrom: cannot be used as a mesh point interface.");
443 NS_FATAL_ERROR(
"Device is not a WiFi NIC: cannot be used as a mesh point interface.");
448 NS_FATAL_ERROR(
"WiFi device doesn't have correct MAC installed: cannot be used as a mesh "
451 ifaceMac->SetMeshPointAddress(
m_address);
459 m_channel->AddChannel(iface->GetChannel());
471 "Routing protocol must be installed on mesh point to be useful.");
490 NS_LOG_FUNCTION(
this << success << packet << src << dst << protocol << outIface);
512 if (outIface != 0xffffffff)
514 GetInterface(outIface)->SendFrom(packet, src, dst, protocol);
520 (*i)->SendFrom(packet->
Copy(), src, dst, protocol);
529 broadcastDataBytes(0)
538 os <<
"<Statistics" << std::endl
551 <<
"/>" << 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)
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)
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
virtual void DoDispose()
Destructor implementation.
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Ptr< Packet > Copy() const
performs a COW copy of the packet.
uint64_t GetUid() const
Returns the packet's Uid.
Hold objects of type Ptr<T>.
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.
Ptr< WifiMac > GetMac() 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...
#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, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
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