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