A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
wimax-net-device.h
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  {
74  DIRECTION_DOWNLINK, DIRECTION_UPLINK
75  };
76 
77  enum RangingStatus
78  {
79  RANGING_STATUS_EXPIRED, RANGING_STATUS_CONTINUE, RANGING_STATUS_ABORT, RANGING_STATUS_SUCCESS
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;
123  void SetMacAddress (Mac48Address address);
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;
215  virtual void SetReceiveCallback (NetDevice::ReceiveCallback cb);
216  virtual void AddLinkChangeCallback (Callback<void> callback);
217  virtual bool SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber);
219  NetDevice::PromiscReceiveCallback GetPromiscReceiveCallback (void);
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);
231  void NotifyPromiscTrace (Ptr<Packet> p);
232 
233 private:
234  WimaxNetDevice (const WimaxNetDevice &);
235  WimaxNetDevice & operator= (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 
250  Ptr<Node> m_node;
251  Ptr<WimaxPhy> m_phy;
252  NetDevice::ReceiveCallback m_forwardUp;
254 
255  uint32_t m_ifIndex;
256  std::string m_name;
257  bool m_linkUp;
258  Callback<void> m_linkChange;
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 
267  Mac48Address m_address;
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 
275  Dcd m_currentDcd;
276  Ucd m_currentUcd;
277 
278  Ptr<WimaxConnection> m_initialRangingConnection;
279  Ptr<WimaxConnection> m_broadcastConnection;
280 
281  Ptr<ConnectionManager> m_connectionManager;
282  Ptr<BurstProfileManager> m_burstProfileManager;
283  Ptr<BandwidthManager> m_bandwidthManager;
284 
285  Ptr<Object> m_mobility;
286 
287 };
288 
289 } // namespace ns3
290 
291 #endif /* WIMAX_NET_DEVICE_H */
void SetRtg(uint16_t rtg)
keep track of time unit.
Definition: nstime.h:149
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
uint16_t GetRtg(void) const
forward calls to a chain of CallbackAn ns3::TracedCallback has almost exactly the same API as a norma...
Ptr< WimaxConnection > GetBroadcastConnection(void) const
Ptr< ConnectionManager > GetConnectionManager(void) const
a polymophic address class
Definition: address.h:86
virtual bool IsMulticast(void) const
virtual Ptr< Channel > GetChannel(void) const
virtual bool SetMtu(const uint16_t mtu)
uint16_t GetTtg(void) const
void SetTtg(uint16_t ttg)
virtual void SetIfIndex(const uint32_t index)
virtual Address GetBroadcast(void) const
Ptr< WimaxConnection > GetInitialRangingConnection(void) const
Ptr< BandwidthManager > GetBandwidthManager(void) const
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
virtual void SetConnectionManager(Ptr< ConnectionManager > connectionManager)
Mac48Address GetMacAddress(void) const
Represents the HT (Header Type) field of generic MAC and bandwidth request headers.
virtual void DoDispose(void)
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.This class holds together ns3::WimaxPhy, ns3::WimaxConnection, ns3::ConectionManager, ns3::BurstProfileManager, and ns3::BandwidthManager.
virtual bool IsBroadcast(void) const
void SetBurstProfileManager(Ptr< BurstProfileManager > burstProfileManager)
an EUI-48 address
Definition: mac48-address.h:41
void SetMacAddress(Mac48Address address)
void SetChannel(Ptr< WimaxChannel > wimaxChannel)
void SetPhy(Ptr< WimaxPhy > phy)
virtual bool IsLinkUp(void) const
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
virtual bool SupportsSendFrom(void) const
Ptr< BurstProfileManager > GetBurstProfileManager(void) const
Describes an IPv6 address.
Definition: ipv6-address.h:44
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
virtual void AddLinkChangeCallback(Callback< void > callback)
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)
virtual uint16_t GetMtu(void) const
Ptr< WimaxPhy > GetPhy(void) const
virtual void SetAddress(Address address)
virtual bool IsBridge(void) const
Return true if the net device is acting as a bridge.
virtual void SetNode(Ptr< Node > node)
virtual bool NeedsArp(void) const
a unique identifier for an interface.
Definition: type-id.h:44