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) 2007,2008, 2009 INRIA, UDcast
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Authors: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
19  * Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
20  */
25 #include "ns3/net-device.h"
26 #include "ns3/event-id.h"
27 #include "ns3/mac48-address.h"
28 #include "cid.h"
29 #include "wimax-connection.h"
30 #include "cid-factory.h"
31 #include "mac-messages.h"
32 #include "dl-mac-messages.h"
33 #include "ul-mac-messages.h"
34 #include "ns3/traced-callback.h"
35 #include "ns3/nstime.h"
36 #include "ns3/log.h"
37 #include "wimax-phy.h"
38 #include "wimax-mac-header.h"
40 namespace ns3 {
42 class Node;
43 class Packet;
44 class TraceContext;
45 class TraceResolver;
46 class Channel;
47 class WimaxChannel;
48 class PacketBurst;
49 class BurstProfileManager;
50 class ConnectionManager;
51 class ServiceFlowManager;
52 class BandwidthManager;
53 class UplinkScheduler;
68 class WimaxNetDevice : public NetDevice
69 {
70 public:
72  enum Direction
73  {
76  };
80  {
85  };
91  static TypeId GetTypeId (void);
92  WimaxNetDevice (void);
93  virtual ~WimaxNetDevice (void);
98  void SetTtg (uint16_t ttg);
103  uint16_t GetTtg (void) const;
108  void SetRtg (uint16_t rtg);
113  uint16_t GetRtg (void) const;
123  void SetPhy (Ptr<WimaxPhy> phy);
128  Ptr<WimaxPhy> GetPhy (void) const;
134  void SetChannel (Ptr<WimaxChannel> wimaxChannel);
141  uint64_t GetChannel (uint8_t index) const;
147  void SetNrFrames (uint32_t nrFrames);
152  uint32_t GetNrFrames (void) const;
162  Mac48Address GetMacAddress (void) const;
167  void SetState (uint8_t state);
172  uint8_t GetState (void) const;
188  void SetCurrentDcd (Dcd dcd);
193  Dcd GetCurrentDcd (void) const;
198  void SetCurrentUcd (Ucd ucd);
203  Ucd GetCurrentUcd (void) const;
214  virtual void SetConnectionManager (Ptr<ConnectionManager> connectionManager );
226  void SetBurstProfileManager (Ptr<BurstProfileManager> burstProfileManager);
238  void SetBandwidthManager (Ptr<BandwidthManager> bandwidthManager);
243  void CreateDefaultConnections (void);
246  virtual void Start (void) = 0;
248  virtual void Stop (void) = 0;
251  void SetReceiveCallback (void);
259  void ForwardUp (Ptr<Packet> packet, const Mac48Address &source, const Mac48Address &dest);
268  virtual bool Enqueue (Ptr<Packet> packet, const MacHeaderType &hdrType, Ptr<WimaxConnection> connection) = 0;
274  void ForwardDown (Ptr<PacketBurst> burst, WimaxPhy::ModulationType modulationType);
276  // temp, shall be private
277  static uint8_t m_direction;
285  virtual void SetName (const std::string name);
290  virtual std::string GetName (void) const;
295  virtual void SetIfIndex (const uint32_t index);
300  virtual uint32_t GetIfIndex (void) const;
305  virtual Ptr<Channel> GetPhyChannel (void) const;
310  virtual Ptr<Channel> GetChannel (void) const;
315  virtual void SetAddress (Address address);
320  virtual Address GetAddress (void) const;
326  virtual bool SetMtu (const uint16_t mtu);
331  virtual uint16_t GetMtu (void) const;
336  virtual bool IsLinkUp (void) const;
341  virtual void SetLinkChangeCallback (Callback<void> callback);
346  virtual bool IsBroadcast (void) const;
351  virtual Address GetBroadcast (void) const;
356  virtual bool IsMulticast (void) const;
361  virtual Address GetMulticast (void) const;
367  virtual Address MakeMulticastAddress (Ipv4Address multicastGroup) const;
372  virtual bool IsPointToPoint (void) const;
380  virtual bool Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber);
385  virtual void SetNode (Ptr<Node> node);
390  virtual Ptr<Node> GetNode (void) const;
395  virtual bool NeedsArp (void) const;
405  virtual void AddLinkChangeCallback (Callback<void> callback);
414  virtual bool SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber);
429  virtual bool SupportsSendFrom (void) const;
441  typedef void (* TxRxTracedCallback)
442  (Ptr<const Packet> packet, const Mac48Address & mac);
460  virtual void DoDispose (void);
461  virtual Address GetMulticast (Ipv6Address addr) const;
462  virtual Address GetMulticast (Ipv4Address multicastGroup) const;
463  virtual bool IsBridge (void) const;
469  bool IsPromisc (void);
476 private:
478  WimaxNetDevice (const WimaxNetDevice &);
486  static const uint16_t MAX_MSDU_SIZE = 1500;
488  static const uint16_t DEFAULT_MSDU_SIZE = 1400;
498  virtual bool DoSend (Ptr<Packet> packet,
499  const Mac48Address& source,
500  const Mac48Address& dest,
501  uint16_t protocolNumber) = 0;
506  virtual void DoReceive (Ptr<Packet> packet) = 0;
511  virtual Ptr<WimaxChannel> DoGetChannel (void) const;
516  void Receive (Ptr<const PacketBurst> burst);
518  void InitializeChannels (void);
525  uint32_t m_ifIndex;
526  std::string m_name;
527  bool m_linkUp;
529  mutable uint16_t m_mtu;
532  static uint32_t m_nrFrames;
535  std::vector<uint64_t> m_dlChannels;
538  uint8_t m_state;
539  uint32_t m_symbolIndex;
542  uint16_t m_ttg;
544  uint16_t m_rtg;
558 };
560 } // namespace ns3
562 #endif /* WIMAX_NET_DEVICE_H */
uint16_t m_ttg
length of TTG in units of PSs
Mac48Address m_address
MAC address.
void SetRtg(uint16_t rtg)
Set receive/transmit transition gap.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
uint16_t GetRtg(void) const
Get receive/transmit transition gap.
NetDevice::PromiscReceiveCallback m_promiscRx
promiscious receive fcallback function
virtual bool DoSend(Ptr< Packet > packet, const Mac48Address &source, const Mac48Address &dest, uint16_t protocolNumber)=0
Send a packet.
virtual ~WimaxNetDevice(void)
std::string m_name
service name
Forward calls to a chain of Callback.
uint32_t m_symbolIndex
symbol index
Ptr< WimaxConnection > m_broadcastConnection
broadcast connection
void ForwardUp(Ptr< Packet > packet, const Mac48Address &source, const Mac48Address &dest)
Forward a packet to the next layer above the device.
Ptr< BurstProfileManager > m_burstProfileManager
burst profile manager
Callback< void > m_linkChange
link change callback
Dcd GetCurrentDcd(void) const
Get the current DCD.
Ptr< WimaxConnection > GetBroadcastConnection(void) const
Get the broadcast connection.
void Receive(Ptr< const PacketBurst > burst)
Receive a packet burst.
Ptr< ConnectionManager > GetConnectionManager(void) const
Get the connection manager of the device.
Direction enumeration.
void(* TxRxTracedCallback)(Ptr< const Packet > packet, const Mac48Address &mac)
TracedCallback signature for packet and Mac48Address.
a polymophic address class
Definition: address.h:90
Definition: third.py:85
Definition: third.py:86
static const uint16_t DEFAULT_MSDU_SIZE
recommended by wimax forum.
virtual bool IsMulticast(void) const
Check if multicast enabled.
uint32_t GetNrFrames(void) const
Get the number of frames.
virtual void Stop(void)=0
Stop function.
virtual Ptr< Channel > GetChannel(void) const
Get the channel.
virtual bool SetMtu(const uint16_t mtu)
Set MTU value for the device.
WimaxNetDevice & operator=(const WimaxNetDevice &)
assignment operator (disabled)
static TypeId GetTypeId(void)
Get the type ID.
virtual Address GetMulticast(void) const
Get multicast address.
uint16_t GetTtg(void) const
Get transmission/receive transition gap.
void SetCurrentDcd(Dcd dcd)
Set the current DCD.
void SetTtg(uint16_t ttg)
Set transmission/receive transition gap.
Ptr< ConnectionManager > m_connectionManager
connection manager
Ptr< WimaxConnection > m_initialRangingConnection
initial rnaging connection
virtual void SetIfIndex(const uint32_t index)
Set interface index.
This class implements the UCD message as described by "IEEE Standard for Local and metropolitan area ...
std::vector< uint64_t > m_dlChannels
not sure if it shall be included here
virtual Ptr< WimaxChannel > DoGetChannel(void) const
Get the channel.
Ptr< Object > m_mobility
modility model
Definition: third.py:92
virtual Address GetBroadcast(void) const
Get broadcast address.
Ptr< WimaxConnection > GetInitialRangingConnection(void) const
Get the initial ranging connection.
Ptr< BandwidthManager > GetBandwidthManager(void) const
Get the bandwidth manager on the device.
static uint32_t m_nrFrames
temp, shall be in BS. defined here to allow SS to access. SS shall actually determine it from DLFP...
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
Set promiscious receive callback function.
virtual void Start(void)=0
Start function.
bool IsPromisc(void)
Check if device is promiscious.
virtual void SetConnectionManager(Ptr< ConnectionManager > connectionManager)
Set the connection manager of the device.
This class implements Downlink channel descriptor as described by "IEEE Standard for Local and metrop...
Mac48Address GetMacAddress(void) const
Get the MAC address.
This class Represents the HT (Header Type) field of generic MAC and bandwidth request headers...
virtual void DoDispose(void)
Destructor implementation.
virtual uint32_t GetIfIndex(void) const
Get interface index.
virtual Ptr< Node > GetNode(void) const
Get node pointer.
void SetBandwidthManager(Ptr< BandwidthManager > bandwidthManager)
Set the bandwidth manager on the device.
virtual Address GetAddress(void) const
Get address of the device.
Hold together all WiMAX-related objects in a NetDevice.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Definition: first.py:37
virtual void SetLinkChangeCallback(Callback< void > callback)
Set link change callback function.
virtual bool IsBroadcast(void) const
Check if broadcast enabled.
void SetBurstProfileManager(Ptr< BurstProfileManager > burstProfileManager)
Set the burst profile manager.
TracedCallback< Ptr< const Packet >, const Mac48Address & > m_traceTx
Ucd GetCurrentUcd(void) const
Get the current UCD.
an EUI-48 address
Definition: mac48-address.h:43
void SetMacAddress(Mac48Address address)
Set the MAC address.
virtual void DoReceive(Ptr< Packet > packet)=0
Receive a packet.
virtual bool Enqueue(Ptr< Packet > packet, const MacHeaderType &hdrType, Ptr< WimaxConnection > connection)=0
Enqueue a packet.
uint32_t m_ifIndex
IF index.
void SetChannel(Ptr< WimaxChannel > wimaxChannel)
Set the channel object.
void SetPhy(Ptr< WimaxPhy > phy)
Set the physical layer object.
virtual bool IsLinkUp(void) const
Check if link is up.
NetDevice::PromiscReceiveCallback GetPromiscReceiveCallback(void)
Get promiscious receive callback function.
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
Send function.
void NotifyPromiscTrace(Ptr< Packet > p)
Notify promiscious trace of a packet arrival.
bool m_linkUp
link up?
Ptr< Node > m_node
the node
virtual bool SupportsSendFrom(void) const
Check if device supports the SendFrom method.
Ptr< BurstProfileManager > GetBurstProfileManager(void) const
Get the burst profile manager.
Describes an IPv6 address.
Definition: ipv6-address.h:49
ModulationType enumeration.
Definition: wimax-phy.h:49
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
virtual void AddLinkChangeCallback(Callback< void > callback)
Add link change callback function.
void SetNrFrames(uint32_t nrFrames)
Set the number of frames.
virtual bool IsPointToPoint(void) const
Check if device is a point-to-point device.
Network layer to device interface.
Definition: net-device.h:95
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
Send a packet.
void SetCurrentUcd(Ucd ucd)
Set the current UCD.
virtual uint16_t GetMtu(void) const
Get MTU of the device.
void ForwardDown(Ptr< PacketBurst > burst, WimaxPhy::ModulationType modulationType)
Forward a packet down the stack.
Ptr< WimaxPhy > GetPhy(void) const
Get the physical layer object.
virtual Ptr< Channel > GetPhyChannel(void) const
Get the channel (this method is redundant with GetChannel())
void CreateDefaultConnections(void)
Creates the initial ranging and broadcast connections.
NetDevice::ReceiveCallback m_forwardUp
forward up callback function
TracedCallback< Ptr< const Packet >, const Mac48Address & > m_traceRx
virtual Address MakeMulticastAddress(Ipv4Address multicastGroup) const
Make multicast address.
void Attach(Ptr< WimaxChannel > channel)
Attach device to channel.
void SetState(uint8_t state)
Set the device state.
void InitializeChannels(void)
Initialize channels function.
virtual std::string GetName(void) const
Get device name.
static const uint16_t MAX_MSDU_SIZE
Maximum MSDU size.
virtual void SetName(const std::string name)
Set device name.
virtual void SetAddress(Address address)
Set address of the device.
uint16_t m_rtg
length of RTG in units of PSs
virtual bool IsBridge(void) const
Return true if the net device is acting as a bridge.
Ptr< WimaxPhy > m_phy
the phy
virtual void SetNode(Ptr< Node > node)
Set node pointer.
virtual bool NeedsArp(void) const
Check if device needs ARP.
Ptr< BandwidthManager > m_bandwidthManager
badnwidth manager
a unique identifier for an interface.
Definition: type-id.h:58
void SetReceiveCallback(void)
Set receive callback function.
RangingStatus enumeration.
static Time m_frameStartTime
temp, to determine the frame start time at SS side, shall actually be determined by frame start pream...
uint8_t GetState(void) const
Get the device state.
static uint8_t m_direction
downlink or uplink