20 #include "wifi-net-device.h"
23 #include "wifi-remote-station-manager.h"
24 #include "wifi-channel.h"
25 #include "ns3/llc-snap-header.h"
26 #include "ns3/packet.h"
27 #include "ns3/uinteger.h"
28 #include "ns3/pointer.h"
30 #include "ns3/trace-source-accessor.h"
37 NS_OBJECT_ENSURE_REGISTERED (WifiNetDevice);
40 WifiNetDevice::GetTypeId (
void)
42 static TypeId tid = TypeId (
"ns3::WifiNetDevice")
43 .SetParent<NetDevice> ()
44 .AddConstructor<WifiNetDevice> ()
45 .AddAttribute (
"Mtu",
"The MAC-level Maximum Transmission Unit",
50 .AddAttribute (
"Channel",
"The channel attached to this device",
52 MakePointerAccessor (&WifiNetDevice::DoGetChannel),
53 MakePointerChecker<WifiChannel> ())
54 .AddAttribute (
"Phy",
"The PHY layer attached to this device.",
58 MakePointerChecker<WifiPhy> ())
59 .AddAttribute (
"Mac",
"The MAC layer attached to this device.",
63 MakePointerChecker<WifiMac> ())
64 .AddAttribute (
"RemoteStationManager",
"The station manager attached to this device.",
68 MakePointerChecker<WifiRemoteStationManager> ())
73 WifiNetDevice::WifiNetDevice ()
74 : m_configComplete (false)
78 WifiNetDevice::~WifiNetDevice ()
90 m_stationManager->Dispose ();
101 m_phy->Initialize ();
102 m_mac->Initialize ();
103 m_stationManager->Initialize ();
108 WifiNetDevice::CompleteConfig (
void)
112 || m_stationManager == 0
118 m_mac->SetWifiRemoteStationManager (m_stationManager);
119 m_mac->SetWifiPhy (m_phy);
120 m_mac->SetForwardUpCallback (
MakeCallback (&WifiNetDevice::ForwardUp,
this));
121 m_mac->SetLinkUpCallback (
MakeCallback (&WifiNetDevice::LinkUp,
this));
122 m_mac->SetLinkDownCallback (
MakeCallback (&WifiNetDevice::LinkDown,
this));
123 m_stationManager->SetupPhy (m_phy);
124 m_configComplete =
true;
142 m_stationManager = manager;
158 return m_stationManager;
174 return m_phy->GetChannel ();
177 WifiNetDevice::DoGetChannel (
void)
const
179 return m_phy->GetChannel ();
189 return m_mac->GetAddress ();
209 return m_phy != 0 && m_linkUp;
214 m_linkChanges.ConnectWithoutContext (callback);
258 llc.SetType (protocolNumber);
261 m_mac->NotifyTx (packet);
262 m_mac->Enqueue (packet, realTo);
301 else if (to == m_mac->GetAddress ())
312 m_mac->NotifyRx (packet);
313 m_forwardUp (
this, packet, llc.GetType (), from);
316 if (!m_promiscRx.IsNull ())
318 m_mac->NotifyPromiscRx (packet);
319 m_promiscRx (
this, packet, llc.GetType (), from, to, type);
324 WifiNetDevice::LinkUp (
void)
330 WifiNetDevice::LinkDown (
void)
346 llc.SetType (protocolNumber);
349 m_mac->NotifyTx (packet);
350 m_mac->Enqueue (packet, realTo, realFrom);
365 return m_mac->SupportsSendFrom ();
virtual void SetNode(Ptr< Node > node)
uint32_t RemoveHeader(Header &header)
virtual bool IsBridge(void) const
Return true if the net device is acting as a bridge.
static bool IsMatchingType(const Address &address)
virtual bool SetMtu(const uint16_t mtu)
smart pointer class similar to boost::intrusive_ptr
virtual uint16_t GetMtu(void) const
virtual Address GetAddress(void) const
#define NS_ASSERT(condition)
#define NS_LOG_COMPONENT_DEFINE(name)
bool IsBroadcast(void) const
virtual Address GetMulticast(Ipv4Address multicastGroup) const
Make and return a MAC multicast address using the provided multicast group.
virtual void DoDispose(void)
#define NS_LOG_FUNCTION_NOARGS()
virtual Ptr< Channel > GetChannel(void) const
virtual bool IsBroadcast(void) const
a polymophic address class
void SetMac(Ptr< WifiMac > mac)
virtual bool IsMulticast(void) const
Ptr< WifiPhy > GetPhy(void) const
virtual void DoDispose(void)
Ptr< WifiRemoteStationManager > GetRemoteStationManager(void) const
static Mac48Address GetMulticast(Ipv4Address address)
void SetPhy(Ptr< WifiPhy > phy)
virtual bool SupportsSendFrom(void) const
static Mac48Address GetBroadcast(void)
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
void SetRemoteStationManager(Ptr< WifiRemoteStationManager > manager)
static Mac48Address ConvertFrom(const Address &address)
static const uint16_t LLC_SNAP_HEADER_LENGTH
virtual Ptr< Node > GetNode(void) const
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
virtual uint32_t GetIfIndex(void) const
virtual void DoInitialize(void)
virtual bool NeedsArp(void) const
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
virtual Address GetBroadcast(void) const
Describes an IPv6 address.
Ipv4 addresses are stored in host order in this class.
virtual void SetIfIndex(const uint32_t index)
virtual bool IsLinkUp(void) const
virtual void AddLinkChangeCallback(Callback< void > callback)
Ptr< WifiMac > GetMac(void) const
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
virtual bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
void AddHeader(const Header &header)
virtual void DoInitialize(void)
virtual void SetAddress(Address address)