A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wimax-net-device.cc
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 * <amine.ismail@UDcast.com>
9 */
10
11#include "wimax-net-device.h"
12
13#include "bandwidth-manager.h"
15#include "connection-manager.h"
16#include "send-params.h"
18#include "wimax-channel.h"
19
20#include "ns3/callback.h"
21#include "ns3/enum.h"
22#include "ns3/llc-snap-header.h"
23#include "ns3/node.h"
24#include "ns3/packet-burst.h"
25#include "ns3/packet.h"
26#include "ns3/pointer.h"
27#include "ns3/simulator.h"
28#include "ns3/trace-source-accessor.h"
29#include "ns3/uinteger.h"
30
31#include <list>
32
33namespace ns3
34{
35
36NS_LOG_COMPONENT_DEFINE("WimaxNetDevice");
37
38NS_OBJECT_ENSURE_REGISTERED(WimaxNetDevice);
39
43
44TypeId
46{
47 static TypeId tid =
48 TypeId("ns3::WimaxNetDevice")
49
51 .SetGroupName("Wimax")
52
53 // No AddConstructor because this is an abstract class.
54
55 .AddAttribute("Mtu",
56 "The MAC-level Maximum Transmission Unit",
60
61 .AddAttribute("Phy",
62 "The PHY layer attached to this device.",
66
67 .AddAttribute(
68 "Channel",
69 "The channel attached to this device.",
73
74 .AddAttribute("RTG",
75 "receive/transmit transition gap.",
79
80 .AddAttribute("TTG",
81 "transmit/receive transition gap.",
85
86 .AddAttribute("ConnectionManager",
87 "The connection manager attached to this device.",
92
93 .AddAttribute("BurstProfileManager",
94 "The burst profile manager attached to this device.",
99
100 .AddAttribute("BandwidthManager",
101 "The bandwidth manager attached to this device.",
102 PointerValue(),
106
107 .AddAttribute("InitialRangingConnection",
108 "Initial ranging connection",
109 PointerValue(),
112
113 .AddAttribute("BroadcastConnection",
114 "Broadcast connection",
115 PointerValue(),
118
119 .AddTraceSource("Rx",
120 "Receive trace",
122 "ns3::WimaxNetDevice::TxRxTracedCallback")
123
124 .AddTraceSource("Tx",
125 "Transmit trace",
127 "ns3::WimaxNetDevice::TxRxTracedCallback");
128 return tid;
129}
130
145
149
150void
152{
153 m_phy->Dispose();
154 m_phy = nullptr;
155 m_node = nullptr;
157 m_broadcastConnection = nullptr;
158 m_connectionManager = nullptr;
159 m_burstProfileManager = nullptr;
160 m_bandwidthManager = nullptr;
161
163}
164
165void
167{
168 m_ttg = ttg;
169}
170
171uint16_t
173{
174 return m_ttg;
175}
176
177void
179{
180 m_rtg = rtg;
181}
182
183uint16_t
185{
186 return m_rtg;
187}
188
189void
190WimaxNetDevice::SetName(const std::string name)
191{
192 m_name = name;
193}
194
195std::string
197{
198 return m_name;
199}
200
201void
203{
204 m_ifIndex = index;
205}
206
209{
210 return m_ifIndex;
211}
212
215{
216 return DoGetChannel();
217}
218
221{
222 return DoGetChannel();
223}
224
225bool
226WimaxNetDevice::SetMtu(const uint16_t mtu)
227{
228 if (mtu > MAX_MSDU_SIZE)
229 {
230 return false;
231 }
232 m_mtu = mtu;
233 return true;
234}
235
236uint16_t
238{
239 return m_mtu;
240}
241
242bool
244{
245 return m_phy && m_linkUp;
246}
247
248void
253
254bool
256{
257 return true;
258}
259
265
266bool
268{
269 return false;
270}
271
274{
275 return Mac48Address("01:00:5e:00:00:00");
276}
277
280{
281 return GetMulticast();
282}
283
284bool
286{
287 return false;
288}
289
290bool
291WimaxNetDevice::Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber)
292{
294 LlcSnapHeader llcHdr;
295 llcHdr.SetType(protocolNumber);
296 packet->AddHeader(llcHdr);
297
298 m_traceTx(packet, to);
299
300 return DoSend(packet, Mac48Address::ConvertFrom(GetAddress()), to, protocolNumber);
301}
302
303void
305{
306 m_node = node;
307}
308
311{
312 return m_node;
313}
314
315bool
317{
318 return false;
319 /*
320 * Modified by Mohamed Amine ISMAIL.
321 * see "Transmission of IPv4 packets over IEEE 802.16's IP Convergence
322 * Sublayer draft-ietf-16ng-ipv4-over-802-dot-16-ipcs-04.txt" section
323 * 5.2
324 */
325}
326
327void
332
333void
335{
336 m_traceRx(packet, source);
337 LlcSnapHeader llc;
338 packet->RemoveHeader(llc);
339 m_forwardUp(this, packet, llc.GetType(), source);
340}
341
342void
344{
345 m_phy->Attach(channel);
346}
347
348void
353
356{
357 return m_phy;
358}
359
360void
362{
363 if (m_phy)
364 {
365 m_phy->Attach(channel);
366 }
367}
368
369uint64_t
370WimaxNetDevice::GetChannel(uint8_t index) const
371{
372 return m_dlChannels.at(index);
373}
374
375void
377{
378 m_nrFrames = nrFrames;
379}
380
383{
384 return m_nrFrames;
385}
386
387void
392
393void
395{
396 m_address = address;
397}
398
401{
402 return m_address;
403}
404
407{
408 return m_address;
409}
410
411void
413{
414 m_state = state;
415}
416
417uint8_t
419{
420 return m_state;
421}
422
428
434
435void
440
441Dcd
443{
444 return m_currentDcd;
445}
446
447void
452
453Ucd
455{
456 return m_currentUcd;
457}
458
464
465void
470
476
477void
482
488
489void
494
495void
502
503void
505{
506 NS_LOG_DEBUG("WimaxNetDevice::Receive, station = " << GetMacAddress());
507
508 Ptr<PacketBurst> b = burst->Copy();
509 for (auto iter = b->Begin(); iter != b->End(); ++iter)
510 {
511 Ptr<Packet> packet = *iter;
512 DoReceive(packet);
513 }
514}
515
518{
519 return m_phy->GetChannel();
520}
521
522void
527
528bool
530 const Address& source,
531 const Address& dest,
532 uint16_t protocolNumber)
533{
536
537 LlcSnapHeader llcHdr;
538 llcHdr.SetType(protocolNumber);
539 packet->AddHeader(llcHdr);
540
541 m_traceTx(packet, to);
542 return DoSend(packet, from, to, protocolNumber);
543}
544
545void
550
551bool
553{
554 return !(m_promiscRx.IsNull());
555}
556
557void
559{
560 // m_promiscRx(p);
561}
562
563bool
565{
566 return false;
567}
568
569void
571{
572 SendParams* params = new OfdmSendParams(burst, modulationType, m_direction);
573 m_phy->Send(params);
574 delete params;
575}
576
577void
579{
580 // initializing vector of channels (or frequencies)
581 // Values according to WirelessMAN-OFDM RF profile for 10 MHz channelization
582 // Section 12.3.3.1 from IEEE 802.16-2004 standard
583 // profR10_3 :
584 // channels: 5000 + n ⋅ 5 MHz, ∀n ∈ { 147, 149, 151, 153, 155, 157, 159, 161, 163, 165, 167 }
585 // from a range 5GHz to 6GHz, according to Section 8.5.1.
586 uint64_t frequency = 5000;
587
588 for (uint8_t i = 0; i < 200; i++)
589 {
590 m_dlChannels.push_back(frequency);
591 frequency += 5;
592 }
593}
594
595bool
597{
599 return false;
600}
601
604{
605 NS_LOG_FUNCTION(multicastGroup);
606
607 Mac48Address ad = Mac48Address::GetMulticast(multicastGroup);
608
609 //
610 // Implicit conversion (operator Address ()) is defined for Mac48Address, so
611 // use it by just returning the EUI-48 address which is automagically converted
612 // to an Address.
613 //
614 NS_LOG_LOGIC("multicast address is " << ad);
615
616 return ad;
617}
618
621{
623
624 NS_LOG_LOGIC("MAC IPv6 multicast address is " << ad);
625 return ad;
626}
627
628void
630{
631 /* \todo Add a callback invoked whenever the link
632 * status changes to UP. This callback is typically used
633 * by the IP/ARP layer to flush the ARP cache and by IPv6 stack
634 * to flush NDISC cache whenever the link goes up.
635 */
636 NS_FATAL_ERROR("Not implemented-- please implement and contribute a patch");
637}
638} // namespace ns3
a polymophic address class
Definition address.h:90
Callback template class.
Definition callback.h:422
bool IsNull() const
Check for null implementation.
Definition callback.h:555
@ BROADCAST
Definition cid.h:31
@ INITIAL_RANGING
Definition cid.h:32
static Cid InitialRanging()
Definition cid.cc:76
static Cid Broadcast()
Definition cid.cc:64
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.
Header for the LLC/SNAP encapsulation.
uint16_t GetType()
Return the Ethertype.
void SetType(uint16_t type)
Set the Ethertype.
an EUI-48 address
static Mac48Address GetMulticast(Ipv4Address address)
static Mac48Address ConvertFrom(const Address &address)
static Mac48Address GetBroadcast()
Network layer to device interface.
Definition net-device.h:87
virtual void DoDispose()
Destructor implementation.
Definition object.cc:433
OfdmSendParams class.
Definition send-params.h:57
AttributeValue implementation for Pointer.
Smart pointer class similar to boost::intrusive_ptr.
The SendParams class defines the parameters with which Send() function of a particular PHY is called.
Definition send-params.h:31
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
This class implements the UCD message as described by "IEEE Standard forLocal and metropolitan area n...
Hold an unsigned integer type.
Definition uinteger.h:34
NetDevice::ReceiveCallback m_forwardUp
forward up callback function
Ptr< Channel > GetChannel() const override
Get the channel.
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
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
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.
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.
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
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.
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.
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.
Ptr< Node > m_node
the node
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
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition pointer.h:248
Ptr< AttributeChecker > MakePointerChecker()
Create a PointerChecker for a type.
Definition pointer.h:269
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:257
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition log.h:271
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1308
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Definition nstime.h:828
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeUintegerChecker()
Definition uinteger.h:85
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition callback.h:684
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition uinteger.h:35