A Discrete-Event Network Simulator
API
wave-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  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18  * Junling Bu <linlinjavaer@gmail.com>
19  */
20 #ifndef WAVE_NET_DEVICE_H
21 #define WAVE_NET_DEVICE_H
22 
23 #include <map>
24 #include <vector>
25 #include "ns3/packet.h"
26 #include "ns3/traced-callback.h"
27 #include "ns3/mac48-address.h"
28 #include "ns3/net-device.h"
29 #include "ocb-wifi-mac.h"
30 #include "vendor-specific-action.h"
31 #include "channel-coordinator.h"
32 #include "channel-manager.h"
33 #include "channel-scheduler.h"
34 #include "vsa-manager.h"
35 namespace ns3 {
36 struct SchInfo;
37 struct VsaInfo;
38 class NetDevice;
39 class ChannelScheduler;
40 class VsaManager;
41 class OcbWifiMac;
42 
56 struct TxInfo
57 {
58  uint32_t channelNumber;
59  uint32_t priority;
61  uint32_t txPowerLevel;
62  // Time expiryTime; // unsupported
63  TxInfo ()
64  : channelNumber (CCH),
65  priority (7),
66  txPowerLevel (8)
67  {
68 
69  }
70  TxInfo (uint32_t channel, uint32_t prio = 7, WifiMode rate = WifiMode (), uint32_t powerLevel = 8)
71  : channelNumber (channel),
72  priority (prio),
73  dataRate (rate),
74  txPowerLevel (powerLevel)
75  {
76 
77  }
78 };
79 
92 struct TxProfile
93 {
94  uint32_t channelNumber;
95  bool adaptable;
96  uint32_t txPowerLevel;
98  TxProfile (void)
99  : channelNumber (SCH1),
100  adaptable (false),
101  txPowerLevel (4)
102  {
103  dataRate = WifiMode ("OfdmRate6MbpsBW10MHz");
104  }
105  TxProfile (uint32_t channel, bool adapt = true, uint32_t powerLevel = 4)
106  : channelNumber (channel),
107  adaptable (adapt),
108  txPowerLevel (powerLevel)
109  {
110  dataRate = WifiMode ("OfdmRate6MbpsBW10MHz");
111  }
112 };
113 
128 class WaveNetDevice : public NetDevice
129 {
130 public:
131  static TypeId GetTypeId (void);
132  WaveNetDevice (void);
133  virtual ~WaveNetDevice (void);
134 
139  void AddMac (uint32_t channelNumber, Ptr<OcbWifiMac> mac);
144  Ptr<OcbWifiMac> GetMac (uint32_t channelNumber) const;
148  std::map<uint32_t, Ptr<OcbWifiMac> > GetMacs (void) const;
152  void AddPhy (Ptr<WifiPhy> phy);
157  Ptr<WifiPhy> GetPhy (uint32_t index) const;
161  std::vector<Ptr<WifiPhy> > GetPhys (void) const;
162 
166  void SetChannelScheduler (Ptr<ChannelScheduler> channelScheduler);
174  void SetChannelManager (Ptr<ChannelManager> channelManager);
182  void SetChannelCoordinator (Ptr<ChannelCoordinator> channelCoordinator);
190  void SetVsaManager (Ptr<VsaManager> vsaManager);
194  Ptr<VsaManager> GetVsaManager (void) const;
195 
200  bool StartSch (const SchInfo & schInfo);
205  bool StopSch (uint32_t channelNumber);
206 
211  bool StartVsa (const VsaInfo & vsaInfo);
216  bool StopVsa (uint32_t channelNumber);
227  typedef Callback<bool, Ptr<const Packet>,const Address &, uint32_t, uint32_t> WaveVsaCallback;
231  void SetWaveVsaCallback (WaveVsaCallback vsaCallback);
232 
241  bool RegisterTxProfile (const TxProfile &txprofile);
248  bool DeleteTxProfile (uint32_t channelNumber);
249 
262  bool SendX (Ptr<Packet> packet, const Address& dest, uint32_t protocol, const TxInfo & txInfo);
271  void ChangeAddress (Address newAddress);
278  void CancelTx (uint32_t channelNumber, enum AcIndex ac);
279 
292  virtual bool Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber);
293 
294  // inherited from NetDevice base class.
295  virtual void SetIfIndex (const uint32_t index);
296  virtual uint32_t GetIfIndex (void) const;
297  virtual Ptr<Channel> GetChannel (void) const;
298  virtual void SetAddress (Address address);
299  virtual Address GetAddress (void) const;
300  virtual bool SetMtu (const uint16_t mtu);
301  virtual uint16_t GetMtu (void) const;
302  virtual bool IsLinkUp (void) const;
303  virtual void AddLinkChangeCallback (Callback<void> callback);
304  virtual bool IsBroadcast (void) const;
305  virtual Address GetBroadcast (void) const;
306  virtual bool IsMulticast (void) const;
307  virtual Address GetMulticast (Ipv4Address multicastGroup) const;
308  virtual bool IsPointToPoint (void) const;
309  virtual bool IsBridge (void) const;
310  virtual Ptr<Node> GetNode (void) const;
311  virtual void SetNode (Ptr<Node> node);
312  virtual bool NeedsArp (void) const;
314  virtual Address GetMulticast (Ipv6Address addr) const;
315  virtual bool SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber);
317  virtual bool SupportsSendFrom (void) const;
318 
319 private:
320  // This value conforms to the 802.11 specification
321  static const uint16_t MAX_MSDU_SIZE = 2304;
322 
323  static const uint16_t IPv4_PROT_NUMBER = 0x0800;
324  static const uint16_t IPv6_PROT_NUMBER = 0x86DD;
325 
326  virtual void DoDispose (void);
327  virtual void DoInitialize (void);
332  bool IsAvailableChannel (uint32_t channelNumber) const;
341  void ForwardUp (Ptr<Packet> packet, Mac48Address from, Mac48Address to);
342 
343  typedef std::map<uint32_t, Ptr<OcbWifiMac> > MacEntities;
344  typedef std::map<uint32_t, Ptr<OcbWifiMac> >::const_iterator MacEntitiesI;
345  MacEntities m_macEntities;
346  typedef std::vector<Ptr<WifiPhy> > PhyEntities;
347  typedef std::vector<Ptr<WifiPhy> >::const_iterator PhyEntitiesI;
348  PhyEntities m_phyEntities;
349 
360 
361  // copy from WifiNetDevice
365  uint32_t m_ifIndex;
366  mutable uint16_t m_mtu;
367 };
368 
369 } // namespace ns3
370 
371 #endif /* WAVE_NET_DEVICE_H */
virtual Address GetAddress(void) const
Ptr< WifiPhy > GetPhy(uint32_t index) const
tuple channel
Definition: third.py:85
bool StopVsa(uint32_t channelNumber)
static const uint16_t IPv4_PROT_NUMBER
Callback template class.
Definition: callback.h:1176
bool StartSch(const SchInfo &schInfo)
void SetWaveVsaCallback(WaveVsaCallback vsaCallback)
uint32_t priority
WifiMode dataRate
Callback< bool, Ptr< const Packet >, const Address &, uint32_t, uint32_t > WaveVsaCallback
Ptr< ChannelCoordinator > m_channelCoordinator
Forward calls to a chain of Callback.
bool SendX(Ptr< Packet > packet, const Address &dest, uint32_t protocol, const TxInfo &txInfo)
virtual bool SupportsSendFrom(void) const
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
std::map< uint32_t, Ptr< OcbWifiMac > >::const_iterator MacEntitiesI
This class holds together multiple, ns3::WifiPhy, and ns3::OcbWifiMac (including ns3::WifiRemoteStati...
virtual void SetAddress(Address address)
Set the address of this interface.
#define CCH
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:99
Ptr< VsaManager > GetVsaManager(void) const
uint32_t txPowerLevel
virtual bool NeedsArp(void) const
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
void ForwardUp(Ptr< Packet > packet, Mac48Address from, Mac48Address to)
Receive a packet from the lower layer and pass the packet up the stack.
uint32_t channelNumber
a polymophic address class
Definition: address.h:90
Ptr< ChannelCoordinator > GetChannelCoordinator(void) const
static const uint16_t IPv6_PROT_NUMBER
tuple phy
Definition: third.py:86
std::map< uint32_t, Ptr< OcbWifiMac > > MacEntities
bool DeleteTxProfile(uint32_t channelNumber)
Ptr< ChannelManager > m_channelManager
virtual ~WaveNetDevice(void)
void SetChannelScheduler(Ptr< ChannelScheduler > channelScheduler)
Ptr< ChannelScheduler > m_channelScheduler
void SetChannelManager(Ptr< ChannelManager > channelManager)
void ChangeAddress(Address newAddress)
uint32_t channelNumber
NetDevice::ReceiveCallback m_forwardUp
virtual void DoDispose(void)
Destructor implementation.
virtual Address GetMulticast(Ipv4Address multicastGroup) const
Make and return a MAC multicast address using the provided multicast group.
Ptr< VsaManager > m_vsaManager
tuple mac
Definition: third.py:92
uint32_t txPowerLevel
virtual void SetIfIndex(const uint32_t index)
bool StopSch(uint32_t channelNumber)
virtual uint16_t GetMtu(void) const
TxProfile * m_txProfile
bool IsAvailableChannel(uint32_t channelNumber) const
std::map< uint32_t, Ptr< OcbWifiMac > > GetMacs(void) const
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual void DoInitialize(void)
Initialize() implementation.
Ptr< OcbWifiMac > GetMac(uint32_t channelNumber) const
virtual Address GetBroadcast(void) const
an EUI-48 address
Definition: mac48-address.h:43
static const uint16_t MAX_MSDU_SIZE
virtual bool IsMulticast(void) const
virtual Ptr< Channel > GetChannel(void) const
Ptr< ChannelManager > GetChannelManager(void) const
TxInfo(uint32_t channel, uint32_t prio=7, WifiMode rate=WifiMode(), uint32_t powerLevel=8)
virtual bool IsBroadcast(void) const
std::vector< Ptr< WifiPhy > > GetPhys(void) const
void AddPhy(Ptr< WifiPhy > phy)
Describes an IPv6 address.
Definition: ipv6-address.h:48
bool StartVsa(const VsaInfo &vsaInfo)
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
TracedCallback< Address, Address > m_addressChange
virtual Ptr< Node > GetNode(void) const
virtual void AddLinkChangeCallback(Callback< void > callback)
Network layer to device interface.
Definition: net-device.h:405
static TypeId GetTypeId(void)
TxProfile(uint32_t channel, bool adapt=true, uint32_t powerLevel=4)
void SetVsaManager(Ptr< VsaManager > vsaManager)
NetDevice::PromiscReceiveCallback m_promiscRx
PhyEntities m_phyEntities
std::vector< Ptr< WifiPhy > >::const_iterator PhyEntitiesI
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
std::vector< Ptr< WifiPhy > > PhyEntities
void AddMac(uint32_t channelNumber, Ptr< OcbWifiMac > mac)
virtual bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
virtual bool SetMtu(const uint16_t mtu)
MacEntities m_macEntities
tuple address
Definition: first.py:37
virtual bool IsBridge(void) const
Return true if the net device is acting as a bridge.
void SetChannelCoordinator(Ptr< ChannelCoordinator > channelCoordinator)
Ptr< ChannelScheduler > GetChannelScheduler(void) const
virtual uint32_t GetIfIndex(void) const
virtual bool IsLinkUp(void) const
a unique identifier for an interface.
Definition: type-id.h:58
bool RegisterTxProfile(const TxProfile &txprofile)
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:36
#define SCH1
void CancelTx(uint32_t channelNumber, enum AcIndex ac)
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
virtual void SetNode(Ptr< Node > node)