A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
wimax-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) 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
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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  */
21 
22 #ifndef WIMAX_NET_DEVICE_H
23 #define WIMAX_NET_DEVICE_H
24 
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"
39 
40 namespace ns3 {
41 
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;
54 
69 class WimaxNetDevice : public NetDevice
70 {
71 public:
72  enum Direction
73  {
75  };
76 
78  {
80  };
81 
82  static TypeId GetTypeId (void);
83  WimaxNetDevice (void);
84  virtual ~WimaxNetDevice (void);
88  void SetTtg (uint16_t ttg);
92  uint16_t GetTtg (void) const;
96  void SetRtg (uint16_t rtg);
100  uint16_t GetRtg (void) const;
101  void Attach (Ptr<WimaxChannel> channel);
105  void SetPhy (Ptr<WimaxPhy> phy);
109  Ptr<WimaxPhy> GetPhy (void) const;
110 
114  void SetChannel (Ptr<WimaxChannel> wimaxChannel);
115 
116  uint64_t GetChannel (uint8_t index) const;
117 
118  void SetNrFrames (uint32_t nrFrames);
119  uint32_t GetNrFrames (void) const;
127  Mac48Address GetMacAddress (void) const;
128  void SetState (uint8_t state);
129  uint8_t GetState (void) const;
138 
139  void SetCurrentDcd (Dcd dcd);
140  Dcd GetCurrentDcd (void) const;
141  void SetCurrentUcd (Ucd ucd);
142  Ucd GetCurrentUcd (void) const;
147 
151  virtual void SetConnectionManager (Ptr<ConnectionManager> connectionManager );
152 
157 
161  void SetBurstProfileManager (Ptr<BurstProfileManager> burstProfileManager);
162 
167 
171  void SetBandwidthManager (Ptr<BandwidthManager> bandwidthManager);
172 
173  /*
174  * \brief Creates the initial ranging and broadcast connections
175  */
176  void CreateDefaultConnections (void);
177 
178  virtual void Start (void) = 0;
179  virtual void Stop (void) = 0;
180 
181  void SetReceiveCallback (void);
182 
183  void ForwardUp (Ptr<Packet> packet, const Mac48Address &source, const Mac48Address &dest);
184 
185  virtual bool Enqueue (Ptr<Packet> packet, const MacHeaderType &hdrType, Ptr<WimaxConnection> connection) = 0;
186  void ForwardDown (Ptr<PacketBurst> burst, WimaxPhy::ModulationType modulationType);
187 
188  // temp, shall be private
189  static uint8_t m_direction; // downlink or uplink
190 
191  static Time m_frameStartTime; // temp, to determine the frame start time at SS side, shall actually be determined by frame start preamble
192 
193  virtual void SetName (const std::string name);
194  virtual std::string GetName (void) const;
195  virtual void SetIfIndex (const uint32_t index);
196  virtual uint32_t GetIfIndex (void) const;
197  virtual Ptr<Channel> GetPhyChannel (void) const;
198  virtual Ptr<Channel> GetChannel (void) const;
199  virtual void SetAddress (Address address);
200  virtual Address GetAddress (void) const;
201  virtual bool SetMtu (const uint16_t mtu);
202  virtual uint16_t GetMtu (void) const;
203  virtual bool IsLinkUp (void) const;
204  virtual void SetLinkChangeCallback (Callback<void> callback);
205  virtual bool IsBroadcast (void) const;
206  virtual Address GetBroadcast (void) const;
207  virtual bool IsMulticast (void) const;
208  virtual Address GetMulticast (void) const;
209  virtual Address MakeMulticastAddress (Ipv4Address multicastGroup) const;
210  virtual bool IsPointToPoint (void) const;
211  virtual bool Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber);
212  virtual void SetNode (Ptr<Node> node);
213  virtual Ptr<Node> GetNode (void) const;
214  virtual bool NeedsArp (void) const;
216  virtual void AddLinkChangeCallback (Callback<void> callback);
217  virtual bool SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber);
220  virtual bool SupportsSendFrom (void) const;
221 
224 
225  virtual void DoDispose (void);
226  virtual Address GetMulticast (Ipv6Address addr) const;
227  virtual Address GetMulticast (Ipv4Address multicastGroup) const;
228  virtual bool IsBridge (void) const;
229 
230  bool IsPromisc (void);
232 
233 private:
234  WimaxNetDevice (const WimaxNetDevice &);
236 
237  static const uint16_t MAX_MSDU_SIZE = 1500;
238  // recommended by wimax forum.
239  static const uint16_t DEFAULT_MSDU_SIZE = 1400;
240 
241  virtual bool DoSend (Ptr<Packet> packet,
242  const Mac48Address& source,
243  const Mac48Address& dest,
244  uint16_t protocolNumber) = 0;
245  virtual void DoReceive (Ptr<Packet> packet) = 0;
246  virtual Ptr<WimaxChannel> DoGetChannel (void) const;
247  void Receive (Ptr<const PacketBurst> burst);
248  void InitializeChannels (void);
249 
254 
255  uint32_t m_ifIndex;
256  std::string m_name;
257  bool m_linkUp;
259  mutable uint16_t m_mtu;
260 
261  // temp, shall be in BS. defined here to allow SS to access. SS shall actually determine it from DLFP, shall be moved to BS after DLFP is implemented
262  static uint32_t m_nrFrames;
263 
264  // not sure if it shall be included here
265  std::vector<uint64_t> m_dlChannels;
266 
268  uint8_t m_state;
269  uint32_t m_symbolIndex;
270 
271  // length of TTG and RTG, in units of PSs
272  uint16_t m_ttg;
273  uint16_t m_rtg;
274 
277 
280 
284 
286 
287 };
288 
289 } // namespace ns3
290 
291 #endif /* WIMAX_NET_DEVICE_H */
void SetRtg(uint16_t rtg)
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
uint16_t GetRtg(void) const
NetDevice::PromiscReceiveCallback m_promiscRx
virtual bool DoSend(Ptr< Packet > packet, const Mac48Address &source, const Mac48Address &dest, uint16_t protocolNumber)=0
virtual ~WimaxNetDevice(void)
forward calls to a chain of CallbackAn ns3::TracedCallback has almost exactly the same API as a norma...
Ptr< WimaxConnection > m_broadcastConnection
void ForwardUp(Ptr< Packet > packet, const Mac48Address &source, const Mac48Address &dest)
Ptr< BurstProfileManager > m_burstProfileManager
Callback< void > m_linkChange
Dcd GetCurrentDcd(void) const
Ptr< WimaxConnection > GetBroadcastConnection(void) const
void Receive(Ptr< const PacketBurst > burst)
Ptr< ConnectionManager > GetConnectionManager(void) const
a polymophic address class
Definition: address.h:86
static const uint16_t DEFAULT_MSDU_SIZE
virtual bool IsMulticast(void) const
uint32_t GetNrFrames(void) const
virtual void Stop(void)=0
virtual Ptr< Channel > GetChannel(void) const
TracedCallback< Ptr< const Packet >, const Mac48Address & > m_traceTx
virtual bool SetMtu(const uint16_t mtu)
WimaxNetDevice & operator=(const WimaxNetDevice &)
static TypeId GetTypeId(void)
virtual Address GetMulticast(void) const
uint16_t GetTtg(void) const
void SetCurrentDcd(Dcd dcd)
void SetTtg(uint16_t ttg)
Ptr< ConnectionManager > m_connectionManager
Ptr< WimaxConnection > m_initialRangingConnection
virtual void SetIfIndex(const uint32_t index)
Doxygen introspection did not find any typical Config paths.
std::vector< uint64_t > m_dlChannels
virtual Ptr< WimaxChannel > DoGetChannel(void) const
Ptr< Object > m_mobility
virtual Address GetBroadcast(void) const
Ptr< WimaxConnection > GetInitialRangingConnection(void) const
Ptr< BandwidthManager > GetBandwidthManager(void) const
static uint32_t m_nrFrames
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
virtual void Start(void)=0
virtual void SetConnectionManager(Ptr< ConnectionManager > connectionManager)
Doxygen introspection did not find any typical Config paths.
Mac48Address GetMacAddress(void) const
Represents the HT (Header Type) field of generic MAC and bandwidth request headers.
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
virtual uint32_t GetIfIndex(void) const
virtual Ptr< Node > GetNode(void) const
void SetBandwidthManager(Ptr< BandwidthManager > bandwidthManager)
virtual Address GetAddress(void) const
Hold together all Wimax-related objects in a NetDevice.
virtual void SetLinkChangeCallback(Callback< void > callback)
virtual bool IsBroadcast(void) const
void SetBurstProfileManager(Ptr< BurstProfileManager > burstProfileManager)
Ucd GetCurrentUcd(void) const
an EUI-48 address
Definition: mac48-address.h:41
void SetMacAddress(Mac48Address address)
virtual void DoReceive(Ptr< Packet > packet)=0
virtual bool Enqueue(Ptr< Packet > packet, const MacHeaderType &hdrType, Ptr< WimaxConnection > connection)=0
void SetChannel(Ptr< WimaxChannel > wimaxChannel)
void SetPhy(Ptr< WimaxPhy > phy)
virtual bool IsLinkUp(void) const
NetDevice::PromiscReceiveCallback GetPromiscReceiveCallback(void)
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
void NotifyPromiscTrace(Ptr< Packet > p)
virtual bool SupportsSendFrom(void) const
Ptr< BurstProfileManager > GetBurstProfileManager(void) const
Describes an IPv6 address.
Definition: ipv6-address.h:46
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
virtual void AddLinkChangeCallback(Callback< void > callback)
void SetNrFrames(uint32_t nrFrames)
virtual bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
Network layer to device interface.
Definition: net-device.h:75
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
void SetCurrentUcd(Ucd ucd)
virtual uint16_t GetMtu(void) const
void ForwardDown(Ptr< PacketBurst > burst, WimaxPhy::ModulationType modulationType)
Ptr< WimaxPhy > GetPhy(void) const
virtual Ptr< Channel > GetPhyChannel(void) const
void CreateDefaultConnections(void)
NetDevice::ReceiveCallback m_forwardUp
virtual Address MakeMulticastAddress(Ipv4Address multicastGroup) const
void Attach(Ptr< WimaxChannel > channel)
void SetState(uint8_t state)
virtual std::string GetName(void) const
static const uint16_t MAX_MSDU_SIZE
virtual void SetName(const std::string name)
tuple address
Definition: first.py:37
virtual void SetAddress(Address address)
Set the address of this interface.
virtual bool IsBridge(void) const
Return true if the net device is acting as a bridge.
Ptr< WimaxPhy > m_phy
virtual void SetNode(Ptr< Node > node)
virtual bool NeedsArp(void) const
Ptr< BandwidthManager > m_bandwidthManager
a unique identifier for an interface.
Definition: type-id.h:49
static Time m_frameStartTime
uint8_t GetState(void) const
TracedCallback< Ptr< const Packet >, const Mac48Address & > m_traceRx
static uint8_t m_direction