A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ss-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  * <amine.ismail@UDcast.com>
21  */
22 
23 #ifndef WIMAX_SS_NET_DEVICE_H
24 #define WIMAX_SS_NET_DEVICE_H
25 
26 #include "ns3/event-id.h"
27 #include "wimax-net-device.h"
28 #include "ns3/nstime.h"
29 #include "wimax-mac-header.h"
30 #include "ns3/uinteger.h"
31 #include "ns3/ss-service-flow-manager.h"
32 #include "ipcs-classifier.h"
33 
34 namespace ns3 {
35 
36 class Node;
37 class OfdmDlBurstProfile;
38 class OfdmUlBurstProfile;
39 class SSScheduler;
40 class SSLinkManager;
41 class SsServiceFlowManager;
42 class IpcsClassifier;
43 
48 {
49 public:
50  enum State
51  {
52  SS_STATE_IDLE, SS_STATE_SCANNING, SS_STATE_SYNCHRONIZING, SS_STATE_ACQUIRING_PARAMETERS,
53  SS_STATE_WAITING_REG_RANG_INTRVL, // regular ranging interval
54  SS_STATE_WAITING_INV_RANG_INTRVL, // invited ranging interval
55  SS_STATE_WAITING_RNG_RSP, SS_STATE_ADJUSTING_PARAMETERS, SS_STATE_REGISTERED, SS_STATE_TRANSMITTING, // currently not being used anywhere
56  SS_STATE_STOPPED
57  };
58 
59  enum EventType
60  {
61  EVENT_NONE, EVENT_WAIT_FOR_RNG_RSP, EVENT_DL_MAP_SYNC_TIMEOUT, EVENT_LOST_DL_MAP, EVENT_LOST_UL_MAP,
62  EVENT_DCD_WAIT_TIMEOUT, EVENT_UCD_WAIT_TIMEOUT, EVENT_RANG_OPP_WAIT_TIMEOUT
63  };
64 
65  static TypeId GetTypeId (void);
69 
77  void SetLostDlMapInterval (Time lostDlMapInterval);
78  /*
79  * \returns the time since last received DL-MAP message before downlink synchronization is considered lost
80  */
81  Time GetLostDlMapInterval (void) const;
85  void SetLostUlMapInterval (Time lostUlMapInterval);
89  Time GetLostUlMapInterval (void) const;
93  void SetMaxDcdInterval (Time maxDcdInterval);
97  Time GetMaxDcdInterval (void) const;
101  void SetMaxUcdInterval (Time maxUcdInterval);
105  Time GetMaxUcdInterval (void) const;
109  void SetIntervalT1 (Time interval1);
113  Time GetIntervalT1 (void) const;
117  void SetIntervalT2 (Time interval2);
121  Time GetIntervalT2 (void) const;
125  void SetIntervalT3 (Time interval3);
129  Time GetIntervalT3 (void) const;
133  void SetIntervalT7 (Time interval7);
137  Time GetIntervalT7 (void) const;
141  void SetIntervalT12 (Time interval12);
145  Time GetIntervalT12 (void) const;
149  void SetIntervalT20 (Time interval20);
153  Time GetIntervalT20 (void) const;
157  void SetIntervalT21 (Time interval21);
161  Time GetIntervalT21 (void) const;
165  void SetMaxContentionRangingRetries (uint8_t maxContentionRangingRetries);
169  uint8_t GetMaxContentionRangingRetries (void) const;
173  void SetBasicConnection (Ptr<WimaxConnection> basicConnection);
181  void SetPrimaryConnection (Ptr<WimaxConnection> primaryConnection);
189  Cid GetBasicCid (void) const;
193  Cid GetPrimaryCid (void) const;
194 
199  void SetModulationType (WimaxPhy::ModulationType modulationType);
203  WimaxPhy::ModulationType GetModulationType (void) const;
207  void SetAreManagementConnectionsAllocated (bool areManagementConnectionsAllocated);
211  bool GetAreManagementConnectionsAllocated (void) const;
215  void SetAreServiceFlowsAllocated (bool areServiceFlowsAllocated);
219  bool GetAreServiceFlowsAllocated (void) const;
223  Ptr<SSScheduler> GetScheduler (void) const;
227  void SetScheduler (Ptr<SSScheduler> ssScheduler);
231  bool HasServiceFlows (void) const;
238  bool Enqueue (Ptr<Packet> packet, const MacHeaderType &hdrType, Ptr<WimaxConnection> connection);
242  void SendBurst (uint8_t uiuc,
243  uint16_t nrSymbols,
244  Ptr<WimaxConnection> connection,
245  MacHeaderType::HeaderType packetType = MacHeaderType::HEADER_TYPE_GENERIC);
246 
247  void Start (void);
248  void Stop (void);
249 
253  void AddServiceFlow (ServiceFlow *sf);
257  void AddServiceFlow (ServiceFlow sf);
258  void SetTimer (EventId eventId, EventId &event);
262  bool IsRegistered (void) const;
263  Time GetTimeToAllocation (Time defferTime);
264 
265  Ptr<SSLinkManager> m_linkManager;
277  Ptr<SSLinkManager> GetLinkManager (void) const;
290 
291 private:
292  static Time GetDefaultLostDlMapInterval ();
293 
294  void DoDispose (void);
295  bool DoSend (Ptr<Packet> packet, const Mac48Address &source, const Mac48Address &dest, uint16_t protocolNumber);
296  void DoReceive (Ptr<Packet> packet);
297 
298  void ProcessDlMap (const DlMap &dlmap);
299  void ProcessUlMap (const UlMap &ulmap);
300  void ProcessDcd (const Dcd &dcd);
301  void ProcessUcd (const Ucd &ucd);
302 
303  // parameters defined in Table 342
304  Time m_lostDlMapInterval; // in milliseconds, time since last received DL-MAP before downlink synchronization is considered lost, maximum is 600
305  Time m_lostUlMapInterval; // in milliseconds, time since last received UL-MAP before uplink synchronization is considered lost, maximum is 600
306  Time m_maxDcdInterval; // in seconds, maximum time between transmission of DCD messages
307  Time m_maxUcdInterval; // in seconds, maximum time between transmission of UCD messages
308  Time m_intervalT1; // in seconds, wait for DCD timeout
309  Time m_intervalT2; // in seconds, wait for broadcast ranging timeout, i.e., wait for initial ranging opportunity
310  Time m_intervalT3; // in milliseconds, ranging Response reception timeout following the transmission of a ranging request
311  Time m_intervalT7; // in seconds, wait for DSA/DSC/DSD Response timeout
312  Time m_intervalT12; // in seconds, wait for UCD descriptor
313  Time m_intervalT20; // in seconds, time the SS searches for preambles on a given channel
314  Time m_intervalT21; // in seconds, time the SS searches for (decodable) DL-MAP on a given channel
315  uint8_t m_maxContentionRangingRetries;
316 
317  // parameters obtained from DL-MAP
318  uint8_t m_dcdCount;
319  Mac48Address m_baseStationId;
320 
321  // parameters obtained from UL-MAP
322  uint8_t m_ucdCount;
323  double m_allocationStartTime;
324 
325  // to keep the number of DL-MAP/UL-MAP IEs found in the last DL-MAP/U-MAP messages
326  uint16_t m_nrDlMapElements;
327  uint16_t m_nrUlMapElements;
328 
329  Ptr<WimaxConnection> m_basicConnection;
330  Ptr<WimaxConnection> m_primaryConnection;
331 
332  EventId m_lostDlMapEvent, m_lostUlMapEvent, m_dcdWaitTimeoutEvent, m_ucdWaitTimeoutEvent, m_rangOppWaitTimeoutEvent;
333 
334  uint32_t m_nrDlMapRecvd;
335  uint32_t m_nrUlMapRecvd;
336  uint32_t m_nrDcdRecvd;
337  uint32_t m_nrUcdRecvd;
338 
339  OfdmDlBurstProfile *m_dlBurstProfile;
340  OfdmUlBurstProfile *m_ulBurstProfile;
341 
342  /*represents the (least robust) modulation type of the SS which it then requests in RNG-REQ and if accepted by BS uses it for receiving and
343  transmiting. currently it is set by user in simulation script, shall actually be determined based on SS's distance, power, signal etc*/
344  WimaxPhy::ModulationType m_modulationType;
345 
346  bool m_areManagementConnectionsAllocated;
347  bool m_areServiceFlowsAllocated;
348 
349  Ptr<SSScheduler> m_scheduler;
350  Ptr<SsServiceFlowManager> m_serviceFlowManager;
351  Ptr<IpcsClassifier> m_classifier;
352 
354  TracedCallback<Ptr<const PacketBurst>, Mac48Address, Cid*, WimaxPhy::ModulationType> m_traceSSTx;
355 
363 
371 
380 
389 
397 };
398 
399 } // namespace ns3
400 
401 #endif /* WIMAX_SS_NET_DEVICE_H */
HeaderType
this class implements the mac header type field.
void SetIntervalT3(Time interval3)
keep track of time unit.
Definition: nstime.h:149
void SetIntervalT1(Time interval1)
void SetLostDlMapInterval(Time lostDlMapInterval)
Time GetMaxUcdInterval(void) const
void SetIntervalT21(Time interval21)
void SetIntervalT2(Time interval2)
void SetModulationType(WimaxPhy::ModulationType modulationType)
Set the most efficient modulation and coding scheme (MCS) supported by the device.
forward calls to a chain of CallbackAn ns3::TracedCallback has almost exactly the same API as a norma...
bool GetAreManagementConnectionsAllocated(void) const
void SetMaxDcdInterval(Time maxDcdInterval)
void SetAreManagementConnectionsAllocated(bool areManagementConnectionsAllocated)
void SetLostUlMapInterval(Time lostUlMapInterval)
Time GetLostUlMapInterval(void) const
void SetScheduler(Ptr< SSScheduler > ssScheduler)
void SetMaxUcdInterval(Time maxUcdInterval)
Ptr< IpcsClassifier > GetIpcsClassifier() const
TracedCallback< Ptr< const Packet > > m_ssPromiscRxTrace
Ptr< SSScheduler > GetScheduler(void) const
TracedCallback< Ptr< const Packet > > m_ssRxTrace
void SetIntervalT20(Time interval20)
void SetMaxContentionRangingRetries(uint8_t maxContentionRangingRetries)
void SetIntervalT12(Time interval12)
bool Enqueue(Ptr< Packet > packet, const MacHeaderType &hdrType, Ptr< WimaxConnection > connection)
Enqueue a packet into a connection queue.
TracedCallback< Ptr< const Packet > > m_ssTxDropTrace
Ptr< SSLinkManager > GetLinkManager(void) const
TracedCallback< Ptr< const Packet > > m_ssTxTrace
void SendBurst(uint8_t uiuc, uint16_t nrSymbols, Ptr< WimaxConnection > connection, MacHeaderType::HeaderType packetType=MacHeaderType::HEADER_TYPE_GENERIC)
Sends a burst on the uplink frame.
Represents the HT (Header Type) field of generic MAC and bandwidth request headers.
TracedCallback< Ptr< const Packet > > m_ssRxDropTrace
Hold together all Wimax-related objects in a NetDevice.This class holds together ns3::WimaxPhy, ns3::WimaxConnection, ns3::ConectionManager, ns3::BurstProfileManager, and ns3::BandwidthManager.
Definition: cid.h:35
WimaxPhy::ModulationType GetModulationType(void) const
an EUI-48 address
Definition: mac48-address.h:41
void SetBasicConnection(Ptr< WimaxConnection > basicConnection)
Ptr< WimaxConnection > GetBasicConnection(void) const
void SetAreServiceFlowsAllocated(bool areServiceFlowsAllocated)
void SetLinkManager(Ptr< SSLinkManager >)
sets the link manager to be used
an identifier for simulation events.
Definition: event-id.h:46
Time GetMaxDcdInterval(void) const
void SetIntervalT7(Time interval7)
void SetServiceFlowManager(Ptr< SsServiceFlowManager >)
Sets the service flow manager to be installed on the device.
void InitSubscriberStationNetDevice(void)
initializes the net device and sets the parameters to the default values
void SetIpcsPacketClassifier(Ptr< IpcsClassifier >)
Sets the packet classifier to be used.
Ptr< SsServiceFlowManager > GetServiceFlowManager(void) const
void AddServiceFlow(ServiceFlow *sf)
adds a new service flow
a unique identifier for an interface.
Definition: type-id.h:44
void SetPrimaryConnection(Ptr< WimaxConnection > primaryConnection)
uint8_t GetMaxContentionRangingRetries(void) const
Ptr< WimaxConnection > GetPrimaryConnection(void) const
bool GetAreServiceFlowsAllocated(void) const