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