A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
regular-wifi-mac.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2008 INRIA
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
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19
*/
20
#include "
regular-wifi-mac.h
"
21
22
#include "ns3/log.h"
23
#include "ns3/boolean.h"
24
#include "ns3/pointer.h"
25
#include "ns3/uinteger.h"
26
#include "ns3/trace-source-accessor.h"
27
28
#include "
mac-rx-middle.h
"
29
#include "
mac-tx-middle.h
"
30
#include "
mac-low.h
"
31
#include "
dcf.h
"
32
#include "
dcf-manager.h
"
33
#include "
wifi-phy.h
"
34
35
#include "
msdu-aggregator.h
"
36
37
NS_LOG_COMPONENT_DEFINE
(
"RegularWifiMac"
);
38
39
namespace
ns3 {
40
41
NS_OBJECT_ENSURE_REGISTERED
(RegularWifiMac);
42
43
RegularWifiMac::RegularWifiMac
()
44
{
45
NS_LOG_FUNCTION
(
this
);
46
m_rxMiddle
=
new
MacRxMiddle
();
47
m_rxMiddle
->
SetForwardCallback
(
MakeCallback
(&
RegularWifiMac::Receive
,
this
));
48
49
m_txMiddle
=
new
MacTxMiddle
();
50
51
m_low
= CreateObject<MacLow> ();
52
m_low
->
SetRxCallback
(
MakeCallback
(&
MacRxMiddle::Receive
,
m_rxMiddle
));
53
54
m_dcfManager
=
new
DcfManager
();
55
m_dcfManager
->
SetupLowListener
(
m_low
);
56
57
m_dca
= CreateObject<DcaTxop> ();
58
m_dca
->
SetLow
(
m_low
);
59
m_dca
->
SetManager
(
m_dcfManager
);
60
m_dca
->
SetTxOkCallback
(
MakeCallback
(&
RegularWifiMac::TxOk
,
this
));
61
m_dca
->
SetTxFailedCallback
(
MakeCallback
(&
RegularWifiMac::TxFailed
,
this
));
62
63
// Construct the EDCAFs. The ordering is important - highest
64
// priority (see Table 9-1 in IEEE 802.11-2007) must be created
65
// first.
66
SetupEdcaQueue
(
AC_VO
);
67
SetupEdcaQueue
(
AC_VI
);
68
SetupEdcaQueue
(
AC_BE
);
69
SetupEdcaQueue
(
AC_BK
);
70
}
71
72
RegularWifiMac::~RegularWifiMac
()
73
{
74
NS_LOG_FUNCTION
(
this
);
75
}
76
77
void
78
RegularWifiMac::DoInitialize
()
79
{
80
NS_LOG_FUNCTION
(
this
);
81
82
m_dca
->
Initialize
();
83
84
for
(EdcaQueues::iterator i =
m_edca
.begin (); i !=
m_edca
.end (); ++i)
85
{
86
i->second->Initialize ();
87
}
88
}
89
90
void
91
RegularWifiMac::DoDispose
()
92
{
93
NS_LOG_FUNCTION
(
this
);
94
delete
m_rxMiddle
;
95
m_rxMiddle
= NULL;
96
97
delete
m_txMiddle
;
98
m_txMiddle
= NULL;
99
100
delete
m_dcfManager
;
101
m_dcfManager
= NULL;
102
103
m_low
->
Dispose
();
104
m_low
= NULL;
105
106
m_phy
= NULL;
107
m_stationManager
= NULL;
108
109
m_dca
->
Dispose
();
110
m_dca
= NULL;
111
112
for
(EdcaQueues::iterator i =
m_edca
.begin (); i !=
m_edca
.end (); ++i)
113
{
114
i->second = NULL;
115
}
116
}
117
118
void
119
RegularWifiMac::SetWifiRemoteStationManager
(
Ptr<WifiRemoteStationManager>
stationManager)
120
{
121
NS_LOG_FUNCTION
(
this
<< stationManager);
122
m_stationManager
= stationManager;
123
m_stationManager
->
SetHtSupported
(
GetHtSupported
());
124
m_low
->
SetWifiRemoteStationManager
(stationManager);
125
126
m_dca
->
SetWifiRemoteStationManager
(stationManager);
127
128
for
(EdcaQueues::iterator i =
m_edca
.begin (); i !=
m_edca
.end (); ++i)
129
{
130
i->second->SetWifiRemoteStationManager (stationManager);
131
}
132
}
133
134
Ptr<WifiRemoteStationManager>
135
RegularWifiMac::GetWifiRemoteStationManager
()
const
136
{
137
return
m_stationManager
;
138
}
139
140
void
141
RegularWifiMac::SetupEdcaQueue
(
enum
AcIndex
ac)
142
{
143
NS_LOG_FUNCTION
(
this
<< ac);
144
145
// Our caller shouldn't be attempting to setup a queue that is
146
// already configured.
147
NS_ASSERT
(
m_edca
.find (ac) ==
m_edca
.end ());
148
149
Ptr<EdcaTxopN>
edca = CreateObject<EdcaTxopN> ();
150
edca->
SetLow
(
m_low
);
151
edca->SetManager (
m_dcfManager
);
152
edca->SetTxMiddle (
m_txMiddle
);
153
edca->SetTxOkCallback (
MakeCallback
(&
RegularWifiMac::TxOk
,
this
));
154
edca->SetTxFailedCallback (
MakeCallback
(&
RegularWifiMac::TxFailed
,
this
));
155
edca->SetAccessCategory (ac);
156
edca->CompleteConfig ();
157
m_edca
.insert (std::make_pair (ac, edca));
158
}
159
160
void
161
RegularWifiMac::SetTypeOfStation
(
TypeOfStation
type)
162
{
163
NS_LOG_FUNCTION
(
this
<< type);
164
for
(EdcaQueues::iterator i =
m_edca
.begin (); i !=
m_edca
.end (); ++i)
165
{
166
i->second->SetTypeOfStation (type);
167
}
168
}
169
170
Ptr<DcaTxop>
171
RegularWifiMac::GetDcaTxop
()
const
172
{
173
return
m_dca
;
174
}
175
176
Ptr<EdcaTxopN>
177
RegularWifiMac::GetVOQueue
()
const
178
{
179
return
m_edca
.find (
AC_VO
)->second;
180
}
181
182
Ptr<EdcaTxopN>
183
RegularWifiMac::GetVIQueue
()
const
184
{
185
return
m_edca
.find (
AC_VI
)->second;
186
}
187
188
Ptr<EdcaTxopN>
189
RegularWifiMac::GetBEQueue
()
const
190
{
191
return
m_edca
.find (
AC_BE
)->second;
192
}
193
194
Ptr<EdcaTxopN>
195
RegularWifiMac::GetBKQueue
()
const
196
{
197
return
m_edca
.find (
AC_BK
)->second;
198
}
199
200
void
201
RegularWifiMac::SetWifiPhy
(
Ptr<WifiPhy>
phy)
202
{
203
NS_LOG_FUNCTION
(
this
<< phy);
204
m_phy
= phy;
205
m_dcfManager
->
SetupPhyListener
(phy);
206
m_low
->
SetPhy
(phy);
207
}
208
209
Ptr<WifiPhy>
210
RegularWifiMac::GetWifiPhy
()
const
211
{
212
return
m_phy
;
213
}
214
215
void
216
RegularWifiMac::SetForwardUpCallback
(
ForwardUpCallback
upCallback)
217
{
218
NS_LOG_FUNCTION
(
this
);
219
m_forwardUp
= upCallback;
220
}
221
222
void
223
RegularWifiMac::SetLinkUpCallback
(
Callback<void>
linkUp)
224
{
225
NS_LOG_FUNCTION
(
this
);
226
m_linkUp
= linkUp;
227
}
228
229
void
230
RegularWifiMac::SetLinkDownCallback
(
Callback<void>
linkDown)
231
{
232
NS_LOG_FUNCTION
(
this
);
233
m_linkDown
= linkDown;
234
}
235
236
void
237
RegularWifiMac::SetQosSupported
(
bool
enable)
238
{
239
NS_LOG_FUNCTION
(
this
);
240
m_qosSupported
= enable;
241
}
242
243
bool
244
RegularWifiMac::GetQosSupported
()
const
245
{
246
return
m_qosSupported
;
247
}
248
void
249
RegularWifiMac::SetHtSupported
(
bool
enable)
250
{
251
NS_LOG_FUNCTION
(
this
);
252
m_htSupported
= enable;
253
}
254
255
bool
256
RegularWifiMac::GetHtSupported
()
const
257
{
258
return
m_htSupported
;
259
}
260
void
261
RegularWifiMac::SetCtsToSelfSupported
(
bool
enable)
262
{
263
NS_LOG_FUNCTION
(
this
);
264
m_low
->
SetCtsToSelfSupported
(enable);
265
}
266
267
bool
268
RegularWifiMac::GetCtsToSelfSupported
()
const
269
{
270
return
m_low
->
GetCtsToSelfSupported
();
271
}
272
273
void
274
RegularWifiMac::SetSlot
(
Time
slotTime)
275
{
276
NS_LOG_FUNCTION
(
this
<< slotTime);
277
m_dcfManager
->
SetSlot
(slotTime);
278
m_low
->
SetSlotTime
(slotTime);
279
}
280
281
Time
282
RegularWifiMac::GetSlot
(
void
)
const
283
{
284
return
m_low
->
GetSlotTime
();
285
}
286
287
void
288
RegularWifiMac::SetSifs
(
Time
sifs)
289
{
290
NS_LOG_FUNCTION
(
this
<< sifs);
291
m_dcfManager
->
SetSifs
(sifs);
292
m_low
->
SetSifs
(sifs);
293
}
294
295
Time
296
RegularWifiMac::GetSifs
(
void
)
const
297
{
298
return
m_low
->
GetSifs
();
299
}
300
301
void
302
RegularWifiMac::SetEifsNoDifs
(
Time
eifsNoDifs)
303
{
304
NS_LOG_FUNCTION
(
this
<< eifsNoDifs);
305
m_dcfManager
->
SetEifsNoDifs
(eifsNoDifs);
306
}
307
308
Time
309
RegularWifiMac::GetEifsNoDifs
(
void
)
const
310
{
311
return
m_dcfManager
->
GetEifsNoDifs
();
312
}
313
void
314
RegularWifiMac::SetRifs
(
Time
rifs)
315
{
316
NS_LOG_FUNCTION
(
this
<< rifs);
317
m_low
->
SetRifs
(rifs);
318
}
319
320
Time
321
RegularWifiMac::GetRifs
(
void
)
const
322
{
323
return
m_low
->
GetRifs
();
324
}
325
326
void
327
RegularWifiMac::SetPifs
(
Time
pifs)
328
{
329
NS_LOG_FUNCTION
(
this
<< pifs);
330
m_low
->
SetPifs
(pifs);
331
}
332
333
Time
334
RegularWifiMac::GetPifs
(
void
)
const
335
{
336
return
m_low
->
GetPifs
();
337
}
338
339
void
340
RegularWifiMac::SetAckTimeout
(
Time
ackTimeout)
341
{
342
NS_LOG_FUNCTION
(
this
<< ackTimeout);
343
m_low
->
SetAckTimeout
(ackTimeout);
344
}
345
346
Time
347
RegularWifiMac::GetAckTimeout
(
void
)
const
348
{
349
return
m_low
->
GetAckTimeout
();
350
}
351
352
void
353
RegularWifiMac::SetCtsTimeout
(
Time
ctsTimeout)
354
{
355
NS_LOG_FUNCTION
(
this
<< ctsTimeout);
356
m_low
->
SetCtsTimeout
(ctsTimeout);
357
}
358
359
Time
360
RegularWifiMac::GetCtsTimeout
(
void
)
const
361
{
362
return
m_low
->
GetCtsTimeout
();
363
}
364
365
void
366
RegularWifiMac::SetBasicBlockAckTimeout
(
Time
blockAckTimeout)
367
{
368
NS_LOG_FUNCTION
(
this
<< blockAckTimeout);
369
m_low
->
SetBasicBlockAckTimeout
(blockAckTimeout);
370
}
371
372
Time
373
RegularWifiMac::GetBasicBlockAckTimeout
(
void
)
const
374
{
375
return
m_low
->
GetBasicBlockAckTimeout
();
376
}
377
378
void
379
RegularWifiMac::SetCompressedBlockAckTimeout
(
Time
blockAckTimeout)
380
{
381
NS_LOG_FUNCTION
(
this
<< blockAckTimeout);
382
m_low
->
SetCompressedBlockAckTimeout
(blockAckTimeout);
383
}
384
385
Time
386
RegularWifiMac::GetCompressedBlockAckTimeout
(
void
)
const
387
{
388
return
m_low
->
GetCompressedBlockAckTimeout
();
389
}
390
391
void
392
RegularWifiMac::SetAddress
(
Mac48Address
address
)
393
{
394
NS_LOG_FUNCTION
(
this
<< address);
395
m_low
->
SetAddress
(address);
396
}
397
398
Mac48Address
399
RegularWifiMac::GetAddress
(
void
)
const
400
{
401
return
m_low
->
GetAddress
();
402
}
403
404
void
405
RegularWifiMac::SetSsid
(
Ssid
ssid)
406
{
407
NS_LOG_FUNCTION
(
this
<< ssid);
408
m_ssid
= ssid;
409
}
410
411
Ssid
412
RegularWifiMac::GetSsid
(
void
)
const
413
{
414
return
m_ssid
;
415
}
416
417
void
418
RegularWifiMac::SetBssid
(
Mac48Address
bssid)
419
{
420
NS_LOG_FUNCTION
(
this
<< bssid);
421
m_low
->
SetBssid
(bssid);
422
}
423
424
Mac48Address
425
RegularWifiMac::GetBssid
(
void
)
const
426
{
427
return
m_low
->
GetBssid
();
428
}
429
430
void
431
RegularWifiMac::SetPromisc
(
void
)
432
{
433
m_low
->
SetPromisc
();
434
}
435
436
void
437
RegularWifiMac::Enqueue
(
Ptr<const Packet>
packet,
438
Mac48Address
to,
Mac48Address
from)
439
{
440
// We expect RegularWifiMac subclasses which do support forwarding (e.g.,
441
// AP) to override this method. Therefore, we throw a fatal error if
442
// someone tries to invoke this method on a class which has not done
443
// this.
444
NS_FATAL_ERROR
(
"This MAC entity ("
<<
this
<<
", "
<<
GetAddress
()
445
<<
") does not support Enqueue() with from address"
);
446
}
447
448
bool
449
RegularWifiMac::SupportsSendFrom
(
void
)
const
450
{
451
return
false
;
452
}
453
454
void
455
RegularWifiMac::ForwardUp
(
Ptr<Packet>
packet,
Mac48Address
from,
Mac48Address
to)
456
{
457
NS_LOG_FUNCTION
(
this
<< packet << from);
458
m_forwardUp
(packet, from, to);
459
}
460
461
void
462
RegularWifiMac::Receive
(
Ptr<Packet>
packet,
const
WifiMacHeader
*hdr)
463
{
464
NS_LOG_FUNCTION
(
this
<< packet << hdr);
465
466
Mac48Address
to = hdr->
GetAddr1
();
467
Mac48Address
from = hdr->
GetAddr2
();
468
469
// We don't know how to deal with any frame that is not addressed to
470
// us (and odds are there is nothing sensible we could do anyway),
471
// so we ignore such frames.
472
//
473
// The derived class may also do some such filtering, but it doesn't
474
// hurt to have it here too as a backstop.
475
if
(to !=
GetAddress
())
476
{
477
return
;
478
}
479
480
if
(hdr->
IsMgt
() && hdr->
IsAction
())
481
{
482
// There is currently only any reason for Management Action
483
// frames to be flying about if we are a QoS STA.
484
NS_ASSERT
(
m_qosSupported
);
485
486
WifiActionHeader
actionHdr;
487
packet->
RemoveHeader
(actionHdr);
488
489
switch
(actionHdr.
GetCategory
())
490
{
491
case
WifiActionHeader::BLOCK_ACK
:
492
493
switch
(actionHdr.
GetAction
().
blockAck
)
494
{
495
case
WifiActionHeader::BLOCK_ACK_ADDBA_REQUEST
:
496
{
497
MgtAddBaRequestHeader
reqHdr;
498
packet->
RemoveHeader
(reqHdr);
499
500
// We've received an ADDBA Request. Our policy here is
501
// to automatically accept it, so we get the ADDBA
502
// Response on it's way immediately.
503
SendAddBaResponse
(&reqHdr, from);
504
// This frame is now completely dealt with, so we're done.
505
return
;
506
}
507
508
case
WifiActionHeader::BLOCK_ACK_ADDBA_RESPONSE
:
509
{
510
MgtAddBaResponseHeader
respHdr;
511
packet->
RemoveHeader
(respHdr);
512
513
// We've received an ADDBA Response. We assume that it
514
// indicates success after an ADDBA Request we have
515
// sent (we could, in principle, check this, but it
516
// seems a waste given the level of the current model)
517
// and act by locally establishing the agreement on
518
// the appropriate queue.
519
AcIndex
ac =
QosUtilsMapTidToAc
(respHdr.
GetTid
());
520
m_edca
[ac]->GotAddBaResponse (&respHdr, from);
521
// This frame is now completely dealt with, so we're done.
522
return
;
523
}
524
525
case
WifiActionHeader::BLOCK_ACK_DELBA
:
526
{
527
MgtDelBaHeader
delBaHdr;
528
packet->
RemoveHeader
(delBaHdr);
529
530
if
(delBaHdr.
IsByOriginator
())
531
{
532
// This DELBA frame was sent by the originator, so
533
// this means that an ingoing established
534
// agreement exists in MacLow and we need to
535
// destroy it.
536
m_low
->
DestroyBlockAckAgreement
(from, delBaHdr.
GetTid
());
537
}
538
else
539
{
540
// We must have been the originator. We need to
541
// tell the correct queue that the agreement has
542
// been torn down
543
AcIndex
ac =
QosUtilsMapTidToAc
(delBaHdr.
GetTid
());
544
m_edca
[ac]->GotDelBaFrame (&delBaHdr, from);
545
}
546
// This frame is now completely dealt with, so we're done.
547
return
;
548
}
549
550
default
:
551
NS_FATAL_ERROR
(
"Unsupported Action field in Block Ack Action frame"
);
552
return
;
553
}
554
555
556
default
:
557
NS_FATAL_ERROR
(
"Unsupported Action frame received"
);
558
return
;
559
}
560
}
561
NS_FATAL_ERROR
(
"Don't know how to handle frame (type="
<< hdr->
GetType
());
562
}
563
564
void
565
RegularWifiMac::DeaggregateAmsduAndForward
(
Ptr<Packet>
aggregatedPacket,
566
const
WifiMacHeader
*hdr)
567
{
568
MsduAggregator::DeaggregatedMsdus
packets =
569
MsduAggregator::Deaggregate
(aggregatedPacket);
570
571
for
(
MsduAggregator::DeaggregatedMsdusCI
i = packets.begin ();
572
i != packets.end (); ++i)
573
{
574
ForwardUp
((*i).first, (*i).second.GetSourceAddr (),
575
(*i).second.GetDestinationAddr ());
576
}
577
}
578
579
void
580
RegularWifiMac::SendAddBaResponse
(
const
MgtAddBaRequestHeader
*reqHdr,
581
Mac48Address
originator)
582
{
583
NS_LOG_FUNCTION
(
this
);
584
WifiMacHeader
hdr;
585
hdr.
SetAction
();
586
hdr.
SetAddr1
(originator);
587
hdr.
SetAddr2
(
GetAddress
());
588
hdr.
SetAddr3
(
GetAddress
());
589
hdr.
SetDsNotFrom
();
590
hdr.
SetDsNotTo
();
591
592
MgtAddBaResponseHeader
respHdr;
593
StatusCode
code;
594
code.
SetSuccess
();
595
respHdr.
SetStatusCode
(code);
596
//Here a control about queues type?
597
respHdr.
SetAmsduSupport
(reqHdr->
IsAmsduSupported
());
598
599
if
(reqHdr->
IsImmediateBlockAck
())
600
{
601
respHdr.
SetImmediateBlockAck
();
602
}
603
else
604
{
605
respHdr.
SetDelayedBlockAck
();
606
}
607
respHdr.
SetTid
(reqHdr->
GetTid
());
608
// For now there's not no control about limit of reception. We
609
// assume that receiver has no limit on reception. However we assume
610
// that a receiver sets a bufferSize in order to satisfy next
611
// equation: (bufferSize + 1) % 16 = 0 So if a recipient is able to
612
// buffer a packet, it should be also able to buffer all possible
613
// packet's fragments. See section 7.3.1.14 in IEEE802.11e for more
614
// details.
615
respHdr.
SetBufferSize
(1023);
616
respHdr.
SetTimeout
(reqHdr->
GetTimeout
());
617
618
WifiActionHeader
actionHdr;
619
WifiActionHeader::ActionValue
action;
620
action.
blockAck
=
WifiActionHeader::BLOCK_ACK_ADDBA_RESPONSE
;
621
actionHdr.
SetAction
(
WifiActionHeader::BLOCK_ACK
, action);
622
623
Ptr<Packet>
packet = Create<Packet> ();
624
packet->
AddHeader
(respHdr);
625
packet->
AddHeader
(actionHdr);
626
627
// We need to notify our MacLow object as it will have to buffer all
628
// correctly received packets for this Block Ack session
629
m_low
->
CreateBlockAckAgreement
(&respHdr, originator,
630
reqHdr->
GetStartingSequence
());
631
632
// It is unclear which queue this frame should go into. For now we
633
// bung it into the queue corresponding to the TID for which we are
634
// establishing an agreement, and push it to the head.
635
m_edca
[
QosUtilsMapTidToAc
(reqHdr->
GetTid
())]->PushFront (packet, hdr);
636
}
637
638
TypeId
639
RegularWifiMac::GetTypeId
(
void
)
640
{
641
static
TypeId
tid =
TypeId
(
"ns3::RegularWifiMac"
)
642
.
SetParent
<
WifiMac
> ()
643
.AddAttribute (
"QosSupported"
,
644
"This Boolean attribute is set to enable 802.11e/WMM-style QoS support at this STA"
,
645
BooleanValue
(
false
),
646
MakeBooleanAccessor (&
RegularWifiMac::SetQosSupported
,
647
&
RegularWifiMac::GetQosSupported
),
648
MakeBooleanChecker ())
649
.AddAttribute (
"HtSupported"
,
650
"This Boolean attribute is set to enable 802.11n support at this STA"
,
651
BooleanValue
(
false
),
652
MakeBooleanAccessor (&
RegularWifiMac::SetHtSupported
,
653
&
RegularWifiMac::GetHtSupported
),
654
MakeBooleanChecker ())
655
.AddAttribute (
"CtsToSelfSupported"
,
656
"Use CTS to Self when using a rate that is not in the basic set rate"
,
657
BooleanValue
(
false
),
658
MakeBooleanAccessor (&
RegularWifiMac::SetCtsToSelfSupported
,
659
&
RegularWifiMac::GetCtsToSelfSupported
),
660
MakeBooleanChecker ())
661
.AddAttribute (
"DcaTxop"
,
"The DcaTxop object"
,
662
PointerValue
(),
663
MakePointerAccessor (&
RegularWifiMac::GetDcaTxop
),
664
MakePointerChecker<DcaTxop> ())
665
.AddAttribute (
"VO_EdcaTxopN"
,
666
"Queue that manages packets belonging to AC_VO access class"
,
667
PointerValue
(),
668
MakePointerAccessor (&
RegularWifiMac::GetVOQueue
),
669
MakePointerChecker<EdcaTxopN> ())
670
.AddAttribute (
"VI_EdcaTxopN"
,
671
"Queue that manages packets belonging to AC_VI access class"
,
672
PointerValue
(),
673
MakePointerAccessor (&
RegularWifiMac::GetVIQueue
),
674
MakePointerChecker<EdcaTxopN> ())
675
.AddAttribute (
"BE_EdcaTxopN"
,
676
"Queue that manages packets belonging to AC_BE access class"
,
677
PointerValue
(),
678
MakePointerAccessor (&
RegularWifiMac::GetBEQueue
),
679
MakePointerChecker<EdcaTxopN> ())
680
.AddAttribute (
"BK_EdcaTxopN"
,
681
"Queue that manages packets belonging to AC_BK access class"
,
682
PointerValue
(),
683
MakePointerAccessor (&
RegularWifiMac::GetBKQueue
),
684
MakePointerChecker<EdcaTxopN> ())
685
.AddTraceSource (
"TxOkHeader"
,
686
"The header of successfully transmitted packet"
,
687
MakeTraceSourceAccessor
(&
RegularWifiMac::m_txOkCallback
))
688
.AddTraceSource (
"TxErrHeader"
,
689
"The header of unsuccessfully transmitted packet"
,
690
MakeTraceSourceAccessor
(&
RegularWifiMac::m_txErrCallback
))
691
;
692
693
return
tid;
694
}
695
696
void
697
RegularWifiMac::FinishConfigureStandard
(
enum
WifiPhyStandard
standard)
698
{
699
uint32_t cwmin;
700
uint32_t cwmax;
701
702
switch
(standard)
703
{
704
case
WIFI_PHY_STANDARD_80211p_CCH
:
705
case
WIFI_PHY_STANDARD_80211p_SCH
:
706
cwmin = 15;
707
cwmax = 511;
708
break
;
709
710
case
WIFI_PHY_STANDARD_holland
:
711
case
WIFI_PHY_STANDARD_80211a
:
712
case
WIFI_PHY_STANDARD_80211g
:
713
case
WIFI_PHY_STANDARD_80211_10MHZ
:
714
case
WIFI_PHY_STANDARD_80211_5MHZ
:
715
case
WIFI_PHY_STANDARD_80211n_5GHZ
:
716
case
WIFI_PHY_STANDARD_80211n_2_4GHZ
:
717
cwmin = 15;
718
cwmax = 1023;
719
break
;
720
721
case
WIFI_PHY_STANDARD_80211b
:
722
cwmin = 31;
723
cwmax = 1023;
724
break
;
725
726
default
:
727
NS_FATAL_ERROR
(
"Unsupported WifiPhyStandard in RegularWifiMac::FinishConfigureStandard ()"
);
728
}
729
730
// The special value of AC_BE_NQOS which exists in the Access
731
// Category enumeration allows us to configure plain old DCF.
732
ConfigureDcf
(
m_dca
, cwmin, cwmax,
AC_BE_NQOS
);
733
734
// Now we configure the EDCA functions
735
for
(EdcaQueues::iterator i =
m_edca
.begin (); i !=
m_edca
.end (); ++i)
736
{
737
// Special configuration for 802.11p CCH
738
if
(standard ==
WIFI_PHY_STANDARD_80211p_CCH
)
739
{
740
ConfigureCCHDcf
(i->second, cwmin, cwmax, i->first);
741
}
742
else
743
{
744
ConfigureDcf
(i->second, cwmin, cwmax, i->first);
745
}
746
}
747
}
748
749
void
750
RegularWifiMac::TxOk
(
const
WifiMacHeader
&hdr)
751
{
752
NS_LOG_FUNCTION
(
this
<< hdr);
753
m_txOkCallback
(hdr);
754
}
755
756
void
757
RegularWifiMac::TxFailed
(
const
WifiMacHeader
&hdr)
758
{
759
NS_LOG_FUNCTION
(
this
<< hdr);
760
m_txErrCallback
(hdr);
761
}
762
763
}
// namespace ns3
src
wifi
model
regular-wifi-mac.cc
Generated on Fri Aug 30 2013 01:43:05 for ns-3 by
1.8.1.2