23 #include "ns3/llc-snap-header.h"
24 #include "ns3/simulator.h"
25 #include "ns3/callback.h"
27 #include "ns3/packet.h"
28 #include "wimax-net-device.h"
29 #include "wimax-channel.h"
30 #include "ns3/packet-burst.h"
31 #include "burst-profile-manager.h"
33 #include "send-params.h"
34 #include "ns3/uinteger.h"
35 #include "ns3/trace-source-accessor.h"
36 #include "ns3/pointer.h"
38 #include "service-flow-manager.h"
39 #include "connection-manager.h"
40 #include "bandwidth-manager.h"
46 NS_OBJECT_ENSURE_REGISTERED (WimaxNetDevice);
48 uint32_t WimaxNetDevice::m_nrFrames = 0;
49 uint8_t WimaxNetDevice::m_direction = ~0;
50 Time WimaxNetDevice::m_frameStartTime =
Seconds (0);
52 TypeId WimaxNetDevice::GetTypeId (
void)
56 TypeId (
"ns3::WimaxNetDevice")
58 .SetParent<NetDevice> ()
60 .AddAttribute (
"Mtu",
"The MAC-level Maximum Transmission Unit",
61 UintegerValue (DEFAULT_MSDU_SIZE),
64 MakeUintegerChecker<uint16_t> (0,MAX_MSDU_SIZE))
67 "The PHY layer attached to this device.",
70 MakePointerChecker<WimaxPhy> ())
72 .AddAttribute (
"Channel",
73 "The channel attached to this device.",
76 MakePointerChecker<WimaxChannel> ())
79 "receive/transmit transition gap.",
82 MakeUintegerChecker<uint16_t> (0, 120))
85 "transmit/receive transition gap.",
88 MakeUintegerChecker<uint16_t> (0, 120))
90 .AddAttribute (
"ConnectionManager",
91 "The connection manager attached to this device.",
95 MakePointerChecker<ConnectionManager> ())
97 .AddAttribute (
"BurstProfileManager",
98 "The burst profile manager attached to this device.",
102 MakePointerChecker<BurstProfileManager> ())
104 .AddAttribute (
"BandwidthManager",
105 "The bandwidth manager attached to this device.",
109 MakePointerChecker<BandwidthManager> ())
111 .AddAttribute (
"InitialRangingConnection",
112 "Initial ranging connection",
114 MakePointerAccessor (&WimaxNetDevice::m_initialRangingConnection),
115 MakePointerChecker<WimaxConnection> ())
117 .AddAttribute (
"BroadcastConnection",
118 "Broadcast connection",
120 MakePointerAccessor (&WimaxNetDevice::m_broadcastConnection),
121 MakePointerChecker<WimaxConnection> ())
129 WimaxNetDevice::WimaxNetDevice (
void)
135 InitializeChannels ();
136 m_connectionManager = CreateObject<ConnectionManager> ();
137 m_burstProfileManager = CreateObject<BurstProfileManager> (
this);
138 m_bandwidthManager = CreateObject<BandwidthManager> (
this);
141 m_frameStartTime =
Seconds (0);
144 WimaxNetDevice::~WimaxNetDevice (
void)
155 m_initialRangingConnection = 0;
156 m_broadcastConnection = 0;
157 m_connectionManager = 0;
158 m_burstProfileManager = 0;
159 m_bandwidthManager = 0;
160 m_connectionManager = 0;
161 m_bandwidthManager = 0;
192 WimaxNetDevice::SetName (
const std::string name)
198 WimaxNetDevice::GetName (
void)
const
218 return DoGetChannel ();
222 WimaxNetDevice::GetPhyChannel (
void)
const
224 return DoGetChannel ();
230 if (mtu > MAX_MSDU_SIZE)
248 return m_phy != 0 && m_linkUp;
255 m_linkChange = callback;
277 WimaxNetDevice::GetMulticast (
void)
const
283 WimaxNetDevice::MakeMulticastAddress (Ipv4Address multicastGroup)
const
285 return GetMulticast ();
300 llcHdr.SetType (protocolNumber);
303 m_traceTx (packet, to);
341 m_traceRx (packet, source);
344 m_forwardUp (
this, packet, llc.GetType (), source);
348 WimaxNetDevice::Attach (Ptr<WimaxChannel> channel)
350 m_phy->Attach (channel);
370 m_phy->Attach (channel);
378 return m_dlChannels.at (index);
382 WimaxNetDevice::SetNrFrames (uint32_t nrFrames)
384 m_nrFrames = nrFrames;
387 uint32_t WimaxNetDevice::GetNrFrames (
void)
const
418 WimaxNetDevice::SetState (uint8_t state)
424 WimaxNetDevice::GetState (
void)
const
432 return m_initialRangingConnection;
438 return m_broadcastConnection;
442 WimaxNetDevice::SetCurrentDcd (
Dcd dcd)
448 WimaxNetDevice::GetCurrentDcd (
void)
const
454 WimaxNetDevice::SetCurrentUcd (Ucd ucd)
460 WimaxNetDevice::GetCurrentUcd (
void)
const
465 Ptr<ConnectionManager>
468 return m_connectionManager;
474 m_connectionManager = cm;
480 return m_burstProfileManager;
486 m_burstProfileManager = bpm;
492 return m_bandwidthManager;
498 m_bandwidthManager = bwm;
502 WimaxNetDevice::CreateDefaultConnections (
void)
504 m_initialRangingConnection = CreateObject<WimaxConnection> (
Cid::InitialRanging (), Cid::INITIAL_RANGING);
505 m_broadcastConnection = CreateObject<WimaxConnection> (
Cid::Broadcast (), Cid::BROADCAST);
509 WimaxNetDevice::Receive (Ptr<const PacketBurst> burst)
514 Ptr<PacketBurst> b = burst->Copy ();
515 for (std::list<Ptr<Packet> >::const_iterator iter = b->Begin (); iter != b->End (); ++iter)
517 Ptr<Packet> packet = *iter;
523 WimaxNetDevice::DoGetChannel (
void)
const
525 return m_phy->GetChannel ();
529 WimaxNetDevice::SetReceiveCallback (
void)
531 m_phy->SetReceiveCallback (
MakeCallback (&WimaxNetDevice::Receive,
this));
542 llcHdr.SetType (protocolNumber);
545 m_traceTx (packet, to);
546 return DoSend (packet, from, to, protocolNumber);
556 WimaxNetDevice::IsPromisc (
void)
558 return !(m_promiscRx.IsNull ());
562 WimaxNetDevice::NotifyPromiscTrace (Ptr<Packet> p)
574 WimaxNetDevice::ForwardDown (
Ptr<PacketBurst> burst, WimaxPhy::ModulationType modulationType)
577 m_phy->Send (params);
582 WimaxNetDevice::InitializeChannels (
void)
591 uint64_t frequency = 5000;
593 for (uint8_t i = 0; i < 200; i++)
595 m_dlChannels.push_back (frequency);
641 NS_FATAL_ERROR (
"Not implemented-- please implement and contribute a patch");
uint32_t RemoveHeader(Header &header)
void SetRtg(uint16_t rtg)
smart pointer class similar to boost::intrusive_ptr
#define NS_LOG_FUNCTION(parameters)
uint16_t GetRtg(void) const
#define NS_LOG_COMPONENT_DEFINE(name)
Ptr< WimaxConnection > GetBroadcastConnection(void) const
virtual void DoDispose(void)
#define NS_LOG_FUNCTION_NOARGS()
Ptr< ConnectionManager > GetConnectionManager(void) const
#define NS_FATAL_ERROR(msg)
fatal error handling
a polymophic address class
virtual bool IsMulticast(void) const
virtual Ptr< Channel > GetChannel(void) const
virtual bool SetMtu(const uint16_t mtu)
uint16_t GetTtg(void) const
static Mac48Address GetMulticast(Ipv4Address address)
The SendParams class defines the parameters with which Send() function of a particular PHY is called...
void SetTtg(uint16_t ttg)
static Cid Broadcast(void)
static Cid InitialRanging(void)
virtual void SetIfIndex(const uint32_t index)
virtual Address GetBroadcast(void) const
static Mac48Address GetBroadcast(void)
Ptr< WimaxConnection > GetInitialRangingConnection(void) const
Ptr< BandwidthManager > GetBandwidthManager(void) const
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
virtual void SetConnectionManager(Ptr< ConnectionManager > connectionManager)
Mac48Address GetMacAddress(void) const
#define NS_LOG_LOGIC(msg)
virtual void DoDispose(void)
static Mac48Address ConvertFrom(const Address &address)
virtual uint32_t GetIfIndex(void) const
virtual Ptr< Node > GetNode(void) const
void SetBandwidthManager(Ptr< BandwidthManager > bandwidthManager)
virtual Address GetAddress(void) const
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
virtual bool IsBroadcast(void) const
void SetBurstProfileManager(Ptr< BurstProfileManager > burstProfileManager)
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.
Ipv4 addresses are stored in host order in this class.
virtual void AddLinkChangeCallback(Callback< void > callback)
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
virtual bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
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
#define NS_LOG_DEBUG(msg)
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
void AddHeader(const Header &header)