LEFT | RIGHT |
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2005, 2006 INRIA | 3 * Copyright (c) 2005, 2006 INRIA |
4 * Copyright (c) 2009 MIRKO BANCHI | 4 * Copyright (c) 2009 MIRKO BANCHI |
5 * | 5 * |
6 * This program is free software; you can redistribute it and/or modify | 6 * This program is free software; you can redistribute it and/or modify |
7 * it under the terms of the GNU General Public License version 2 as· | 7 * it under the terms of the GNU General Public License version 2 as· |
8 * published by the Free Software Foundation; | 8 * published by the Free Software Foundation; |
9 * | 9 * |
10 * This program is distributed in the hope that it will be useful, | 10 * This program is distributed in the hope that it will be useful, |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 * and contains information about the correct reception· | 92 * and contains information about the correct reception· |
93 * of a set of packet for which a normal ack wasn't send. | 93 * of a set of packet for which a normal ack wasn't send. |
94 * Default implementation for this method is empty. Every | 94 * Default implementation for this method is empty. Every |
95 * queue that intends to be notified by MacLow of reception | 95 * queue that intends to be notified by MacLow of reception |
96 * of a block ack must redefine this function. | 96 * of a block ack must redefine this function. |
97 */ | 97 */ |
98 virtual void GotBlockAck (const CtrlBAckResponseHeader *blockAck, Mac48Address
source); | 98 virtual void GotBlockAck (const CtrlBAckResponseHeader *blockAck, Mac48Address
source); |
99 /** | 99 /** |
100 * ns3::MacLow did not receive an expected BLOCK_ACK within | 100 * ns3::MacLow did not receive an expected BLOCK_ACK within |
101 * BlockAckTimeout. This method is used only for immediate· | 101 * BlockAckTimeout. This method is used only for immediate· |
102 * block ack variant. | 102 * block ack variant. With delayed block ack, the MissedAck method will be |
| 103 * called instead: upon receipt of a block ack request, the rx station will |
| 104 * reply with a normal ack frame. Later, when the rx station gets a txop, it |
| 105 * will send the block ack back to the tx station which will reply with a |
| 106 * normal ack to the rx station. |
103 */ | 107 */ |
104 virtual void MissedBlockAck (void); | 108 virtual void MissedBlockAck (void); |
105 /** | 109 /** |
106 * Invoked when ns3::MacLow wants to start a new transmission | 110 * Invoked when ns3::MacLow wants to start a new transmission |
107 * as configured by MacLowTransmissionParameters::EnableNextData. | 111 * as configured by MacLowTransmissionParameters::EnableNextData. |
108 * The listener is expected to call again MacLow::StartTransmission | 112 * The listener is expected to call again MacLow::StartTransmission |
109 * with the "next" data to send. | 113 * with the "next" data to send. |
110 */ | 114 */ |
111 virtual void StartNext (void) = 0; | 115 virtual void StartNext (void) = 0; |
112 | 116 |
(...skipping 26 matching lines...) Expand all Loading... |
139 * \param duration duration of NAV timer | 143 * \param duration duration of NAV timer |
140 */ | 144 */ |
141 virtual void NavReset (Time duration) = 0; | 145 virtual void NavReset (Time duration) = 0; |
142 virtual void AckTimeoutStart (Time duration) = 0; | 146 virtual void AckTimeoutStart (Time duration) = 0; |
143 virtual void AckTimeoutReset () = 0; | 147 virtual void AckTimeoutReset () = 0; |
144 virtual void CtsTimeoutStart (Time duration) = 0; | 148 virtual void CtsTimeoutStart (Time duration) = 0; |
145 virtual void CtsTimeoutReset () = 0; | 149 virtual void CtsTimeoutReset () = 0; |
146 }; | 150 }; |
147 | 151 |
148 /** | 152 /** |
149 * \brief listen for block ack events | 153 * \brief listen for block ack events. |
150 */ | 154 */ |
151 class MacLowBlockAckEventListener { | 155 class MacLowBlockAckEventListener { |
152 public: | 156 public: |
153 MacLowBlockAckEventListener (); | 157 MacLowBlockAckEventListener (); |
154 virtual ~MacLowBlockAckEventListener (); | 158 virtual ~MacLowBlockAckEventListener (); |
155 /** | 159 /** |
| 160 * Typically is called in order to notify EdcaTxopN that a block ack inactivit
y |
| 161 * timeout occurs for the block ack agreement identified by the pair <i>origin
ator</i>, <i>tid</i>. |
| 162 *· |
| 163 * Rx station maintains an inactivity timer for each block ack |
| 164 * agreement. Timer is reset when a frame with ack policy block ack |
| 165 * or a block ack request are received. When this timer reaches zero |
| 166 * this method is called and a delba frame is scheduled for transmission. |
156 */ | 167 */ |
157 virtual void BlockAckInactivityTimeout (Mac48Address originator, uint8_t tid)
= 0; | 168 virtual void BlockAckInactivityTimeout (Mac48Address originator, uint8_t tid)
= 0; |
158 }; | 169 }; |
159 | 170 |
160 /** | 171 /** |
161 * \brief control how a packet is transmitted. | 172 * \brief control how a packet is transmitted. |
162 * | 173 * |
163 * The ns3::MacLow::StartTransmission method expects | 174 * The ns3::MacLow::StartTransmission method expects |
164 * an instance of this class to describe how the packet | 175 * an instance of this class to describe how the packet |
165 * should be transmitted. | 176 * should be transmitted. |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 }; | 352 }; |
342 | 353 |
343 std::ostream &operator << (std::ostream &os, const MacLowTransmissionParameters
¶ms); | 354 std::ostream &operator << (std::ostream &os, const MacLowTransmissionParameters
¶ms); |
344 | 355 |
345 | 356 |
346 /** | 357 /** |
347 * \brief handle RTS/CTS/DATA/ACK transactions. | 358 * \brief handle RTS/CTS/DATA/ACK transactions. |
348 */ | 359 */ |
349 class MacLow : public Object { | 360 class MacLow : public Object { |
350 public: | 361 public: |
351 typedef Callback<void, Ptr<Packet> , WifiMacHeader const*> MacLowRxCallback; | 362 typedef Callback<void, Ptr<Packet>, const WifiMacHeader*> MacLowRxCallback; |
352 | 363 |
353 MacLow (); | 364 MacLow (); |
354 virtual ~MacLow (); | 365 virtual ~MacLow (); |
355 | 366 |
356 void SetPhy (Ptr<WifiPhy> phy); | 367 void SetPhy (Ptr<WifiPhy> phy); |
357 void SetWifiRemoteStationManager (Ptr<WifiRemoteStationManager> manager); | 368 void SetWifiRemoteStationManager (Ptr<WifiRemoteStationManager> manager); |
358 | 369 |
359 void SetAddress (Mac48Address ad); | 370 void SetAddress (Mac48Address ad); |
360 void SetAckTimeout (Time ackTimeout); | 371 void SetAckTimeout (Time ackTimeout); |
361 void SetBasicBlockAckTimeout (Time blockAckTimeout); | 372 void SetBasicBlockAckTimeout (Time blockAckTimeout); |
(...skipping 28 matching lines...) Expand all Loading... |
390 | 401 |
391 /** | 402 /** |
392 * \param packet to send (does not include the 802.11 MAC header and checksum) | 403 * \param packet to send (does not include the 802.11 MAC header and checksum) |
393 * \param hdr header associated to the packet to send. | 404 * \param hdr header associated to the packet to send. |
394 * \param parameters transmission parameters of packet. | 405 * \param parameters transmission parameters of packet. |
395 * | 406 * |
396 * This transmission time includes the time required for | 407 * This transmission time includes the time required for |
397 * the next packet transmission if one was selected. | 408 * the next packet transmission if one was selected. |
398 */ | 409 */ |
399 Time CalculateTransmissionTime (Ptr<const Packet> packet, | 410 Time CalculateTransmissionTime (Ptr<const Packet> packet, |
400 WifiMacHeader const*hdr,· | 411 const WifiMacHeader* hdr,· |
401 MacLowTransmissionParameters const¶meters)
const; | 412 const MacLowTransmissionParameters& parameters
) const; |
402 | 413 |
403 /** | 414 /** |
404 * \param packet packet to send | 415 * \param packet packet to send |
405 * \param hdr 802.11 header for packet to send | 416 * \param hdr 802.11 header for packet to send |
406 * \param parameters the transmission parameters to use for this packet. | 417 * \param parameters the transmission parameters to use for this packet. |
407 * \param listener listen to transmission events. | 418 * \param listener listen to transmission events. |
408 * | 419 * |
409 * Start the transmission of the input packet and notify the listener | 420 * Start the transmission of the input packet and notify the listener |
410 * of transmission events. | 421 * of transmission events. |
411 */ | 422 */ |
412 void StartTransmission (Ptr<const Packet> packet,· | 423 void StartTransmission (Ptr<const Packet> packet,· |
413 WifiMacHeader const*hdr,· | 424 const WifiMacHeader* hdr,· |
414 MacLowTransmissionParameters parameters, | 425 MacLowTransmissionParameters parameters, |
415 MacLowTransmissionListener *listener); | 426 MacLowTransmissionListener *listener); |
416 | 427 |
417 /** | 428 /** |
418 * \param packet packet received | 429 * \param packet packet received |
419 * \param rxSnr snr of packet received | 430 * \param rxSnr snr of packet received |
420 * \param txMode transmission mode of packet received | 431 * \param txMode transmission mode of packet received |
421 * \param preamble type of preamble used for the packet received | 432 * \param preamble type of preamble used for the packet received |
422 * | 433 * |
423 * This method is typically invoked by the lower PHY layer to notify | 434 * This method is typically invoked by the lower PHY layer to notify |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 /** | 466 /** |
456 * \param originator Address of peer partecipating in Block Ack mechanism. | 467 * \param originator Address of peer partecipating in Block Ack mechanism. |
457 * \param tid TID for which Block Ack was created. | 468 * \param tid TID for which Block Ack was created. |
458 * | 469 * |
459 * Checks if exists an established block ack agreement with <i>originator</i> | 470 * Checks if exists an established block ack agreement with <i>originator</i> |
460 * for tid <i>tid</i>. If the agreement exists, tears down it. This function i
s typically | 471 * for tid <i>tid</i>. If the agreement exists, tears down it. This function i
s typically |
461 * invoked when a DELBA frame is received from <i>originator</i>. | 472 * invoked when a DELBA frame is received from <i>originator</i>. |
462 */ | 473 */ |
463 void DestroyBlockAckAgreement (Mac48Address originator, uint8_t tid); | 474 void DestroyBlockAckAgreement (Mac48Address originator, uint8_t tid); |
464 /** | 475 /** |
465 * \param originator Address of peer partecipating in Block Ack mechanism. | |
466 * \param tid TID for which Block Ack was created. | |
467 * \param seq Starting sequence | |
468 * | |
469 * This function forward up all completed "old" packets with sequence number | |
470 * smaller than <i>seq</i>. All comparison are performed circularly mod 4096. | |
471 */ | |
472 void RxCompleteBufferedPacketsWithSmallerSequence (uint16_t seq, Mac48Address
originator, uint8_t tid); | |
473 /** | |
474 * \param originator Address of peer partecipating in Block Ack mechanism. | |
475 * \param tid TID for which Block Ack was created. | |
476 * | |
477 * This method is typically invoked when a MPDU with ack policy | |
478 * subfield set to Normal Ack is received and a block ack agreement | |
479 * for that packet exists. | |
480 * This happens when the originator of block ack has only few MPDUs to send. | |
481 * All completed MSDUs starting with starting sequence number of block ack | |
482 * agreement are forward up to WifiMac until there is an incomplete MSDU. | |
483 * See section 9.10.4 in IEEE802.11 standard for more details. | |
484 */ | |
485 void RxCompleteBufferedPackets (Mac48Address originator, uint8_t tid); | |
486 /** | |
487 * \param ac Access class managed by the queue. | 476 * \param ac Access class managed by the queue. |
488 * \param listener The listener for the queue. | 477 * \param listener The listener for the queue. |
| 478 * |
| 479 * The lifetime of the registered listener is typically equal to the lifetime
of the queue |
| 480 * associated to this AC. |
489 */ | 481 */ |
490 void RegisterBlockAckListenerForAc (enum AccessClass ac, MacLowBlockAckEventLi
stener *listener); | 482 void RegisterBlockAckListenerForAc (enum AccessClass ac, MacLowBlockAckEventLi
stener *listener); |
491 private: | 483 private: |
492 void CancelAllEvents (void); | 484 void CancelAllEvents (void); |
493 uint32_t GetAckSize (void) const; | 485 uint32_t GetAckSize (void) const; |
494 uint32_t GetBlockAckSize (enum BlockAckType type) const; | 486 uint32_t GetBlockAckSize (enum BlockAckType type) const; |
495 uint32_t GetRtsSize (void) const; | 487 uint32_t GetRtsSize (void) const; |
496 uint32_t GetCtsSize (void) const; | 488 uint32_t GetCtsSize (void) const; |
497 uint32_t GetSize (Ptr<const Packet> packet, const WifiMacHeader *hdr) const; | 489 uint32_t GetSize (Ptr<const Packet> packet, const WifiMacHeader *hdr) const; |
498 Time NowUs (void) const; | 490 Time NowUs (void) const; |
499 WifiRemoteStation *GetStation (Mac48Address to) const; | 491 WifiRemoteStation *GetStation (Mac48Address to) const; |
500 void ForwardDown (Ptr<const Packet> packet, WifiMacHeader const *hdr,· | 492 void ForwardDown (Ptr<const Packet> packet, const WifiMacHeader *hdr,· |
501 WifiMode txMode); | 493 WifiMode txMode); |
502 Time CalculateOverallTxTime (Ptr<const Packet> packet, | 494 Time CalculateOverallTxTime (Ptr<const Packet> packet, |
503 WifiMacHeader const*hdr,· | 495 const WifiMacHeader* hdr,· |
504 MacLowTransmissionParameters const ¶ms) const
; | 496 const MacLowTransmissionParameters ¶ms) const
; |
505 WifiMode GetRtsTxMode (Ptr<const Packet> packet, const WifiMacHeader *hdr) con
st; | 497 WifiMode GetRtsTxMode (Ptr<const Packet> packet, const WifiMacHeader *hdr) con
st; |
506 WifiMode GetDataTxMode (Ptr<const Packet> packet, const WifiMacHeader *hdr) co
nst; | 498 WifiMode GetDataTxMode (Ptr<const Packet> packet, const WifiMacHeader *hdr) co
nst; |
507 WifiMode GetCtsTxModeForRts (Mac48Address to, WifiMode rtsTxMode) const; | 499 WifiMode GetCtsTxModeForRts (Mac48Address to, WifiMode rtsTxMode) const; |
508 WifiMode GetAckTxModeForData (Mac48Address to, WifiMode dataTxMode) const; | 500 WifiMode GetAckTxModeForData (Mac48Address to, WifiMode dataTxMode) const; |
509 | 501 |
510 Time GetCtsDuration (Mac48Address to, WifiMode rtsTxMode) const; | 502 Time GetCtsDuration (Mac48Address to, WifiMode rtsTxMode) const; |
511 Time GetAckDuration (Mac48Address to, WifiMode dataTxMode) const; | 503 Time GetAckDuration (Mac48Address to, WifiMode dataTxMode) const; |
512 Time GetBlockAckDuration (Mac48Address to, WifiMode blockAckReqTxMode, enum Bl
ockAckType type) const; | 504 Time GetBlockAckDuration (Mac48Address to, WifiMode blockAckReqTxMode, enum Bl
ockAckType type) const; |
513 void NotifyNav (const WifiMacHeader &hdr, WifiMode txMode, WifiPreamble preamb
le); | 505 void NotifyNav (const WifiMacHeader &hdr, WifiMode txMode, WifiPreamble preamb
le); |
514 void DoNavResetNow (Time duration); | 506 void DoNavResetNow (Time duration); |
(...skipping 15 matching lines...) Expand all Loading... |
530 void SendCtsAfterRts (Mac48Address source, Time duration, WifiMode txMode, dou
ble rtsSnr); | 522 void SendCtsAfterRts (Mac48Address source, Time duration, WifiMode txMode, dou
ble rtsSnr); |
531 void SendAckAfterData (Mac48Address source, Time duration, WifiMode txMode, do
uble rtsSnr); | 523 void SendAckAfterData (Mac48Address source, Time duration, WifiMode txMode, do
uble rtsSnr); |
532 void SendDataAfterCts (Mac48Address source, Time duration, WifiMode txMode); | 524 void SendDataAfterCts (Mac48Address source, Time duration, WifiMode txMode); |
533 void WaitSifsAfterEndTx (void); | 525 void WaitSifsAfterEndTx (void); |
534 | 526 |
535 void SendRtsForPacket (void); | 527 void SendRtsForPacket (void); |
536 void SendDataPacket (void); | 528 void SendDataPacket (void); |
537 void SendCurrentTxPacket (void); | 529 void SendCurrentTxPacket (void); |
538 void StartDataTxTimers (void); | 530 void StartDataTxTimers (void); |
539 virtual void DoDispose (void); | 531 virtual void DoDispose (void); |
| 532 /** |
| 533 * \param originator Address of peer partecipating in Block Ack mechanism. |
| 534 * \param tid TID for which Block Ack was created. |
| 535 * \param seq Starting sequence |
| 536 * |
| 537 * This function forward up all completed "old" packets with sequence number |
| 538 * smaller than <i>seq</i>. All comparison are performed circularly mod 4096. |
| 539 */ |
| 540 void RxCompleteBufferedPacketsWithSmallerSequence (uint16_t seq, Mac48Address
originator, uint8_t tid); |
| 541 /** |
| 542 * \param originator Address of peer partecipating in Block Ack mechanism. |
| 543 * \param tid TID for which Block Ack was created. |
| 544 * |
| 545 * This method is typically invoked when a MPDU with ack policy |
| 546 * subfield set to Normal Ack is received and a block ack agreement |
| 547 * for that packet exists. |
| 548 * This happens when the originator of block ack has only few MPDUs to send. |
| 549 * All completed MSDUs starting with starting sequence number of block ack |
| 550 * agreement are forward up to WifiMac until there is an incomplete MSDU. |
| 551 * See section 9.10.4 in IEEE802.11 standard for more details. |
| 552 */ |
| 553 void RxCompleteBufferedPackets (Mac48Address originator, uint8_t tid); |
540 /*· | 554 /*· |
541 * This method checks if exists a valid established block ack agreement.· | 555 * This method checks if exists a valid established block ack agreement.· |
542 * If there is, store the packet without pass it up to WifiMac. The packet is
buffered | 556 * If there is, store the packet without pass it up to WifiMac. The packet is
buffered |
543 * in order of increasing sequence control field. All comparison are performed | 557 * in order of increasing sequence control field. All comparison are performed |
544 * circularly modulo 2^12. | 558 * circularly modulo 2^12. |
545 */ | 559 */ |
546 bool StoreMpduIfNeeded (Ptr<Packet> packet, WifiMacHeader hdr); | 560 bool StoreMpduIfNeeded (Ptr<Packet> packet, WifiMacHeader hdr); |
547 /* | 561 /* |
548 * Invoked after that a block ack request has been received. Looks for corresp
onding | 562 * Invoked after that a block ack request has been received. Looks for corresp
onding |
549 * block ack agreement and creates block ack bitmap on a received packets basi
s. | 563 * block ack agreement and creates block ack bitmap on a received packets basi
s. |
550 */ | 564 */ |
551 void SendBlockAckAfterBlockAckRequest (const CtrlBAckRequestHeader reqHdr, Mac
48Address originator, | 565 void SendBlockAckAfterBlockAckRequest (const CtrlBAckRequestHeader reqHdr, Mac
48Address originator, |
552 Time duration, WifiMode txMode); | 566 Time duration, WifiMode blockAckReqTxMo
de); |
553 /* | 567 /* |
554 * This method creates block ack frame with header equals to <i>blockAck</i> a
nd start its transmission. | 568 * This method creates block ack frame with header equals to <i>blockAck</i> a
nd start its transmission. |
555 */ | 569 */ |
556 void SendBlockAckResponse (const CtrlBAckResponseHeader* blockAck, Mac48Addres
s originator, bool immediate, | 570 void SendBlockAckResponse (const CtrlBAckResponseHeader* blockAck, Mac48Addres
s originator, bool immediate, |
557 Time duration, WifiMode txMode); | 571 Time duration, WifiMode blockAckReqTxMode); |
558 /* | 572 /* |
559 * Every time that a block ack request or a packet with ack policy equals to <
i>block ack</i> | 573 * Every time that a block ack request or a packet with ack policy equals to <
i>block ack</i> |
560 * are received, if a relative block ack agreement exists and the value of ina
ctivity timeout | 574 * are received, if a relative block ack agreement exists and the value of ina
ctivity timeout |
561 * is not 0, the timer is reset. | 575 * is not 0, the timer is reset. |
562 * see section 11.5.3 in IEEE802.11e for more details. | 576 * see section 11.5.3 in IEEE802.11e for more details. |
563 */ | 577 */ |
564 void ResetBlockAckInactivityTimerIfNeeded (BlockAckAgreement &agreement); | 578 void ResetBlockAckInactivityTimerIfNeeded (BlockAckAgreement &agreement); |
565 | 579 |
566 void SetupPhyMacLowListener (Ptr<WifiPhy> phy);· | 580 void SetupPhyMacLowListener (Ptr<WifiPhy> phy);· |
567 | 581 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 | 632 |
619 Agreements m_bAckAgreements; | 633 Agreements m_bAckAgreements; |
620 ·· | 634 ·· |
621 typedef std::map<AccessClass, MacLowBlockAckEventListener*> QueueListeners; | 635 typedef std::map<AccessClass, MacLowBlockAckEventListener*> QueueListeners; |
622 QueueListeners m_edcaListeners; | 636 QueueListeners m_edcaListeners; |
623 }; | 637 }; |
624 | 638 |
625 } // namespace ns3 | 639 } // namespace ns3 |
626 | 640 |
627 #endif /* MAC_LOW_H */ | 641 #endif /* MAC_LOW_H */ |
LEFT | RIGHT |