A Discrete-Event Network Simulator
API
wifi-net-device.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005,2006 INRIA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 
21 #ifndef WIFI_NET_DEVICE_H
22 #define WIFI_NET_DEVICE_H
23 
24 #include "ns3/net-device.h"
25 #include "ns3/queue-item.h"
26 #include "ns3/traced-callback.h"
27 
28 namespace ns3 {
29 
30 class WifiRemoteStationManager;
31 class WifiPhy;
32 class WifiMac;
33 class NetDeviceQueueInterface;
34 
49 class WifiNetDevice : public NetDevice
50 {
51 public:
56  static TypeId GetTypeId (void);
57 
58  WifiNetDevice ();
59  virtual ~WifiNetDevice ();
60 
64  void SetMac (const Ptr<WifiMac> mac);
68  void SetPhy (const Ptr<WifiPhy> phy);
76  Ptr<WifiMac> GetMac (void) const;
80  Ptr<WifiPhy> GetPhy (void) const;
85 
86 
87  //inherited from NetDevice base class.
88  void SetIfIndex (const uint32_t index);
89  uint32_t GetIfIndex (void) const;
90  Ptr<Channel> GetChannel (void) const;
91  void SetAddress (Address address);
92  Address GetAddress (void) const;
93  bool SetMtu (const uint16_t mtu);
94  uint16_t GetMtu (void) const;
95  bool IsLinkUp (void) const;
96  void AddLinkChangeCallback (Callback<void> callback);
97  bool IsBroadcast (void) const;
98  Address GetBroadcast (void) const;
99  bool IsMulticast (void) const;
100  Address GetMulticast (Ipv4Address multicastGroup) const;
101  bool IsPointToPoint (void) const;
102  bool IsBridge (void) const;
103  bool Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber);
104  Ptr<Node> GetNode (void) const;
105  void SetNode (const Ptr<Node> node);
106  bool NeedsArp (void) const;
108  Address GetMulticast (Ipv6Address addr) const;
109  bool SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber);
111  bool SupportsSendFrom (void) const;
112 
113 
114 protected:
115  void DoDispose (void);
116  void DoInitialize (void);
117  void NotifyNewAggregate (void);
126  void ForwardUp (Ptr<Packet> packet, Mac48Address from, Mac48Address to);
127 
128 
129 private:
136  WifiNetDevice (const WifiNetDevice &o);
137 
146 
148  static const uint16_t MAX_MSDU_SIZE = 2304;
149 
154  void LinkUp (void);
158  void LinkDown (void);
164  Ptr<Channel> DoGetChannel (void) const;
169  void CompleteConfig (void);
173  void FlowControlConfig (void);
174 
217  uint8_t SelectQueue (Ptr<QueueItem> item) const;
218 
226 
229 
230  uint32_t m_ifIndex;
231  bool m_linkUp;
233  mutable uint16_t m_mtu;
235 };
236 
237 } //namespace ns3
238 
239 #endif /* WIFI_NET_DEVICE_H */
bool IsBridge(void) const
Return true if the net device is acting as a bridge.
uint8_t SelectQueue(Ptr< QueueItem > item) const
Determine the tx queue for a given packet.
bool m_linkUp
link up
bool SetMtu(const uint16_t mtu)
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
TracedCallback< Ptr< const Packet >, Mac48Address > m_txLogger
transmit trace callback
void LinkUp(void)
Set that the link is up.
uint16_t GetMtu(void) const
Forward calls to a chain of Callback.
Address GetAddress(void) const
Ptr< WifiRemoteStationManager > m_stationManager
the station manager
Address GetMulticast(Ipv4Address multicastGroup) const
Make and return a MAC multicast address using the provided multicast group.
TracedCallback< Ptr< const Packet >, Mac48Address > m_rxLogger
receive trace callback
void ForwardUp(Ptr< Packet > packet, Mac48Address from, Mac48Address to)
Receive a packet from the lower layer and pass the packet up the stack.
Ptr< Channel > GetChannel(void) const
bool IsBroadcast(void) const
a polymophic address class
Definition: address.h:90
uint16_t m_mtu
MTU.
bool IsMulticast(void) const
Ptr< WifiPhy > GetPhy(void) const
tuple phy
Definition: third.py:86
void DoDispose(void)
Destructor implementation.
Ptr< WifiRemoteStationManager > GetRemoteStationManager(void) const
void SetMac(const Ptr< WifiMac > mac)
Ptr< WifiMac > m_mac
the MAC
bool SupportsSendFrom(void) const
Ptr< WifiPhy > m_phy
the phy
Hold together all Wifi-related objects.
tuple mac
Definition: third.py:92
Ptr< Node > GetNode(void) const
Every class exported by the ns3 library is enclosed in the ns3 namespace.
TracedCallback m_linkChanges
link change callback
bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
Ptr< Node > m_node
the node
uint32_t GetIfIndex(void) const
static const uint16_t MAX_MSDU_SIZE
This value conforms to the 802.11 specification.
void FlowControlConfig(void)
Perform the actions needed to support flow control and dynamic queue limits.
an EUI-48 address
Definition: mac48-address.h:43
void DoInitialize(void)
Initialize() implementation.
bool NeedsArp(void) const
uint32_t m_ifIndex
IF index.
bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
Address GetBroadcast(void) const
Describes an IPv6 address.
Definition: ipv6-address.h:48
void SetPhy(const Ptr< WifiPhy > phy)
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
void SetIfIndex(const uint32_t index)
NetDevice::ReceiveCallback m_forwardUp
forward up callback
Ptr< Channel > DoGetChannel(void) const
Return the Channel this device is connected to.
Network layer to device interface.
Definition: net-device.h:95
bool IsLinkUp(void) const
void AddLinkChangeCallback(Callback< void > callback)
void CompleteConfig(void)
Complete the configuration of this Wi-Fi device by connecting all lower components (e...
Ptr< WifiMac > GetMac(void) const
void NotifyNewAggregate(void)
Notify all Objects aggregated to this one of a new Object being aggregated.
void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
WifiNetDevice & operator=(const WifiNetDevice &o)
Assignment operator.
tuple address
Definition: first.py:37
bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
void LinkDown(void)
Set that the link is down (i.e.
Ptr< NetDeviceQueueInterface > m_queueInterface
NetDevice queue interface.
a unique identifier for an interface.
Definition: type-id.h:58
void SetReceiveCallback(NetDevice::ReceiveCallback cb)
static TypeId GetTypeId(void)
Get the type ID.
NetDevice::PromiscReceiveCallback m_promiscRx
promiscious receive callback
bool m_configComplete
configuration complete
void SetNode(const Ptr< Node > node)
void SetAddress(Address address)
Set the address of this interface.
void SetRemoteStationManager(const Ptr< WifiRemoteStationManager > manager)