A Discrete-Event Network Simulator
API
wimax-net-device.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2007,2008, 2009 INRIA, UDcast
3  *
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  * Authors: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
18  * Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
19  */
20 
21 #ifndef WIMAX_NET_DEVICE_H
22 #define WIMAX_NET_DEVICE_H
23 
24 #include "cid-factory.h"
25 #include "cid.h"
26 #include "dl-mac-messages.h"
27 #include "mac-messages.h"
28 #include "ul-mac-messages.h"
29 #include "wimax-connection.h"
30 #include "wimax-mac-header.h"
31 #include "wimax-phy.h"
32 
33 #include "ns3/event-id.h"
34 #include "ns3/log.h"
35 #include "ns3/mac48-address.h"
36 #include "ns3/net-device.h"
37 #include "ns3/nstime.h"
38 #include "ns3/traced-callback.h"
39 
40 namespace ns3
41 {
42 
43 class Node;
44 class Packet;
45 class TraceContext;
46 class TraceResolver;
47 class Channel;
48 class WimaxChannel;
49 class PacketBurst;
50 class BurstProfileManager;
51 class ConnectionManager;
52 class ServiceFlowManager;
53 class BandwidthManager;
54 class UplinkScheduler;
55 
70 class WimaxNetDevice : public NetDevice
71 {
72  public:
74  enum Direction
75  {
78  };
79 
82  {
87  };
88 
93  static TypeId GetTypeId();
95  ~WimaxNetDevice() override;
100  void SetTtg(uint16_t ttg);
105  uint16_t GetTtg() const;
110  void SetRtg(uint16_t rtg);
115  uint16_t GetRtg() const;
125  void SetPhy(Ptr<WimaxPhy> phy);
130  Ptr<WimaxPhy> GetPhy() const;
131 
136  void SetChannel(Ptr<WimaxChannel> wimaxChannel);
137 
143  uint64_t GetChannel(uint8_t index) const;
144 
149  void SetNrFrames(uint32_t nrFrames);
154  uint32_t GetNrFrames() const;
164  Mac48Address GetMacAddress() const;
169  void SetState(uint8_t state);
174  uint8_t GetState() const;
185 
190  void SetCurrentDcd(Dcd dcd);
195  Dcd GetCurrentDcd() const;
200  void SetCurrentUcd(Ucd ucd);
205  Ucd GetCurrentUcd() const;
211 
216  virtual void SetConnectionManager(Ptr<ConnectionManager> connectionManager);
217 
223 
228  void SetBurstProfileManager(Ptr<BurstProfileManager> burstProfileManager);
229 
235 
240  void SetBandwidthManager(Ptr<BandwidthManager> bandwidthManager);
241 
246 
248  virtual void Start() = 0;
250  virtual void Stop() = 0;
251 
253  void SetReceiveCallback();
254 
261  void ForwardUp(Ptr<Packet> packet, const Mac48Address& source, const Mac48Address& dest);
262 
270  virtual bool Enqueue(Ptr<Packet> packet,
271  const MacHeaderType& hdrType,
272  Ptr<WimaxConnection> connection) = 0;
278  void ForwardDown(Ptr<PacketBurst> burst, WimaxPhy::ModulationType modulationType);
279 
280  // temp, shall be private
281  static uint8_t m_direction;
282 
285 
290  virtual void SetName(const std::string name);
295  virtual std::string GetName() const;
300  void SetIfIndex(const uint32_t index) override;
305  uint32_t GetIfIndex() const override;
310  virtual Ptr<Channel> GetPhyChannel() const;
315  Ptr<Channel> GetChannel() const override;
320  void SetAddress(Address address) override;
325  Address GetAddress() const override;
331  bool SetMtu(const uint16_t mtu) override;
336  uint16_t GetMtu() const override;
341  bool IsLinkUp() const override;
346  virtual void SetLinkChangeCallback(Callback<void> callback);
351  bool IsBroadcast() const override;
356  Address GetBroadcast() const override;
361  bool IsMulticast() const override;
366  virtual Address GetMulticast() const;
372  virtual Address MakeMulticastAddress(Ipv4Address multicastGroup) const;
377  bool IsPointToPoint() const override;
385  bool Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber) override;
390  void SetNode(Ptr<Node> node) override;
395  Ptr<Node> GetNode() const override;
400  bool NeedsArp() const override;
410  void AddLinkChangeCallback(Callback<void> callback) override;
419  bool SendFrom(Ptr<Packet> packet,
420  const Address& source,
421  const Address& dest,
422  uint16_t protocolNumber) override;
437  bool SupportsSendFrom() const override;
438 
449  typedef void (*TxRxTracedCallback)(Ptr<const Packet> packet, const Mac48Address& mac);
466 
467  void DoDispose() override;
468  Address GetMulticast(Ipv6Address addr) const override;
469  Address GetMulticast(Ipv4Address multicastGroup) const override;
470  bool IsBridge() const override;
471 
476  bool IsPromisc();
482 
483  private:
491 
493  static const uint16_t MAX_MSDU_SIZE = 1500;
495  static const uint16_t DEFAULT_MSDU_SIZE = 1400;
496 
505  virtual bool DoSend(Ptr<Packet> packet,
506  const Mac48Address& source,
507  const Mac48Address& dest,
508  uint16_t protocolNumber) = 0;
513  virtual void DoReceive(Ptr<Packet> packet) = 0;
518  virtual Ptr<WimaxChannel> DoGetChannel() const;
523  void Receive(Ptr<const PacketBurst> burst);
525  void InitializeChannels();
526 
531 
532  uint32_t m_ifIndex;
533  std::string m_name;
534  bool m_linkUp;
536  mutable uint16_t m_mtu;
537 
540  static uint32_t m_nrFrames;
541 
543  std::vector<uint64_t> m_dlChannels;
544 
546  uint8_t m_state;
547  uint32_t m_symbolIndex;
548 
550  uint16_t m_ttg;
552  uint16_t m_rtg;
553 
556 
559 
563 };
564 
565 } // namespace ns3
566 
567 #endif /* WIMAX_NET_DEVICE_H */
a polymophic address class
Definition: address.h:101
This class implements Downlink channel descriptor as described by "IEEE Standard for Local and metrop...
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
Describes an IPv6 address.
Definition: ipv6-address.h:49
an EUI-48 address
Definition: mac48-address.h:46
This class Represents the HT (Header Type) field of generic MAC and bandwidth request headers.
Network layer to device interface.
Definition: net-device.h:98
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition: type-id.h:59
This class implements the UCD message as described by "IEEE Standard for Local and metropolitan area ...
Hold together all WiMAX-related objects in a NetDevice.
NetDevice::ReceiveCallback m_forwardUp
forward up callback function
Ptr< Channel > GetChannel() const override
Get the channel.
virtual std::string GetName() const
Get device name.
void DoDispose() override
Destructor implementation.
uint16_t GetRtg() const
Get receive/transmit transition gap.
void SetRtg(uint16_t rtg)
Set receive/transmit transition gap.
virtual void SetConnectionManager(Ptr< ConnectionManager > connectionManager)
Set the connection manager of the device.
Ptr< BandwidthManager > m_bandwidthManager
badnwidth manager
bool NeedsArp() const override
Check if device needs ARP.
Ptr< BurstProfileManager > m_burstProfileManager
burst profile manager
static uint8_t m_direction
downlink or uplink
TracedCallback< Ptr< const Packet >, const Mac48Address & > m_traceTx
NetDevice::PromiscReceiveCallback GetPromiscReceiveCallback()
Get promiscuous receive callback function.
void Receive(Ptr< const PacketBurst > burst)
Receive a packet burst.
void SetAddress(Address address) override
Set address of the device.
std::vector< uint64_t > m_dlChannels
not sure if it shall be included here
NetDevice::PromiscReceiveCallback m_promiscRx
promiscuous receive callback function
Direction
Direction enumeration.
Mac48Address m_address
MAC address.
static TypeId GetTypeId()
Get the type ID.
bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber) override
Send a packet.
Ptr< ConnectionManager > GetConnectionManager() const
Get the connection manager of the device.
virtual void Stop()=0
Stop function.
RangingStatus
RangingStatus enumeration.
Ptr< WimaxConnection > m_initialRangingConnection
initial rnaging connection
uint32_t GetIfIndex() const override
Get interface index.
bool IsMulticast() const override
Check if multicast enabled.
Ucd GetCurrentUcd() const
Get the current UCD.
virtual Address MakeMulticastAddress(Ipv4Address multicastGroup) const
Make multicast address.
void SetPhy(Ptr< WimaxPhy > phy)
Set the physical layer object.
Address GetAddress() const override
Get address of the device.
Address GetBroadcast() const override
Get broadcast address.
virtual bool DoSend(Ptr< Packet > packet, const Mac48Address &source, const Mac48Address &dest, uint16_t protocolNumber)=0
Send a packet.
virtual Ptr< Channel > GetPhyChannel() const
Get the channel (this method is redundant with GetChannel())
void AddLinkChangeCallback(Callback< void > callback) override
Add link change callback function.
virtual void SetName(const std::string name)
Set device name.
uint8_t GetState() const
Get the device state.
uint16_t GetMtu() const override
Get MTU of the device.
static const uint16_t DEFAULT_MSDU_SIZE
recommended by wimax forum.
virtual void Start()=0
Start function.
static const uint16_t MAX_MSDU_SIZE
Maximum MSDU size.
void SetCurrentUcd(Ucd ucd)
Set the current UCD.
uint32_t GetNrFrames() const
Get the number of frames.
void SetMacAddress(Mac48Address address)
Set the MAC address.
Ptr< Node > GetNode() const override
Get node pointer.
Ptr< WimaxConnection > m_broadcastConnection
broadcast connection
static Time m_frameStartTime
temp, to determine the frame start time at SS side, shall actually be determined by frame start pream...
void SetBurstProfileManager(Ptr< BurstProfileManager > burstProfileManager)
Set the burst profile manager.
void SetState(uint8_t state)
Set the device state.
Ptr< WimaxPhy > m_phy
the phy
virtual bool Enqueue(Ptr< Packet > packet, const MacHeaderType &hdrType, Ptr< WimaxConnection > connection)=0
Enqueue a packet.
void SetChannel(Ptr< WimaxChannel > wimaxChannel)
Set the channel object.
bool SetMtu(const uint16_t mtu) override
Set MTU value for the device.
Ptr< WimaxConnection > GetInitialRangingConnection() const
Get the initial ranging connection.
virtual void SetLinkChangeCallback(Callback< void > callback)
Set link change callback function.
Ptr< ConnectionManager > m_connectionManager
connection manager
void SetBandwidthManager(Ptr< BandwidthManager > bandwidthManager)
Set the bandwidth manager on the device.
Ptr< WimaxPhy > GetPhy() const
Get the physical layer object.
uint32_t m_ifIndex
IF index.
void SetPromiscReceiveCallback(PromiscReceiveCallback cb) override
Set promiscuous receive callback function.
bool IsPointToPoint() const override
Check if device is a point-to-point device.
void InitializeChannels()
Initialize channels function.
Ptr< BandwidthManager > GetBandwidthManager() const
Get the bandwidth manager on the device.
Ptr< WimaxConnection > GetBroadcastConnection() const
Get the broadcast connection.
Callback< void > m_linkChange
link change callback
virtual Address GetMulticast() const
Get multicast address.
std::string m_name
service name
virtual void DoReceive(Ptr< Packet > packet)=0
Receive a packet.
bool IsPromisc()
Check if device is promiscuous.
static uint32_t m_nrFrames
temp, shall be in BS.
void Attach(Ptr< WimaxChannel > channel)
Attach device to channel.
void SetTtg(uint16_t ttg)
Set transmission/receive transition gap.
void CreateDefaultConnections()
Creates the initial ranging and broadcast connections.
void SetNrFrames(uint32_t nrFrames)
Set the number of frames.
uint16_t m_ttg
length of TTG in units of PSs
void SetCurrentDcd(Dcd dcd)
Set the current DCD.
WimaxNetDevice & operator=(const WimaxNetDevice &)
assignment operator (disabled)
void SetReceiveCallback()
Set receive callback function.
bool SupportsSendFrom() const override
Check if device supports the SendFrom method.
WimaxNetDevice(const WimaxNetDevice &)
copy constructor (disabled)
bool IsLinkUp() const override
Check if link is up.
void SetIfIndex(const uint32_t index) override
Set interface index.
uint16_t GetTtg() const
Get transmission/receive transition gap.
Mac48Address GetMacAddress() const
Get the MAC address.
void SetNode(Ptr< Node > node) override
Set node pointer.
bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber) override
Send function.
void(* TxRxTracedCallback)(Ptr< const Packet > packet, const Mac48Address &mac)
TracedCallback signature for packet and Mac48Address.
Ptr< Node > m_node
the node
uint32_t m_symbolIndex
symbol index
void NotifyPromiscTrace(Ptr< Packet > p)
Notify promiscuous trace of a packet arrival.
void ForwardUp(Ptr< Packet > packet, const Mac48Address &source, const Mac48Address &dest)
Forward a packet to the next layer above the device.
TracedCallback< Ptr< const Packet >, const Mac48Address & > m_traceRx
virtual Ptr< WimaxChannel > DoGetChannel() const
Get the channel.
Ptr< BurstProfileManager > GetBurstProfileManager() const
Get the burst profile manager.
Dcd GetCurrentDcd() const
Get the current DCD.
void ForwardDown(Ptr< PacketBurst > burst, WimaxPhy::ModulationType modulationType)
Forward a packet down the stack.
bool IsBridge() const override
Return true if the net device is acting as a bridge.
uint16_t m_rtg
length of RTG in units of PSs
bool IsBroadcast() const override
Check if broadcast enabled.
ModulationType
ModulationType enumeration.
Definition: wimax-phy.h:54
address
Definition: first.py:47
Every class exported by the ns3 library is enclosed in the ns3 namespace.
channel
Definition: third.py:88
mac
Definition: third.py:92
phy
Definition: third.py:89