A Discrete-Event Network Simulator
API
wave-net-device.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2005,2006 INRIA
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License version 2 as
5  * published by the Free Software Foundation;
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15  *
16  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
17  * Junling Bu <linlinjavaer@gmail.com>
18  */
19 #ifndef WAVE_NET_DEVICE_H
20 #define WAVE_NET_DEVICE_H
21 
22 #include "channel-coordinator.h"
23 #include "channel-manager.h"
24 #include "channel-scheduler.h"
25 #include "ocb-wifi-mac.h"
26 #include "vendor-specific-action.h"
27 #include "vsa-manager.h"
28 
29 #include "ns3/mac48-address.h"
30 #include "ns3/packet.h"
31 #include "ns3/traced-callback.h"
32 #include "ns3/wifi-net-device.h"
33 
34 #include <map>
35 #include <vector>
36 
37 namespace ns3
38 {
39 struct SchInfo;
40 struct VsaInfo;
41 class NetDevice;
42 class ChannelScheduler;
43 class VsaManager;
44 class OcbWifiMac;
45 
65 struct TxInfo
66 {
67  uint32_t channelNumber;
68  uint32_t priority;
71  uint32_t txPowerLevel;
72 
73  // Time expiryTime; // unsupported
76  : channelNumber(CCH),
77  priority(7),
78  txPowerLevel(8)
79  {
80  }
81 
90  TxInfo(uint32_t channel,
91  uint32_t prio = 7,
92  WifiMode rate = WifiMode(),
94  uint32_t powerLevel = 8)
96  priority(prio),
97  dataRate(rate),
99  txPowerLevel(powerLevel)
100  {
101  }
102 };
103 
118 struct TxProfile
119 {
120  uint32_t channelNumber;
121  bool adaptable;
122  uint32_t txPowerLevel;
125 
128  : channelNumber(SCH1),
129  adaptable(false),
130  txPowerLevel(4),
132  {
133  dataRate = WifiMode("OfdmRate6MbpsBW10MHz");
134  }
135 
142  TxProfile(uint32_t channel, bool adapt = true, uint32_t powerLevel = 4)
144  adaptable(adapt),
145  txPowerLevel(powerLevel)
146  {
147  dataRate = WifiMode("OfdmRate6MbpsBW10MHz");
149  }
150 };
151 
169 {
170  public:
175  static TypeId GetTypeId();
176  WaveNetDevice();
177  ~WaveNetDevice() override;
178 
183  void AddMac(uint32_t channelNumber, Ptr<OcbWifiMac> mac);
188  Ptr<OcbWifiMac> GetMac(uint32_t channelNumber) const;
192  std::map<uint32_t, Ptr<OcbWifiMac>> GetMacs() const;
196  void AddPhy(Ptr<WifiPhy> phy);
201  Ptr<WifiPhy> GetPhy(uint8_t index) const override;
205  const std::vector<Ptr<WifiPhy>>& GetPhys() const override;
206 
210  void SetChannelScheduler(Ptr<ChannelScheduler> channelScheduler);
218  void SetChannelManager(Ptr<ChannelManager> channelManager);
226  void SetChannelCoordinator(Ptr<ChannelCoordinator> channelCoordinator);
234  void SetVsaManager(Ptr<VsaManager> vsaManager);
239 
244  bool StartSch(const SchInfo& schInfo);
249  bool StopSch(uint32_t channelNumber);
250 
255  bool StartVsa(const VsaInfo& vsaInfo);
260  bool StopVsa(uint32_t channelNumber);
271  typedef Callback<bool, Ptr<const Packet>, const Address&, uint32_t, uint32_t> WaveVsaCallback;
275  void SetWaveVsaCallback(WaveVsaCallback vsaCallback);
276 
285  bool RegisterTxProfile(const TxProfile& txprofile);
292  bool DeleteTxProfile(uint32_t channelNumber);
293 
306  bool SendX(Ptr<Packet> packet, const Address& dest, uint32_t protocol, const TxInfo& txInfo);
315  void ChangeAddress(Address newAddress);
322  void CancelTx(uint32_t channelNumber, AcIndex ac);
323 
336  bool Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber) override;
337 
338  // inherited from NetDevice base class.
339  void SetIfIndex(const uint32_t index) override;
340  uint32_t GetIfIndex() const override;
341  Ptr<Channel> GetChannel() const override;
342  void SetAddress(Address address) override;
343  Address GetAddress() const override;
344  bool SetMtu(const uint16_t mtu) override;
345  uint16_t GetMtu() const override;
346  bool IsLinkUp() const override;
347  void AddLinkChangeCallback(Callback<void> callback) override;
348  bool IsBroadcast() const override;
349  Address GetBroadcast() const override;
350  bool IsMulticast() const override;
351  Address GetMulticast(Ipv4Address multicastGroup) const override;
352  bool IsPointToPoint() const override;
353  bool IsBridge() const override;
354  bool NeedsArp() const override;
356  Address GetMulticast(Ipv6Address addr) const override;
357  bool SendFrom(Ptr<Packet> packet,
358  const Address& source,
359  const Address& dest,
360  uint16_t protocolNumber) override;
362  bool SupportsSendFrom() const override;
363 
364  private:
366  static const uint16_t MAX_MSDU_SIZE = 2304;
367 
369  static const uint16_t IPv4_PROT_NUMBER = 0x0800;
371  static const uint16_t IPv6_PROT_NUMBER = 0x86DD;
372 
373  void DoDispose() override;
374  void DoInitialize() override;
379  bool IsAvailableChannel(uint32_t channelNumber) const;
388  void ForwardUp(Ptr<const Packet> packet, Mac48Address from, Mac48Address to);
389 
391  typedef std::map<uint32_t, Ptr<OcbWifiMac>> MacEntities;
393  typedef std::map<uint32_t, Ptr<OcbWifiMac>>::const_iterator MacEntitiesI;
396  typedef std::vector<Ptr<WifiPhy>> PhyEntities;
398  typedef std::vector<Ptr<WifiPhy>>::const_iterator PhyEntitiesI;
400 
411 
412  // copy from WifiNetDevice
415  uint32_t m_ifIndex;
416  mutable uint16_t m_mtu;
417 };
418 
419 } // namespace ns3
420 
421 #endif /* WAVE_NET_DEVICE_H */
#define SCH1
#define CCH
a polymophic address class
Definition: address.h:100
Callback template class.
Definition: callback.h:443
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:43
Describes an IPv6 address.
Definition: ipv6-address.h:50
an EUI-48 address
Definition: mac48-address.h:46
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition: type-id.h:60
This class holds together multiple, ns3::WifiPhy, and ns3::OcbWifiMac (including ns3::WifiRemoteStati...
bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber) override
void AddPhy(Ptr< WifiPhy > phy)
bool IsPointToPoint() const override
Return true if the net device is on a point-to-point link.
void SetChannelCoordinator(Ptr< ChannelCoordinator > channelCoordinator)
bool StartSch(const SchInfo &schInfo)
void ChangeAddress(Address newAddress)
bool IsBridge() const override
Return true if the net device is acting as a bridge.
bool DeleteTxProfile(uint32_t channelNumber)
void AddMac(uint32_t channelNumber, Ptr< OcbWifiMac > mac)
bool IsLinkUp() const override
Address GetAddress() const override
void DoDispose() override
Destructor implementation.
NetDevice::ReceiveCallback m_forwardUp
forward up receive callback
void SetAddress(Address address) override
Set the address of this interface.
void SetChannelScheduler(Ptr< ChannelScheduler > channelScheduler)
Ptr< VsaManager > m_vsaManager
the VSA manager
std::vector< Ptr< WifiPhy > > PhyEntities
PhyEntities typedef.
Address GetBroadcast() const override
PhyEntities m_phyEntities
Phy entities.
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.
void SetPromiscReceiveCallback(PromiscReceiveCallback cb) override
MacEntities m_macEntities
MAC entities.
Ptr< ChannelScheduler > GetChannelScheduler() const
void ForwardUp(Ptr< const Packet > packet, Mac48Address from, Mac48Address to)
Receive a packet from the lower layer and pass the packet up the stack.
static TypeId GetTypeId()
Get the type ID.
void SetReceiveCallback(NetDevice::ReceiveCallback cb) override
bool StopVsa(uint32_t channelNumber)
uint16_t GetMtu() const override
const std::vector< Ptr< WifiPhy > > & GetPhys() const override
bool SetMtu(const uint16_t mtu) override
static const uint16_t IPv6_PROT_NUMBER
IP v6 Protocol number.
std::map< uint32_t, Ptr< OcbWifiMac > > GetMacs() const
bool NeedsArp() const override
void DoInitialize() override
Initialize() implementation.
bool SendX(Ptr< Packet > packet, const Address &dest, uint32_t protocol, const TxInfo &txInfo)
bool RegisterTxProfile(const TxProfile &txprofile)
TracedCallback< Address, Address > m_addressChange
NetDevice::PromiscReceiveCallback m_promiscRx
promiscious receive callback
bool IsMulticast() const override
void CancelTx(uint32_t channelNumber, AcIndex ac)
std::map< uint32_t, Ptr< OcbWifiMac > > MacEntities
MacEntities typedef.
uint32_t GetIfIndex() const override
Callback< bool, Ptr< const Packet >, const Address &, uint32_t, uint32_t > WaveVsaCallback
bool IsBroadcast() const override
Ptr< ChannelCoordinator > m_channelCoordinator
the channel coordinator
bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber) override
void AddLinkChangeCallback(Callback< void > callback) override
Ptr< ChannelCoordinator > GetChannelCoordinator() const
bool IsAvailableChannel(uint32_t channelNumber) const
void SetWaveVsaCallback(WaveVsaCallback vsaCallback)
std::vector< Ptr< WifiPhy > >::const_iterator PhyEntitiesI
PhyEntities iterator typedef.
Address GetMulticast(Ipv4Address multicastGroup) const override
Make and return a MAC multicast address using the provided multicast group.
TxProfile * m_txProfile
transmit profile
Ptr< VsaManager > GetVsaManager() const
void SetChannelManager(Ptr< ChannelManager > channelManager)
Ptr< Channel > GetChannel() const override
bool SupportsSendFrom() const override
Ptr< ChannelManager > GetChannelManager() const
bool StartVsa(const VsaInfo &vsaInfo)
Ptr< ChannelManager > m_channelManager
the channel manager
static const uint16_t IPv4_PROT_NUMBER
IP v4 Protocol number.
bool StopSch(uint32_t channelNumber)
void SetIfIndex(const uint32_t index) override
represent a single transmission mode
Definition: wifi-mode.h:50
Hold together all Wifi-related objects.
Ptr< WifiMac > GetMac() const
Ptr< WifiPhy > GetPhy() 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:72
@ WIFI_PREAMBLE_LONG
address
Definition: first.py:40
Every class exported by the ns3 library is enclosed in the ns3 namespace.
channel
Definition: third.py:81
mac
Definition: third.py:85
phy
Definition: third.py:82
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()
Initializer.
TxProfile(uint32_t channel, bool adapt=true, uint32_t powerLevel=4)
Initializer.