A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wimax-net-device.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007,2008, 2009 INRIA, UDcast
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Authors: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
7 * Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
8 */
9
10#ifndef WIMAX_NET_DEVICE_H
11#define WIMAX_NET_DEVICE_H
12
13#include "cid-factory.h"
14#include "cid.h"
15#include "dl-mac-messages.h"
16#include "mac-messages.h"
17#include "ul-mac-messages.h"
18#include "wimax-connection.h"
19#include "wimax-mac-header.h"
20#include "wimax-phy.h"
21
22#include "ns3/event-id.h"
23#include "ns3/log.h"
24#include "ns3/mac48-address.h"
25#include "ns3/net-device.h"
26#include "ns3/nstime.h"
27#include "ns3/traced-callback.h"
28
29namespace ns3
30{
31
32class Node;
33class Packet;
34class TraceContext;
35class TraceResolver;
36class Channel;
37class WimaxChannel;
38class PacketBurst;
39class BurstProfileManager;
40class ConnectionManager;
41class ServiceFlowManager;
42class BandwidthManager;
43class UplinkScheduler;
44
45/**
46 * \defgroup wimax WiMAX Models
47 * This section documents the API of the ns-3 wimax module. For a generic functional description,
48 * please refer to the ns-3 manual.
49 */
50
51/**
52 * \brief Hold together all WiMAX-related objects in a NetDevice.
53 * \ingroup wimax
54 *
55 * This class holds together ns3::WimaxPhy, ns3::WimaxConnection,
56 * ns3::ConnectionManager, ns3::BurstProfileManager, and
57 * ns3::BandwidthManager.
58 */
60{
61 public:
62 /// Direction enumeration
68
69 /// RangingStatus enumeration
77
78 /**
79 * \brief Get the type ID.
80 * \return the object TypeId
81 */
82 static TypeId GetTypeId();
84 ~WimaxNetDevice() override;
85 /**
86 * Set transmission/receive transition gap
87 * \param ttg transmit/receive transition gap
88 */
89 void SetTtg(uint16_t ttg);
90 /**
91 * Get transmission/receive transition gap
92 * \returns transmit/receive transition gap
93 */
94 uint16_t GetTtg() const;
95 /**
96 * Set receive/transmit transition gap
97 * \param rtg receive/transmit transition gap
98 */
99 void SetRtg(uint16_t rtg);
100 /**
101 * Get receive/transmit transition gap
102 * \returns receive/transmit transition gap
103 */
104 uint16_t GetRtg() const;
105 /**
106 * Attach device to channel
107 * \param channel channel to attach
108 */
109 void Attach(Ptr<WimaxChannel> channel);
110 /**
111 * Set the physical layer object
112 * \param phy the phy layer object to use
113 */
114 void SetPhy(Ptr<WimaxPhy> phy);
115 /**
116 * Get the physical layer object
117 * \returns a pointer to the physical layer object
118 */
119 Ptr<WimaxPhy> GetPhy() const;
120
121 /**
122 * Set the channel object
123 * \param wimaxChannel the channel to be used
124 */
125 void SetChannel(Ptr<WimaxChannel> wimaxChannel);
126
127 /**
128 * Get the channel object by index
129 * \param index the channel index
130 * \returns the channel being used.
131 */
132 uint64_t GetChannel(uint8_t index) const;
133
134 /**
135 * Set the number of frames
136 * \param nrFrames the number of frames
137 */
138 void SetNrFrames(uint32_t nrFrames);
139 /**
140 * Get the number of frames
141 * \returns the number of frames.
142 */
143 uint32_t GetNrFrames() const;
144 /**
145 * Set the MAC address
146 * \param address the mac address of the net device
147 */
148 void SetMacAddress(Mac48Address address);
149 /**
150 * Get the MAC address
151 * \returns the mac address of the net device
152 */
154 /**
155 * Set the device state
156 * \param state the state
157 */
158 void SetState(uint8_t state);
159 /**
160 * Get the device state
161 * \returns the state
162 */
163 uint8_t GetState() const;
164 /**
165 * Get the initial ranging connection
166 * \returns the initial ranging connection
167 */
169 /**
170 * Get the broadcast connection
171 * \returns the broadcast connection
172 */
174
175 /**
176 * Set the current DCD
177 * \param dcd the DCD
178 */
179 void SetCurrentDcd(Dcd dcd);
180 /**
181 * Get the current DCD
182 * \returns the DCD
183 */
184 Dcd GetCurrentDcd() const;
185 /**
186 * Set the current UCD
187 * \param ucd the UCD
188 */
189 void SetCurrentUcd(Ucd ucd);
190 /**
191 * Get the current UCD
192 * \returns the UCD
193 */
194 Ucd GetCurrentUcd() const;
195 /**
196 * Get the connection manager of the device
197 * \returns the connection manager of the device
198 */
200
201 /**
202 * Set the connection manager of the device
203 * \param connectionManager the connection manager to be installed in the device
204 */
205 virtual void SetConnectionManager(Ptr<ConnectionManager> connectionManager);
206
207 /**
208 * Get the burst profile manager
209 * \returns the burst profile manager currently installed in the device
210 */
212
213 /**
214 * Set the burst profile manager
215 * \param burstProfileManager the burst profile manager to be installed on the device
216 */
217 void SetBurstProfileManager(Ptr<BurstProfileManager> burstProfileManager);
218
219 /**
220 * Get the bandwidth manager on the device
221 * \returns the bandwidth manager installed on the device
222 */
224
225 /**
226 * Set the bandwidth manager on the device
227 * \param bandwidthManager the bandwidth manager to be installed on the device
228 */
229 void SetBandwidthManager(Ptr<BandwidthManager> bandwidthManager);
230
231 /**
232 * \brief Creates the initial ranging and broadcast connections
233 */
235
236 /// Start function
237 virtual void Start() = 0;
238 /// Stop function
239 virtual void Stop() = 0;
240
241 /// Set receive callback function
242 void SetReceiveCallback();
243
244 /**
245 * Forward a packet to the next layer above the device
246 * \param packet the packet
247 * \param source the source MAC address
248 * \param dest the destination MAC address
249 */
250 void ForwardUp(Ptr<Packet> packet, const Mac48Address& source, const Mac48Address& dest);
251
252 /**
253 * Enqueue a packet
254 * \param packet the packet
255 * \param hdrType the header type
256 * \param connection the wimax connection
257 * \returns true if successful
258 */
259 virtual bool Enqueue(Ptr<Packet> packet,
260 const MacHeaderType& hdrType,
261 Ptr<WimaxConnection> connection) = 0;
262 /**
263 * Forward a packet down the stack
264 * \param burst the packet burst
265 * \param modulationType the modulation type
266 */
267 void ForwardDown(Ptr<PacketBurst> burst, WimaxPhy::ModulationType modulationType);
268
269 // temp, shall be private
270 static uint8_t m_direction; ///< downlink or uplink
271
272 static Time m_frameStartTime; ///< temp, to determine the frame start time at SS side, shall
273 ///< actually be determined by frame start preamble
274
275 /**
276 * Set device name
277 * \param name the device name
278 */
279 virtual void SetName(const std::string name);
280 /**
281 * Get device name
282 * \returns the device name
283 */
284 virtual std::string GetName() const;
285 /**
286 * Set interface index
287 * \param index the index
288 */
289 void SetIfIndex(const uint32_t index) override;
290 /**
291 * Get interface index
292 * \returns the interface index
293 */
294 uint32_t GetIfIndex() const override;
295 /**
296 * Get the channel (this method is redundant with GetChannel())
297 * \returns the channel used by the phy layer
298 */
299 virtual Ptr<Channel> GetPhyChannel() const;
300 /**
301 * Get the channel
302 * \returns the channel
303 */
304 Ptr<Channel> GetChannel() const override;
305 /**
306 * Set address of the device
307 * \param address the address
308 */
309 void SetAddress(Address address) override;
310 /**
311 * Get address of the device
312 * \returns the address
313 */
314 Address GetAddress() const override;
315 /**
316 * Set MTU value for the device
317 * \param mtu the MTU
318 * \returns true if successful
319 */
320 bool SetMtu(const uint16_t mtu) override;
321 /**
322 * Get MTU of the device
323 * \returns the MTU
324 */
325 uint16_t GetMtu() const override;
326 /**
327 * Check if link is up
328 * \return true if the link is up
329 */
330 bool IsLinkUp() const override;
331 /**
332 * Set link change callback function
333 * \param callback the callback function
334 */
335 virtual void SetLinkChangeCallback(Callback<void> callback);
336 /**
337 * Check if broadcast enabled
338 * \returns true if broadcast
339 */
340 bool IsBroadcast() const override;
341 /**
342 * Get broadcast address
343 * \returns the address
344 */
345 Address GetBroadcast() const override;
346 /**
347 * Check if multicast enabled
348 * \returns true if multicast
349 */
350 bool IsMulticast() const override;
351 /**
352 * Get multicast address
353 * \returns the multicast address
354 */
355 virtual Address GetMulticast() const;
356 /**
357 * Make multicast address
358 * \param multicastGroup the IPv4 address
359 * \returns the multicast address
360 */
361 virtual Address MakeMulticastAddress(Ipv4Address multicastGroup) const;
362 /**
363 * Check if device is a point-to-point device
364 * \returns true if point to point
365 */
366 bool IsPointToPoint() const override;
367 /**
368 * Send function
369 * \param packet the packet
370 * \param dest the destination address
371 * \param protocolNumber the protocol number
372 * \returns true if successful
373 */
374 bool Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber) override;
375 /**
376 * Set node pointer
377 * \param node the node pointer
378 */
379 void SetNode(Ptr<Node> node) override;
380 /**
381 * Get node pointer
382 * \returns the node pointer
383 */
384 Ptr<Node> GetNode() const override;
385 /**
386 * Check if device needs ARP
387 * \returns true if ARP required
388 */
389 bool NeedsArp() const override;
390 /**
391 * Set receive callback function
392 * \param cb the receive callback function
393 */
395 /**
396 * Add link change callback function
397 * \param callback the link change callback function
398 */
399 void AddLinkChangeCallback(Callback<void> callback) override;
400 /**
401 * Send a packet
402 * \param packet the packet
403 * \param source the source address
404 * \param dest the destination address
405 * \param protocolNumber the protocol number
406 * \returns true if successful
407 */
408 bool SendFrom(Ptr<Packet> packet,
409 const Address& source,
410 const Address& dest,
411 uint16_t protocolNumber) override;
412 /**
413 * Set promiscuous receive callback function
414 * \param cb the promiscuous mode callback
415 */
417 /**
418 * Get promiscuous receive callback function
419 * \returns the promiscuous mode callback
420 */
422 /**
423 * Check if device supports the SendFrom method
424 * \returns true if SendFrom is supported
425 */
426 bool SupportsSendFrom() const override;
427
428 /**
429 * TracedCallback signature for packet and Mac48Address.
430 *
431 * \param [in] packet The packet.
432 * \param [in] mac The Mac48Address.
433 * \deprecated The `const Mac48Address &` argument is deprecated
434 * and will be changed to \c Mac48Address in a future release.
435 * The TracedCallback signature will then match \c Packet::Mac48Address
436 * and this typedef can be removed.
437 */
438 // NS_DEPRECATED() - tag for future removal
439 typedef void (*TxRxTracedCallback)(Ptr<const Packet> packet, const Mac48Address& mac);
440 /**
441 * \deprecated The `const Mac48Address &` argument is deprecated
442 * and will be changed to \c Mac48Address in a future release.
443 * The TracedCallback signature will then match \c Packet::Mac48Address
444 * and this typedef can be removed.
445 * \todo This member variable should be private.
446 */
447 // NS_DEPRECATED() - tag for future removal
449 /**
450 * \deprecated The `const Mac48Address &` argument is deprecated
451 * and will be changed to \c Mac48Address in a future release.
452 * The TracedCallback signature will then match \c Packet::Mac48Address
453 * and this typedef can be removed.
454 * \todo This member variable should be private.
455 */
456 // NS_DEPRECATED() - tag for future removal
458
459 void DoDispose() override;
460 Address GetMulticast(Ipv6Address addr) const override;
461 Address GetMulticast(Ipv4Address multicastGroup) const override;
462 bool IsBridge() const override;
463
464 /**
465 * Check if device is promiscuous
466 * \returns true if promiscuous
467 */
468 bool IsPromisc();
469 /**
470 * Notify promiscuous trace of a packet arrival
471 * \param p the packet
472 */
474
475 private:
476 /// copy constructor (disabled)
478 /**
479 * assignment operator (disabled)
480 * \returns the wimax net device
481 */
483
484 /// Maximum MSDU size
485 static const uint16_t MAX_MSDU_SIZE = 1500;
486 /// recommended by wimax forum.
487 static const uint16_t DEFAULT_MSDU_SIZE = 1400;
488
489 /**
490 * Send a packet
491 * \param packet the packet
492 * \param source the source MAC address
493 * \param dest the destination MAC address
494 * \param protocolNumber the protocol number
495 * \returns true if successful
496 */
497 virtual bool DoSend(Ptr<Packet> packet,
498 const Mac48Address& source,
499 const Mac48Address& dest,
500 uint16_t protocolNumber) = 0;
501 /**
502 * Receive a packet
503 * \param packet the packet received
504 */
505 virtual void DoReceive(Ptr<Packet> packet) = 0;
506 /**
507 * Get the channel
508 * \returns the wimax channel
509 */
510 virtual Ptr<WimaxChannel> DoGetChannel() const;
511 /**
512 * Receive a packet burst
513 * \param burst the packet burst
514 */
516 /// Initialize channels function
517 void InitializeChannels();
518
519 Ptr<Node> m_node; ///< the node
520 Ptr<WimaxPhy> m_phy; ///< the phy
521 NetDevice::ReceiveCallback m_forwardUp; ///< forward up callback function
522 NetDevice::PromiscReceiveCallback m_promiscRx; ///< promiscuous receive callback function
523
524 uint32_t m_ifIndex; ///< IF index
525 std::string m_name; ///< service name
526 bool m_linkUp; ///< link up?
527 Callback<void> m_linkChange; ///< link change callback
528 mutable uint16_t m_mtu; ///< MTU
529
530 /// temp, shall be in BS. defined here to allow SS to access. SS shall actually determine it
531 /// from DLFP, shall be moved to BS after DLFP is implemented
533
534 /// not sure if it shall be included here
535 std::vector<uint64_t> m_dlChannels;
536
537 Mac48Address m_address; ///< MAC address
538 uint8_t m_state; ///< state
539 uint32_t m_symbolIndex; ///< symbol index
540
541 /// length of TTG in units of PSs
542 uint16_t m_ttg;
543 /// length of RTG in units of PSs
544 uint16_t m_rtg;
545
548
549 Ptr<WimaxConnection> m_initialRangingConnection; ///< initial rnaging connection
551
555};
556
557} // namespace ns3
558
559#endif /* WIMAX_NET_DEVICE_H */
a polymophic address class
Definition address.h:90
Callback template class.
Definition callback.h:422
This class implements Downlink channel descriptor as described by "IEEE Standard forLocal and metropo...
Ipv4 addresses are stored in host order in this class.
Describes an IPv6 address.
an EUI-48 address
This class Represents the HT (Header Type) field of generic MAC and bandwidth request headers.
Network layer to device interface.
Definition net-device.h:87
Smart pointer class similar to boost::intrusive_ptr.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition type-id.h:48
This class implements the UCD message as described by "IEEE Standard forLocal and metropolitan area n...
Hold together all WiMAX-related objects in a NetDevice.
uint64_t GetChannel(uint8_t index) const
Get the channel object by index.
NetDevice::ReceiveCallback m_forwardUp
forward up callback function
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.
WimaxNetDevice & operator=(const WimaxNetDevice &)
assignment operator (disabled)
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.
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:43
Every class exported by the ns3 library is enclosed in the ns3 namespace.