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/wifi-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 
63 struct TxInfo
64 {
65  uint32_t channelNumber;
66  uint32_t priority;
69  uint32_t txPowerLevel;
70  // Time expiryTime; // unsupported
72  TxInfo ()
73  : channelNumber (CCH),
74  priority (7),
75  txPowerLevel (8)
76  {
77 
78  }
87  TxInfo (uint32_t channel, uint32_t prio = 7, WifiMode rate = WifiMode (), WifiPreamble preamble = WIFI_PREAMBLE_LONG, uint32_t powerLevel = 8)
89  priority (prio),
90  dataRate (rate),
92  txPowerLevel (powerLevel)
93  {
94 
95  }
96 };
97 
112 struct TxProfile
113 {
114  uint32_t channelNumber;
115  bool adaptable;
116  uint32_t txPowerLevel;
119  TxProfile (void)
121  : channelNumber (SCH1),
122  adaptable (false),
123  txPowerLevel (4),
125  {
126  dataRate = WifiMode ("OfdmRate6MbpsBW10MHz");
127  }
134  TxProfile (uint32_t channel, bool adapt = true, uint32_t powerLevel = 4)
136  adaptable (adapt),
137  txPowerLevel (powerLevel)
138  {
139  dataRate = WifiMode ("OfdmRate6MbpsBW10MHz");
141  }
142 };
143 
161 {
162 public:
167  static TypeId GetTypeId (void);
168  WaveNetDevice (void);
169  virtual ~WaveNetDevice (void);
170 
175  void AddMac (uint32_t channelNumber, Ptr<OcbWifiMac> mac);
180  Ptr<OcbWifiMac> GetMac (uint32_t channelNumber) const;
184  std::map<uint32_t, Ptr<OcbWifiMac> > GetMacs (void) const;
188  void AddPhy (Ptr<WifiPhy> phy);
193  Ptr<WifiPhy> GetPhy (uint32_t index) const;
197  std::vector<Ptr<WifiPhy> > GetPhys (void) const;
198 
202  void SetChannelScheduler (Ptr<ChannelScheduler> channelScheduler);
210  void SetChannelManager (Ptr<ChannelManager> channelManager);
218  void SetChannelCoordinator (Ptr<ChannelCoordinator> channelCoordinator);
226  void SetVsaManager (Ptr<VsaManager> vsaManager);
230  Ptr<VsaManager> GetVsaManager (void) const;
231 
236  bool StartSch (const SchInfo & schInfo);
241  bool StopSch (uint32_t channelNumber);
242 
247  bool StartVsa (const VsaInfo & vsaInfo);
252  bool StopVsa (uint32_t channelNumber);
263  typedef Callback<bool, Ptr<const Packet>,const Address &, uint32_t, uint32_t> WaveVsaCallback;
267  void SetWaveVsaCallback (WaveVsaCallback vsaCallback);
268 
277  bool RegisterTxProfile (const TxProfile &txprofile);
284  bool DeleteTxProfile (uint32_t channelNumber);
285 
298  bool SendX (Ptr<Packet> packet, const Address& dest, uint32_t protocol, const TxInfo & txInfo);
307  void ChangeAddress (Address newAddress);
314  void CancelTx (uint32_t channelNumber, enum AcIndex ac);
315 
328  virtual bool Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber);
329 
330  // inherited from NetDevice base class.
331  virtual void SetIfIndex (const uint32_t index);
332  virtual uint32_t GetIfIndex (void) const;
333  virtual Ptr<Channel> GetChannel (void) const;
334  virtual void SetAddress (Address address);
335  virtual Address GetAddress (void) const;
336  virtual bool SetMtu (const uint16_t mtu);
337  virtual uint16_t GetMtu (void) const;
338  virtual bool IsLinkUp (void) const;
339  virtual void AddLinkChangeCallback (Callback<void> callback);
340  virtual bool IsBroadcast (void) const;
341  virtual Address GetBroadcast (void) const;
342  virtual bool IsMulticast (void) const;
343  virtual Address GetMulticast (Ipv4Address multicastGroup) const;
344  virtual bool IsPointToPoint (void) const;
345  virtual bool IsBridge (void) const;
346  virtual bool NeedsArp (void) const;
348  virtual Address GetMulticast (Ipv6Address addr) const;
349  virtual bool SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber);
351  virtual bool SupportsSendFrom (void) const;
352 
353 private:
355  static const uint16_t MAX_MSDU_SIZE = 2304;
356 
358  static const uint16_t IPv4_PROT_NUMBER = 0x0800;
360  static const uint16_t IPv6_PROT_NUMBER = 0x86DD;
361 
362  virtual void DoDispose (void);
363  virtual void DoInitialize (void);
368  bool IsAvailableChannel (uint32_t channelNumber) const;
377  void ForwardUp (Ptr<const Packet> packet, Mac48Address from, Mac48Address to);
378 
380  typedef std::map<uint32_t, Ptr<OcbWifiMac> > MacEntities;
382  typedef std::map<uint32_t, Ptr<OcbWifiMac> >::const_iterator MacEntitiesI;
384  typedef std::vector<Ptr<WifiPhy> > PhyEntities;
387  typedef std::vector<Ptr<WifiPhy> >::const_iterator PhyEntitiesI;
389 
395 
400 
401  // copy from WifiNetDevice
404  uint32_t m_ifIndex;
405  mutable uint16_t m_mtu;
406 };
407 
408 } // namespace ns3
409 
410 #endif /* WAVE_NET_DEVICE_H */
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::VsaInfo
Definition: vsa-manager.h:63
ns3::TxProfile::preamble
WifiPreamble preamble
preamble
Definition: wave-net-device.h:118
ns3::WaveNetDevice::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: wave-net-device.cc:39
ns3::WaveNetDevice::m_promiscRx
NetDevice::PromiscReceiveCallback m_promiscRx
promiscious receive callback
Definition: wave-net-device.h:403
ns3::WaveNetDevice::DoInitialize
virtual void DoInitialize(void)
Initialize() implementation.
Definition: wave-net-device.cc:134
ns3::WaveNetDevice::DeleteTxProfile
bool DeleteTxProfile(uint32_t channelNumber)
Definition: wave-net-device.cc:350
ns3::TxInfo::priority
uint32_t priority
priority
Definition: wave-net-device.h:66
ns3::WaveNetDevice
This class holds together multiple, ns3::WifiPhy, and ns3::OcbWifiMac (including ns3::WifiRemoteStati...
Definition: wave-net-device.h:161
ns3::WaveNetDevice::IsLinkUp
virtual bool IsLinkUp(void) const
Definition: wave-net-device.cc:551
ns3::WaveNetDevice::SetChannelScheduler
void SetChannelScheduler(Ptr< ChannelScheduler > channelScheduler)
Definition: wave-net-device.cc:476
ns3::WaveNetDevice::ChangeAddress
void ChangeAddress(Address newAddress)
Definition: wave-net-device.cc:436
ns3::Callback
Callback template class.
Definition: callback.h:1279
ns3::WifiNetDevice::GetPhy
Ptr< WifiPhy > GetPhy(void) const
Definition: wifi-net-device.cc:207
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
CCH
#define CCH
Definition: channel-manager.h:52
ns3::WaveNetDevice::m_macEntities
MacEntities m_macEntities
MAC entities.
Definition: wave-net-device.h:383
ns3::WaveNetDevice::IsAvailableChannel
bool IsAvailableChannel(uint32_t channelNumber) const
Definition: wave-net-device.cc:654
ns3::WaveNetDevice::SetMtu
virtual bool SetMtu(const uint16_t mtu)
Definition: wave-net-device.cc:536
SCH1
#define SCH1
Definition: channel-manager.h:49
ns3::WaveNetDevice::DoDispose
virtual void DoDispose(void)
Destructor implementation.
Definition: wave-net-device.cc:98
ns3::WaveNetDevice::GetMtu
virtual uint16_t GetMtu(void) const
Definition: wave-net-device.cc:546
third.channel
channel
Definition: third.py:92
ns3::WaveNetDevice::GetMacs
std::map< uint32_t, Ptr< OcbWifiMac > > GetMacs(void) const
Definition: wave-net-device.cc:203
ns3::WaveNetDevice::m_vsaManager
Ptr< VsaManager > m_vsaManager
the VSA manager
Definition: wave-net-device.h:393
ns3::WaveNetDevice::PhyEntitiesI
std::vector< Ptr< WifiPhy > >::const_iterator PhyEntitiesI
PhyEntities iterator typedef.
Definition: wave-net-device.h:387
ns3::TxInfo::channelNumber
uint32_t channelNumber
channel number
Definition: wave-net-device.h:65
ns3::WaveNetDevice::GetChannelManager
Ptr< ChannelManager > GetChannelManager(void) const
Definition: wave-net-device.cc:471
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
ns3::Ipv6Address
Describes an IPv6 address.
Definition: ipv6-address.h:50
ns3::WaveNetDevice::SetWaveVsaCallback
void SetWaveVsaCallback(WaveVsaCallback vsaCallback)
Definition: wave-net-device.cc:276
ns3::WaveNetDevice::PhyEntities
std::vector< Ptr< WifiPhy > > PhyEntities
PhyEntities typedef.
Definition: wave-net-device.h:385
ns3::Mac48Address
an EUI-48 address
Definition: mac48-address.h:44
ns3::WaveNetDevice::GetChannel
virtual Ptr< Channel > GetChannel(void) const
Definition: wave-net-device.cc:517
ns3::WaveNetDevice::SetIfIndex
virtual void SetIfIndex(const uint32_t index)
Definition: wave-net-device.cc:507
ns3::SchInfo
Definition: channel-scheduler.h:66
third.mac
mac
Definition: third.py:99
vendor-specific-action.h
ns3::WaveNetDevice::m_mtu
uint16_t m_mtu
MTU.
Definition: wave-net-device.h:405
ns3::WaveNetDevice::GetChannelCoordinator
Ptr< ChannelCoordinator > GetChannelCoordinator(void) const
Definition: wave-net-device.cc:491
ns3::WaveNetDevice::m_channelCoordinator
Ptr< ChannelCoordinator > m_channelCoordinator
the channel coordinator
Definition: wave-net-device.h:392
ns3::WaveNetDevice::RegisterTxProfile
bool RegisterTxProfile(const TxProfile &txprofile)
Definition: wave-net-device.cc:305
ns3::TxInfo::dataRate
WifiMode dataRate
data rate
Definition: wave-net-device.h:67
channel-scheduler.h
ns3::WaveNetDevice::MAX_MSDU_SIZE
static const uint16_t MAX_MSDU_SIZE
This value conforms to the 802.11 specification.
Definition: wave-net-device.h:355
ns3::WaveNetDevice::IPv4_PROT_NUMBER
static const uint16_t IPv4_PROT_NUMBER
IP v4 Protocol number.
Definition: wave-net-device.h:358
ns3::WifiNetDevice
Hold together all Wifi-related objects.
Definition: wifi-net-device.h:54
ns3::TxInfo::TxInfo
TxInfo(uint32_t channel, uint32_t prio=7, WifiMode rate=WifiMode(), WifiPreamble preamble=WIFI_PREAMBLE_LONG, uint32_t powerLevel=8)
Initializer.
Definition: wave-net-device.h:87
ns3::WaveNetDevice::AddPhy
void AddPhy(Ptr< WifiPhy > phy)
Definition: wave-net-device.cc:210
ns3::Ptr< OcbWifiMac >
ns3::WaveNetDevice::GetBroadcast
virtual Address GetBroadcast(void) const
Definition: wave-net-device.cc:569
channel-manager.h
ns3::WifiMode
represent a single transmission mode
Definition: wifi-mode.h:48
ns3::WaveNetDevice::GetPhys
std::vector< Ptr< WifiPhy > > GetPhys(void) const
Definition: wave-net-device.cc:227
ns3::WaveNetDevice::SetReceiveCallback
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
Definition: wave-net-device.cc:648
ns3::TxInfo::txPowerLevel
uint32_t txPowerLevel
transmit power level
Definition: wave-net-device.h:69
ns3::Address
a polymophic address class
Definition: address.h:91
channel-coordinator.h
ns3::WaveNetDevice::m_ifIndex
uint32_t m_ifIndex
IF index.
Definition: wave-net-device.h:404
ns3::TxProfile::channelNumber
uint32_t channelNumber
channel number
Definition: wave-net-device.h:114
ns3::WaveNetDevice::AddLinkChangeCallback
virtual void AddLinkChangeCallback(Callback< void > callback)
Definition: wave-net-device.cc:559
ns3::WaveNetDevice::GetChannelScheduler
Ptr< ChannelScheduler > GetChannelScheduler(void) const
Definition: wave-net-device.cc:481
ns3::TxInfo::TxInfo
TxInfo()
Initializer.
Definition: wave-net-device.h:72
ns3::WaveNetDevice::ForwardUp
void ForwardUp(Ptr< const Packet > packet, Mac48Address from, Mac48Address to)
Receive a packet from the lower layer and pass the packet up the stack.
Definition: wave-net-device.cc:670
ns3::WaveNetDevice::IsPointToPoint
virtual bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
Definition: wave-net-device.cc:588
ns3::WaveNetDevice::m_addressChange
TracedCallback< Address, Address > m_addressChange
Definition: wave-net-device.h:399
ns3::TxProfile::dataRate
WifiMode dataRate
data rate
Definition: wave-net-device.h:117
ns3::WaveNetDevice::CancelTx
void CancelTx(uint32_t channelNumber, enum AcIndex ac)
Definition: wave-net-device.cc:455
ns3::TxProfile::adaptable
bool adaptable
adaptable
Definition: wave-net-device.h:115
first.address
address
Definition: first.py:44
ns3::TxProfile
Definition: wave-net-device.h:113
ns3::WaveNetDevice::m_channelManager
Ptr< ChannelManager > m_channelManager
the channel manager
Definition: wave-net-device.h:390
ns3::WaveNetDevice::GetMulticast
virtual Address GetMulticast(Ipv4Address multicastGroup) const
Make and return a MAC multicast address using the provided multicast group.
Definition: wave-net-device.cc:579
ns3::WaveNetDevice::StartVsa
bool StartVsa(const VsaInfo &vsaInfo)
Definition: wave-net-device.cc:234
ns3::WaveNetDevice::IPv6_PROT_NUMBER
static const uint16_t IPv6_PROT_NUMBER
IP v6 Protocol number.
Definition: wave-net-device.h:360
ns3::WaveNetDevice::SetAddress
virtual void SetAddress(Address address)
Set the address of this interface.
Definition: wave-net-device.cc:523
ns3::TxInfo::preamble
WifiPreamble preamble
preamble
Definition: wave-net-device.h:68
ns3::WaveNetDevice::SetChannelCoordinator
void SetChannelCoordinator(Ptr< ChannelCoordinator > channelCoordinator)
Definition: wave-net-device.cc:486
ns3::WaveNetDevice::m_phyEntities
PhyEntities m_phyEntities
Phy entities.
Definition: wave-net-device.h:388
ns3::WaveNetDevice::MacEntitiesI
std::map< uint32_t, Ptr< OcbWifiMac > >::const_iterator MacEntitiesI
MacEntities iterator typedef.
Definition: wave-net-device.h:382
ns3::WifiPreamble
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
Definition: wifi-phy-common.h:63
ns3::WaveNetDevice::AddMac
void AddMac(uint32_t channelNumber, Ptr< OcbWifiMac > mac)
Definition: wave-net-device.cc:177
ns3::WIFI_PREAMBLE_LONG
@ WIFI_PREAMBLE_LONG
Definition: wifi-phy-common.h:64
vsa-manager.h
ns3::WaveNetDevice::IsMulticast
virtual bool IsMulticast(void) const
Definition: wave-net-device.cc:574
ns3::WaveNetDevice::StartSch
bool StartSch(const SchInfo &schInfo)
Definition: wave-net-device.cc:283
ns3::WaveNetDevice::GetIfIndex
virtual uint32_t GetIfIndex(void) const
Definition: wave-net-device.cc:512
ns3::WaveNetDevice::m_channelScheduler
Ptr< ChannelScheduler > m_channelScheduler
the channel scheduler
Definition: wave-net-device.h:391
ns3::WaveNetDevice::WaveNetDevice
WaveNetDevice(void)
Definition: wave-net-device.cc:86
ns3::AcIndex
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:71
ns3::WaveNetDevice::GetVsaManager
Ptr< VsaManager > GetVsaManager(void) const
Definition: wave-net-device.cc:501
ns3::WaveNetDevice::Send
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
Definition: wave-net-device.cc:599
ns3::WaveNetDevice::MacEntities
std::map< uint32_t, Ptr< OcbWifiMac > > MacEntities
MacEntities typedef.
Definition: wave-net-device.h:380
ns3::WaveNetDevice::IsBridge
virtual bool IsBridge(void) const
Return true if the net device is acting as a bridge.
Definition: wave-net-device.cc:593
ns3::WaveNetDevice::IsBroadcast
virtual bool IsBroadcast(void) const
Definition: wave-net-device.cc:564
ns3::TracedCallback
Forward calls to a chain of Callback.
Definition: traced-callback.h:53
ns3::WaveNetDevice::~WaveNetDevice
virtual ~WaveNetDevice(void)
Definition: wave-net-device.cc:92
ns3::WaveNetDevice::SendFrom
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
Definition: wave-net-device.cc:714
ns3::WaveNetDevice::StopVsa
bool StopVsa(uint32_t channelNumber)
Definition: wave-net-device.cc:264
ns3::WaveNetDevice::m_forwardUp
NetDevice::ReceiveCallback m_forwardUp
forward up receive callback
Definition: wave-net-device.h:402
ns3::WaveNetDevice::GetAddress
virtual Address GetAddress(void) const
Definition: wave-net-device.cc:531
ns3::WaveNetDevice::WaveVsaCallback
Callback< bool, Ptr< const Packet >, const Address &, uint32_t, uint32_t > WaveVsaCallback
Definition: wave-net-device.h:263
ns3::WaveNetDevice::SupportsSendFrom
virtual bool SupportsSendFrom(void) const
Definition: wave-net-device.cc:731
ns3::TxProfile::TxProfile
TxProfile(void)
Initializer.
Definition: wave-net-device.h:120
ns3::WaveNetDevice::SendX
bool SendX(Ptr< Packet > packet, const Address &dest, uint32_t protocol, const TxInfo &txInfo)
Definition: wave-net-device.cc:372
ns3::TxProfile::TxProfile
TxProfile(uint32_t channel, bool adapt=true, uint32_t powerLevel=4)
Initializer.
Definition: wave-net-device.h:134
ns3::WaveNetDevice::SetVsaManager
void SetVsaManager(Ptr< VsaManager > vsaManager)
Definition: wave-net-device.cc:496
ns3::TxProfile::txPowerLevel
uint32_t txPowerLevel
transmit power level
Definition: wave-net-device.h:116
ns3::TxInfo
Definition: wave-net-device.h:64
ns3::WaveNetDevice::NeedsArp
virtual bool NeedsArp(void) const
Definition: wave-net-device.cc:640
ns3::WaveNetDevice::SetPromiscReceiveCallback
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
Definition: wave-net-device.cc:721
ocb-wifi-mac.h
ns3::WaveNetDevice::StopSch
bool StopSch(uint32_t channelNumber)
Definition: wave-net-device.cc:294
third.phy
phy
Definition: third.py:93
ns3::WaveNetDevice::m_txProfile
TxProfile * m_txProfile
transmit profile
Definition: wave-net-device.h:394
ns3::WifiNetDevice::GetMac
Ptr< WifiMac > GetMac(void) const
Definition: wifi-net-device.cc:201
ns3::WaveNetDevice::SetChannelManager
void SetChannelManager(Ptr< ChannelManager > channelManager)
Definition: wave-net-device.cc:466