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;
120  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;
385  typedef std::vector<Ptr<WifiPhy> > PhyEntities;
387  typedef std::vector<Ptr<WifiPhy> >::const_iterator PhyEntitiesI;
389 
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 */
#define SCH1
#define CCH
a polymophic address class
Definition: address.h:91
Callback template class.
Definition: callback.h:1279
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
Describes an IPv6 address.
Definition: ipv6-address.h:50
an EUI-48 address
Definition: mac48-address.h:44
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition: type-id.h:59
This class holds together multiple, ns3::WifiPhy, and ns3::OcbWifiMac (including ns3::WifiRemoteStati...
void AddPhy(Ptr< WifiPhy > phy)
virtual bool IsBridge(void) const
Return true if the net device is acting as a bridge.
void SetChannelCoordinator(Ptr< ChannelCoordinator > channelCoordinator)
virtual Address GetAddress(void) const
bool StartSch(const SchInfo &schInfo)
void ChangeAddress(Address newAddress)
bool DeleteTxProfile(uint32_t channelNumber)
void AddMac(uint32_t channelNumber, Ptr< OcbWifiMac > mac)
virtual bool IsBroadcast(void) const
virtual Address GetBroadcast(void) const
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
NetDevice::ReceiveCallback m_forwardUp
forward up receive callback
virtual bool SetMtu(const uint16_t mtu)
void SetChannelScheduler(Ptr< ChannelScheduler > channelScheduler)
Ptr< VsaManager > m_vsaManager
the VSA manager
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
virtual ~WaveNetDevice(void)
std::vector< Ptr< WifiPhy > > PhyEntities
PhyEntities typedef.
std::vector< Ptr< WifiPhy > > GetPhys(void) const
virtual uint16_t GetMtu(void) const
std::map< uint32_t, Ptr< OcbWifiMac > > GetMacs(void) const
virtual Ptr< Channel > GetChannel(void) const
PhyEntities m_phyEntities
Phy entities.
virtual bool IsMulticast(void) const
Ptr< ChannelManager > GetChannelManager(void) const
Ptr< ChannelScheduler > m_channelScheduler
the channel scheduler
std::map< uint32_t, Ptr< OcbWifiMac > >::const_iterator MacEntitiesI
MacEntities iterator typedef.
static const uint16_t MAX_MSDU_SIZE
This value conforms to the 802.11 specification.
void SetVsaManager(Ptr< VsaManager > vsaManager)
uint32_t m_ifIndex
IF index.
MacEntities m_macEntities
MAC entities.
virtual Address GetMulticast(Ipv4Address multicastGroup) const
Make and return a MAC multicast address using the provided multicast group.
virtual bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
void ForwardUp(Ptr< const Packet > packet, Mac48Address from, Mac48Address to)
Receive a packet from the lower layer and pass the packet up the stack.
bool StopVsa(uint32_t channelNumber)
static TypeId GetTypeId(void)
Get the type ID.
static const uint16_t IPv6_PROT_NUMBER
IP v6 Protocol number.
virtual uint32_t GetIfIndex(void) const
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
bool SendX(Ptr< Packet > packet, const Address &dest, uint32_t protocol, const TxInfo &txInfo)
virtual bool SupportsSendFrom(void) const
bool RegisterTxProfile(const TxProfile &txprofile)
TracedCallback< Address, Address > m_addressChange
virtual void DoDispose(void)
Destructor implementation.
NetDevice::PromiscReceiveCallback m_promiscRx
promiscious receive callback
Ptr< ChannelCoordinator > GetChannelCoordinator(void) const
Callback< bool, Ptr< const Packet >, const Address &, uint32_t, uint32_t > WaveVsaCallback
std::map< uint32_t, Ptr< OcbWifiMac > > MacEntities
MacEntities typedef.
Ptr< ChannelCoordinator > m_channelCoordinator
the channel coordinator
bool IsAvailableChannel(uint32_t channelNumber) const
void SetWaveVsaCallback(WaveVsaCallback vsaCallback)
std::vector< Ptr< WifiPhy > >::const_iterator PhyEntitiesI
PhyEntities iterator typedef.
Ptr< ChannelScheduler > GetChannelScheduler(void) const
TxProfile * m_txProfile
transmit profile
virtual void SetIfIndex(const uint32_t index)
virtual bool NeedsArp(void) const
void CancelTx(uint32_t channelNumber, enum AcIndex ac)
void SetChannelManager(Ptr< ChannelManager > channelManager)
bool StartVsa(const VsaInfo &vsaInfo)
Ptr< VsaManager > GetVsaManager(void) const
Ptr< ChannelManager > m_channelManager
the channel manager
static const uint16_t IPv4_PROT_NUMBER
IP v4 Protocol number.
bool StopSch(uint32_t channelNumber)
virtual void SetAddress(Address address)
Set the address of this interface.
virtual bool IsLinkUp(void) const
virtual void AddLinkChangeCallback(Callback< void > callback)
virtual void DoInitialize(void)
Initialize() implementation.
represent a single transmission mode
Definition: wifi-mode.h:48
Hold together all Wifi-related objects.
Ptr< WifiMac > GetMac(void) const
Ptr< WifiPhy > GetPhy(void) const
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:71
@ WIFI_PREAMBLE_LONG
address
Definition: first.py:44
Every class exported by the ns3 library is enclosed in the ns3 namespace.
channel
Definition: third.py:92
mac
Definition: third.py:99
phy
Definition: third.py:93
TxInfo()
Initializer.
uint32_t txPowerLevel
transmit power level
uint32_t priority
priority
TxInfo(uint32_t channel, uint32_t prio=7, WifiMode rate=WifiMode(), WifiPreamble preamble=WIFI_PREAMBLE_LONG, uint32_t powerLevel=8)
Initializer.
WifiMode dataRate
data rate
WifiPreamble preamble
preamble
uint32_t channelNumber
channel number
uint32_t txPowerLevel
transmit power level
WifiMode dataRate
data rate
WifiPreamble preamble
preamble
bool adaptable
adaptable
uint32_t channelNumber
channel number
TxProfile(void)
Initializer.
TxProfile(uint32_t channel, bool adapt=true, uint32_t powerLevel=4)
Initializer.