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/packet.h"
26 #include "ns3/traced-callback.h"
27 #include "ns3/mac48-address.h"
28 #include <string>
29 
30 namespace ns3 {
31 
32 class WifiRemoteStationManager;
33 class WifiChannel;
34 class WifiPhy;
35 class WifiMac;
36 
51 class WifiNetDevice : public NetDevice
52 {
53 public:
54  static TypeId GetTypeId (void);
55 
56  WifiNetDevice ();
57  virtual ~WifiNetDevice ();
58 
62  void SetMac (Ptr<WifiMac> mac);
66  void SetPhy (Ptr<WifiPhy> phy);
74  Ptr<WifiMac> GetMac (void) const;
78  Ptr<WifiPhy> GetPhy (void) const;
83 
84 
85  //inherited from NetDevice base class.
86  virtual void SetIfIndex (const uint32_t index);
87  virtual uint32_t GetIfIndex (void) const;
88  virtual Ptr<Channel> GetChannel (void) const;
89  virtual void SetAddress (Address address);
90  virtual Address GetAddress (void) const;
91  virtual bool SetMtu (const uint16_t mtu);
92  virtual uint16_t GetMtu (void) const;
93  virtual bool IsLinkUp (void) const;
94  virtual void AddLinkChangeCallback (Callback<void> callback);
95  virtual bool IsBroadcast (void) const;
96  virtual Address GetBroadcast (void) const;
97  virtual bool IsMulticast (void) const;
98  virtual Address GetMulticast (Ipv4Address multicastGroup) const;
99  virtual bool IsPointToPoint (void) const;
100  virtual bool IsBridge (void) const;
101  virtual bool Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber);
102  virtual Ptr<Node> GetNode (void) const;
103  virtual void SetNode (Ptr<Node> node);
104  virtual bool NeedsArp (void) const;
106 
107  virtual Address GetMulticast (Ipv6Address addr) const;
108 
109  virtual bool SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber);
111  virtual bool SupportsSendFrom (void) const;
112 
113 
114 protected:
115  virtual void DoDispose (void);
116  virtual void DoInitialize (void);
117  virtual void NotifyNewAggregate (void);
126  void ForwardUp (Ptr<Packet> packet, Mac48Address from, Mac48Address to);
127 
128 
129 private:
130  //This value conforms to the 802.11 specification
131  static const uint16_t MAX_MSDU_SIZE = 2304;
132 
137  void LinkUp (void);
141  void LinkDown (void);
147  Ptr<WifiChannel> DoGetChannel (void) const;
152  void CompleteConfig (void);
153 
195  uint8_t SelectQueue (Ptr<QueueItem> item) const;
196 
204 
207 
208  uint32_t m_ifIndex;
209  bool m_linkUp;
211  mutable uint16_t m_mtu;
213 };
214 
215 } //namespace ns3
216 
217 #endif /* WIFI_NET_DEVICE_H */
virtual void SetNode(Ptr< Node > node)
virtual 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.
virtual 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
void LinkUp(void)
Set that the link is up.
virtual uint16_t GetMtu(void) const
Forward calls to a chain of Callback.
virtual Address GetAddress(void) const
Ptr< WifiRemoteStationManager > m_stationManager
virtual Address GetMulticast(Ipv4Address multicastGroup) const
Make and return a MAC multicast address using the provided multicast group.
TracedCallback< Ptr< const Packet >, Mac48Address > m_rxLogger
void ForwardUp(Ptr< Packet > packet, Mac48Address from, Mac48Address to)
Receive a packet from the lower layer and pass the packet up the stack.
virtual Ptr< Channel > GetChannel(void) const
virtual bool IsBroadcast(void) const
a polymophic address class
Definition: address.h:90
void SetMac(Ptr< WifiMac > mac)
virtual bool IsMulticast(void) const
Ptr< WifiPhy > GetPhy(void) const
tuple phy
Definition: third.py:86
virtual void DoDispose(void)
Destructor implementation.
Ptr< WifiRemoteStationManager > GetRemoteStationManager(void) const
void SetPhy(Ptr< WifiPhy > phy)
Ptr< WifiChannel > DoGetChannel(void) const
Return the WifiChannel this device is connected to.
Ptr< WifiMac > m_mac
virtual bool SupportsSendFrom(void) const
Ptr< WifiPhy > m_phy
Hold together all Wifi-related objects.
tuple mac
Definition: third.py:92
void SetRemoteStationManager(Ptr< WifiRemoteStationManager > manager)
virtual Ptr< Node > GetNode(void) const
Every class exported by the ns3 library is enclosed in the ns3 namespace.
TracedCallback m_linkChanges
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
virtual uint32_t GetIfIndex(void) const
static const uint16_t MAX_MSDU_SIZE
an EUI-48 address
Definition: mac48-address.h:43
virtual void DoInitialize(void)
Initialize() implementation.
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.
Definition: ipv6-address.h:48
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
virtual void SetIfIndex(const uint32_t index)
NetDevice::ReceiveCallback m_forwardUp
Network layer to device interface.
Definition: net-device.h:405
virtual bool IsLinkUp(void) const
virtual 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
virtual void NotifyNewAggregate(void)
Notify all Objects aggregated to this one of a new Object being aggregated.
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
tuple address
Definition: first.py:37
virtual 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
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
static TypeId GetTypeId(void)
NetDevice::PromiscReceiveCallback m_promiscRx
virtual void SetAddress(Address address)
Set the address of this interface.