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 * |
5 * |
5 * 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 |
6 * 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 |
7 * published by the Free Software Foundation; |
8 * published by the Free Software Foundation; |
8 * |
9 * |
14 * You should have received a copy of the GNU General Public License |
15 * 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 * 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 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 * |
18 * |
18 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
19 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
|
20 * Author: Mirko Banchi <mk.banchi@gmail.com> |
19 */ |
21 */ |
20 #ifndef MAC_LOW_H |
22 #ifndef MAC_LOW_H |
21 #define MAC_LOW_H |
23 #define MAC_LOW_H |
22 |
24 |
23 #include <vector> |
25 #include <vector> |
24 #include <stdint.h> |
26 #include <stdint.h> |
25 #include <ostream> |
27 #include <ostream> |
|
28 #include <map> |
26 |
29 |
27 #include "wifi-mac-header.h" |
30 #include "wifi-mac-header.h" |
28 #include "wifi-mode.h" |
31 #include "wifi-mode.h" |
29 #include "wifi-preamble.h" |
32 #include "wifi-preamble.h" |
30 #include "wifi-remote-station-manager.h" |
33 #include "wifi-remote-station-manager.h" |
31 #include "ctrl-headers.h" |
34 #include "ctrl-headers.h" |
|
35 #include "mgt-headers.h" |
|
36 #include "block-ack-agreement.h" |
32 #include "ns3/mac48-address.h" |
37 #include "ns3/mac48-address.h" |
33 #include "ns3/callback.h" |
38 #include "ns3/callback.h" |
34 #include "ns3/event-id.h" |
39 #include "ns3/event-id.h" |
35 #include "ns3/packet.h" |
40 #include "ns3/packet.h" |
36 #include "ns3/nstime.h" |
41 #include "ns3/nstime.h" |
409 * This method is typically invoked by the PhyMacLowListener to notify |
414 * This method is typically invoked by the PhyMacLowListener to notify |
410 * the MAC layer that a channel switching occured. When a channel switching |
415 * the MAC layer that a channel switching occured. When a channel switching |
411 * occurs, pending MAC transmissions (RTS, CTS, DATA and ACK) are cancelled. |
416 * occurs, pending MAC transmissions (RTS, CTS, DATA and ACK) are cancelled. |
412 */ |
417 */ |
413 void NotifySwitchingStartNow (Time duration); |
418 void NotifySwitchingStartNow (Time duration); |
|
419 /** |
|
420 * \param respHdr Add block ack response from originator (action frame). |
|
421 * \param originator Address of peer station involved in block ack mechanism. |
|
422 * \param startingSeq Sequence number of the first MPDU of all packets for which block ack was negotiated. |
|
423 * |
|
424 * This function is typically invoked only by ns3::QapWifiMac and ns3::QstaWifiMac. |
|
425 * If we are transmitting an Add block ack response, MacLow must allocate buffers to collect |
|
426 * all correctly received packets belonging to category for which block ack was negotiated. |
|
427 * It's needed in order to send a Block ack after corresponding originator's Block ack request. |
|
428 */ |
|
429 void CreateBlockAckAgreement (const MgtAddBaResponseHeader *respHdr, Mac48Address originator, |
|
430 uint16_t startingSeq); |
|
431 /** |
|
432 * \param originator Address of peer partecipating in Block Ack mechanism. |
|
433 * \param tid TID for which Block Ack was created. |
|
434 * |
|
435 * Checks if exists an established block ack agreement with <i>originator</i> |
|
436 * for tid <i>tid</i>. If the agreement exists, tears down it. This function is typically |
|
437 * invoked when a DELBA frame is received from <i>originator</i>. |
|
438 */ |
|
439 void DestroyBlockAckAgreement (Mac48Address originator, uint8_t tid); |
414 private: |
440 private: |
415 void CancelAllEvents (void); |
441 void CancelAllEvents (void); |
416 uint32_t GetAckSize (void) const; |
442 uint32_t GetAckSize (void) const; |
417 uint32_t GetRtsSize (void) const; |
443 uint32_t GetRtsSize (void) const; |
418 uint32_t GetCtsSize (void) const; |
444 uint32_t GetCtsSize (void) const; |
454 void SendRtsForPacket (void); |
480 void SendRtsForPacket (void); |
455 void SendDataPacket (void); |
481 void SendDataPacket (void); |
456 void SendCurrentTxPacket (void); |
482 void SendCurrentTxPacket (void); |
457 void StartDataTxTimers (void); |
483 void StartDataTxTimers (void); |
458 virtual void DoDispose (void); |
484 virtual void DoDispose (void); |
|
485 /** |
|
486 * \param originator Address of peer partecipating in Block Ack mechanism. |
|
487 * \param tid TID for which Block Ack was created. |
|
488 * \param seq Starting sequence |
|
489 * |
|
490 * This function forward up all completed "old" packets with sequence number |
|
491 * smaller than <i>seq</i>. All comparison are performed circularly mod 4096. |
|
492 */ |
|
493 void RxCompleteBufferedPacketsWithSmallerSequence (uint16_t seq, Mac48Address originator, uint8_t tid); |
|
494 /** |
|
495 * \param originator Address of peer partecipating in Block Ack mechanism. |
|
496 * \param tid TID for which Block Ack was created. |
|
497 * |
|
498 * This method is typically invoked when a MPDU with ack policy |
|
499 * subfield set to Normal Ack is received and a block ack agreement |
|
500 * for that packet exists. |
|
501 * This happens when the originator of block ack has only few MPDUs to send. |
|
502 * All completed MSDUs starting with starting sequence number of block ack |
|
503 * agreement are forward up to WifiMac until there is an incomplete MSDU. |
|
504 * See section 9.10.4 in IEEE802.11 standard for more details. |
|
505 */ |
|
506 void RxCompleteBufferedPackets (Mac48Address originator, uint8_t tid); |
|
507 /* |
|
508 * This method checks if exists a valid established block ack agreement. |
|
509 * If there is, store the packet without pass it up to WifiMac. The packet is buffered |
|
510 * in order of increasing sequence control field. All comparison are performed |
|
511 * circularly modulo 2^12. |
|
512 */ |
|
513 bool StoreMpduIfNeeded (Ptr<Packet> packet, WifiMacHeader hdr); |
459 |
514 |
460 void SetupPhyMacLowListener (Ptr<WifiPhy> phy); |
515 void SetupPhyMacLowListener (Ptr<WifiPhy> phy); |
461 |
516 |
462 Ptr<WifiPhy> m_phy; |
517 Ptr<WifiPhy> m_phy; |
463 Ptr<WifiRemoteStationManager> m_stationManager; |
518 Ptr<WifiRemoteStationManager> m_stationManager; |
492 Time m_lastNavStart; |
547 Time m_lastNavStart; |
493 Time m_lastNavDuration; |
548 Time m_lastNavDuration; |
494 |
549 |
495 // Listerner needed to monitor when a channel switching occurs. |
550 // Listerner needed to monitor when a channel switching occurs. |
496 class PhyMacLowListener *m_phyMacLowListener; |
551 class PhyMacLowListener *m_phyMacLowListener; |
|
552 |
|
553 /* |
|
554 * BlockAck data structures. |
|
555 */ |
|
556 typedef std::pair<Ptr<Packet>, WifiMacHeader> BufferedPacket; |
|
557 typedef std::list<BufferedPacket>::iterator BufferedPacketI; |
|
558 |
|
559 typedef std::pair<Mac48Address, uint8_t> AgreementKey; |
|
560 typedef std::pair<BlockAckAgreement, std::list<BufferedPacket> > AgreementValue; |
|
561 |
|
562 typedef std::map<AgreementKey, AgreementValue> Agreements; |
|
563 typedef std::map<AgreementKey, AgreementValue>::iterator AgreementsI; |
|
564 |
|
565 Agreements m_bAckAgreements; |
497 }; |
566 }; |
498 |
567 |
499 } // namespace ns3 |
568 } // namespace ns3 |
500 |
569 |
501 #endif /* MAC_LOW_H */ |
570 #endif /* MAC_LOW_H */ |