Left: | ||
Right: |
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) 2006, 2009 INRIA | 3 * Copyright (c) 2006, 2009 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 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
400 else | 400 else |
401 { | 401 { |
402 //packet is considerated belonging to BestEffort AC | 402 //packet is considerated belonging to BestEffort AC |
403 hdr.SetQosTid (0); | 403 hdr.SetQosTid (0); |
404 m_queues[AC_BE]->Queue (packet, hdr); | 404 m_queues[AC_BE]->Queue (packet, hdr); |
405 } | 405 } |
406 } | 406 } |
407 | 407 |
408 void | 408 void |
409 QapWifiMac::ForwardDown (Ptr<const Packet> packet, Mac48Address from, Mac48Addre ss to, | 409 QapWifiMac::ForwardDown (Ptr<const Packet> packet, Mac48Address from, Mac48Addre ss to, |
410 WifiMacHeader const *oldHdr) | 410 const WifiMacHeader *oldHdr) |
411 { | 411 { |
412 /* For now Qos AP sends only Qos frame. In the future it should be able to· | 412 /* For now Qos AP sends only Qos frame. In the future it should be able to· |
413 send frames also to Non-Qos Stas. | 413 send frames also to Non-Qos Stas. |
414 */ | 414 */ |
415 NS_LOG_FUNCTION (this << packet << from << to); | 415 NS_LOG_FUNCTION (this << packet << from << to); |
416 NS_ASSERT (oldHdr->IsQosData ()); | 416 NS_ASSERT (oldHdr->IsQosData ()); |
417 WifiMacHeader hdr; | 417 WifiMacHeader hdr; |
418 hdr.SetType (WIFI_MAC_QOSDATA); | 418 hdr.SetType (WIFI_MAC_QOSDATA); |
419 hdr.SetQosAckPolicy (WifiMacHeader::NORMAL_ACK); | 419 hdr.SetQosAckPolicy (WifiMacHeader::NORMAL_ACK); |
420 hdr.SetQosNoEosp (); | 420 hdr.SetQosNoEosp (); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
543 beacon.SetSupportedRates (GetSupportedRates ()); | 543 beacon.SetSupportedRates (GetSupportedRates ()); |
544 beacon.SetBeaconIntervalUs (m_beaconInterval.GetMicroSeconds ()); | 544 beacon.SetBeaconIntervalUs (m_beaconInterval.GetMicroSeconds ()); |
545 ·· | 545 ·· |
546 packet->AddHeader (beacon); | 546 packet->AddHeader (beacon); |
547 | 547 |
548 m_beaconDca->Queue (packet, hdr); | 548 m_beaconDca->Queue (packet, hdr); |
549 m_beaconEvent = Simulator::Schedule (m_beaconInterval, &QapWifiMac::SendOneBea con, this);·· | 549 m_beaconEvent = Simulator::Schedule (m_beaconInterval, &QapWifiMac::SendOneBea con, this);·· |
550 } | 550 } |
551 | 551 |
552 void | 552 void |
553 QapWifiMac::TxOk (WifiMacHeader const &hdr) | 553 QapWifiMac::TxOk (const WifiMacHeader &hdr) |
554 { | 554 { |
555 NS_LOG_FUNCTION (this); | 555 NS_LOG_FUNCTION (this); |
556 WifiRemoteStation *station = m_stationManager->Lookup (hdr.GetAddr1 ()); | 556 WifiRemoteStation *station = m_stationManager->Lookup (hdr.GetAddr1 ()); |
557 if (hdr.IsAssocResp () &&· | 557 if (hdr.IsAssocResp () &&· |
558 station->IsWaitAssocTxOk ())· | 558 station->IsWaitAssocTxOk ())· |
559 { | 559 { |
560 NS_LOG_DEBUG ("associated with sta="<<hdr.GetAddr1 ()); | 560 NS_LOG_DEBUG ("associated with sta="<<hdr.GetAddr1 ()); |
561 station->RecordGotAssocTxOk (); | 561 station->RecordGotAssocTxOk (); |
562 } | 562 } |
563 } | 563 } |
564 | 564 |
565 void | 565 void |
566 QapWifiMac::TxFailed (WifiMacHeader const &hdr) | 566 QapWifiMac::TxFailed (const WifiMacHeader &hdr) |
567 { | 567 { |
568 NS_LOG_FUNCTION (this); | 568 NS_LOG_FUNCTION (this); |
569 WifiRemoteStation *station = m_stationManager->Lookup (hdr.GetAddr1 ()); | 569 WifiRemoteStation *station = m_stationManager->Lookup (hdr.GetAddr1 ()); |
570 if (hdr.IsAssocResp () &&· | 570 if (hdr.IsAssocResp () &&· |
571 station->IsWaitAssocTxOk ())· | 571 station->IsWaitAssocTxOk ())· |
572 { | 572 { |
573 NS_LOG_DEBUG ("assoc failed with sta="<<hdr.GetAddr1 ()); | 573 NS_LOG_DEBUG ("assoc failed with sta="<<hdr.GetAddr1 ()); |
574 station->RecordGotAssocTxFailed (); | 574 station->RecordGotAssocTxFailed (); |
575 } | 575 } |
576 } | 576 } |
577 | 577 |
578 void | 578 void |
579 QapWifiMac::Receive (Ptr<Packet> packet, WifiMacHeader const *hdr) | 579 QapWifiMac::Receive (Ptr<Packet> packet, const WifiMacHeader *hdr) |
580 { | 580 { |
581 NS_LOG_FUNCTION (this << packet << hdr); | 581 NS_LOG_FUNCTION (this << packet << hdr); |
582 | 582 |
583 Mac48Address from = hdr->GetAddr2 (); | 583 Mac48Address from = hdr->GetAddr2 (); |
584 WifiRemoteStation *fromStation = m_stationManager->Lookup (from); | 584 WifiRemoteStation *fromStation = m_stationManager->Lookup (from); |
585 ·· | 585 ·· |
586 if (hdr->IsData ()) | 586 if (hdr->IsData ()) |
587 { | 587 { |
588 Mac48Address bssid = hdr->GetAddr1 (); | 588 Mac48Address bssid = hdr->GetAddr1 (); |
589 if (!hdr->IsFromDs () &&· | 589 if (!hdr->IsFromDs () &&· |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
693 else if (hdr->IsDisassociation ())· | 693 else if (hdr->IsDisassociation ())· |
694 { | 694 { |
695 fromStation->RecordDisassociated (); | 695 fromStation->RecordDisassociated (); |
696 }· | 696 }· |
697 else if (hdr->IsReassocReq ())· | 697 else if (hdr->IsReassocReq ())· |
698 { | 698 { |
699 /* we don't support reassoc frames for now */ | 699 /* we don't support reassoc frames for now */ |
700 } | 700 } |
701 else if (hdr->IsAction ()) | 701 else if (hdr->IsAction ()) |
702 { | 702 { |
703 MgtActionFrameHeader actHdr; | 703 WifiActionHeader actionHdr; |
704 packet->PeekHeader (actHdr); | 704 packet->RemoveHeader (actionHdr); |
705 if (actHdr.IsAddBaRequest ()) | 705 if (actionHdr.GetCategory () == WifiActionHeader::BLOCK_ACK && |
706 actionHdr.GetAction().blockAck == WifiActionHeader::BLOCK_ACK_ ADDBA_REQUEST) | |
706 { | 707 { |
707 MgtAddBaRequestHeader reqHdr; | 708 MgtAddBaRequestHeader reqHdr; |
708 packet->RemoveHeader (reqHdr); | 709 packet->RemoveHeader (reqHdr); |
709 SendAddBaResponse (&reqHdr, hdr->GetAddr2 ()); | 710 SendAddBaResponse (&reqHdr, hdr->GetAddr2 ()); |
710 } | 711 } |
711 else if (actHdr.IsAddBaResponse ()) | 712 else if (actionHdr.GetCategory () == WifiActionHeader::BLOCK_ACK & & |
713 actionHdr.GetAction().blockAck == WifiActionHeader::BLOCK _ACK_ADDBA_RESPONSE) | |
712 { | 714 { |
713 MgtAddBaResponseHeader respHdr; | 715 MgtAddBaResponseHeader respHdr; |
714 packet->RemoveHeader (respHdr); | 716 packet->RemoveHeader (respHdr); |
715 m_queues[QosUtilsMapTidToAc (respHdr.GetTid ())]->GotAddBaResp onse (&respHdr, hdr->GetAddr2 ()); | 717 m_queues[QosUtilsMapTidToAc (respHdr.GetTid ())]->GotAddBaResp onse (&respHdr, hdr->GetAddr2 ()); |
716 } | 718 } |
717 else if (actHdr.IsDelBa ()) | 719 else if (actionHdr.GetCategory () == WifiActionHeader::BLOCK_ACK & & |
720 actionHdr.GetAction().blockAck == WifiActionHeader::BLOCK _ACK_DELBA) | |
718 { | 721 { |
719 MgtDelBaHeader delBaHdr; | 722 MgtDelBaHeader delBaHdr; |
720 packet->RemoveHeader (delBaHdr); | 723 packet->RemoveHeader (delBaHdr); |
721 if (delBaHdr.IsByOriginator ()) | 724 if (delBaHdr.IsByOriginator ()) |
722 { | 725 { |
723 /* Delba frame was sent by originator, this means that an ingoing established | 726 /* Delba frame was sent by originator, this means that an ingoing established |
724 agreement exists in MacLow */ | 727 agreement exists in MacLow */ |
725 m_low->DestroyBlockAckAgreement (hdr->GetAddr2 (), delBaHd r.GetTid ()); | 728 m_low->DestroyBlockAckAgreement (hdr->GetAddr2 (), delBaHd r.GetTid ()); |
726 } | 729 } |
727 else | 730 else |
(...skipping 13 matching lines...) Expand all Loading... | |
741 else· | 744 else· |
742 { | 745 { |
743 /* unknown mgt frame | 746 /* unknown mgt frame |
744 */ | 747 */ |
745 } | 748 } |
746 } | 749 } |
747 } | 750 } |
748 } | 751 } |
749 | 752 |
750 void | 753 void |
751 QapWifiMac::DeaggregateAmsduAndForward (Ptr<Packet> aggregatedPacket, WifiMacHea der const *hdr) | 754 QapWifiMac::DeaggregateAmsduAndForward (Ptr<Packet> aggregatedPacket, const Wifi MacHeader *hdr) |
752 { | 755 { |
753 DeaggregatedMsdus packets = MsduAggregator::Deaggregate (aggregatedPacket); | 756 DeaggregatedMsdus packets = MsduAggregator::Deaggregate (aggregatedPacket); |
754 for (DeaggregatedMsdusCI i = packets.begin (); i != packets.end (); ++i) | 757 for (DeaggregatedMsdusCI i = packets.begin (); i != packets.end (); ++i) |
755 { | 758 { |
756 if ((*i).second.GetDestinationAddr () == GetAddress ()) | 759 if ((*i).second.GetDestinationAddr () == GetAddress ()) |
757 { | 760 { |
758 ForwardUp ((*i).first, (*i).second.GetSourceAddr (), | 761 ForwardUp ((*i).first, (*i).second.GetSourceAddr (), |
759 (*i).second.GetDestinationAddr ()); | 762 (*i).second.GetDestinationAddr ()); |
760 } | 763 } |
761 else | 764 else |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
805 edca->SetAccessClass (ac); | 808 edca->SetAccessClass (ac); |
806 edca->CompleteConfig (); | 809 edca->CompleteConfig (); |
807 m_queues.insert (std::make_pair(ac, edca)); | 810 m_queues.insert (std::make_pair(ac, edca)); |
808 } | 811 } |
809 | 812 |
810 void· | 813 void· |
811 QapWifiMac::FinishConfigureStandard (enum WifiPhyStandard standard) | 814 QapWifiMac::FinishConfigureStandard (enum WifiPhyStandard standard) |
812 { | 815 { |
813 switch (standard) | 816 switch (standard) |
814 { | 817 { |
818 case WIFI_PHY_STANDARD_80211p_CCH: | |
819 ConfigureCCHDcf (m_queues[AC_BK], 15, 511, AC_BK); | |
820 ConfigureCCHDcf (m_queues[AC_BE], 15, 511, AC_BE); | |
821 ConfigureCCHDcf (m_queues[AC_VI], 15, 511, AC_VI); | |
822 ConfigureCCHDcf (m_queues[AC_VO], 15, 511, AC_VO); | |
823 break; | |
824 case WIFI_PHY_STANDARD_80211p_SCH: | |
825 ConfigureDcf (m_queues[AC_BK], 15, 511, AC_BK); | |
826 ConfigureDcf (m_queues[AC_BE], 15, 511, AC_BE); | |
827 ConfigureDcf (m_queues[AC_VI], 15, 511, AC_VI); | |
828 ConfigureDcf (m_queues[AC_VO], 15, 511, AC_VO); | |
829 break; | |
815 case WIFI_PHY_STANDARD_holland: | 830 case WIFI_PHY_STANDARD_holland: |
816 // fall through | 831 // fall through |
817 case WIFI_PHY_STANDARD_80211a: | 832 case WIFI_PHY_STANDARD_80211a: |
818 // fall through | 833 // fall through |
819 case WIFI_PHY_STANDARD_80211_10Mhz: | 834 case WIFI_PHY_STANDARD_80211_10Mhz: |
820 // fall through | 835 // fall through |
821 case WIFI_PHY_STANDARD_80211_5Mhz: | 836 case WIFI_PHY_STANDARD_80211_5Mhz: |
822 ConfigureDcf (m_queues[AC_BK], 15, 1023, AC_BK); | 837 ConfigureDcf (m_queues[AC_BK], 15, 1023, AC_BK); |
823 ConfigureDcf (m_queues[AC_BE], 15, 1023, AC_BE); | 838 ConfigureDcf (m_queues[AC_BE], 15, 1023, AC_BE); |
824 ConfigureDcf (m_queues[AC_VI], 15, 1023, AC_VI); | 839 ConfigureDcf (m_queues[AC_VI], 15, 1023, AC_VI); |
(...skipping 23 matching lines...) Expand all Loading... | |
848 } | 863 } |
849 | 864 |
850 void | 865 void |
851 QapWifiMac::SendAddBaResponse (const MgtAddBaRequestHeader *reqHdr, Mac48Address originator) | 866 QapWifiMac::SendAddBaResponse (const MgtAddBaRequestHeader *reqHdr, Mac48Address originator) |
852 { | 867 { |
853 NS_LOG_FUNCTION (this); | 868 NS_LOG_FUNCTION (this); |
854 WifiMacHeader hdr; | 869 WifiMacHeader hdr; |
855 hdr.SetAction (); | 870 hdr.SetAction (); |
856 hdr.SetAddr1 (originator); | 871 hdr.SetAddr1 (originator); |
857 hdr.SetAddr2 (m_low->GetAddress ()); | 872 hdr.SetAddr2 (m_low->GetAddress ()); |
858 hdr.SetAddr3 (GetBssid ()); | 873 hdr.SetAddr3 (m_low->GetAddress ()); |
859 hdr.SetDsNotFrom (); | 874 hdr.SetDsNotFrom (); |
860 hdr.SetDsNotTo (); | 875 hdr.SetDsNotTo (); |
861 | 876 |
862 MgtAddBaResponseHeader respHdr; | 877 MgtAddBaResponseHeader respHdr; |
863 StatusCode code; | 878 StatusCode code; |
864 code.SetSuccess (); | 879 code.SetSuccess (); |
865 respHdr.SetStatusCode (code); | 880 respHdr.SetStatusCode (code); |
866 //Here a control about queues type? | 881 //Here a control about queues type? |
867 respHdr.SetAmsduSupport (reqHdr->IsAmsduSupported ()); | 882 respHdr.SetAmsduSupport (reqHdr->IsAmsduSupported ()); |
868 ·· | 883 ·· |
869 if (reqHdr->IsImmediateBlockAck ()) | 884 if (reqHdr->IsImmediateBlockAck ()) |
870 { | 885 { |
871 respHdr.SetImmediateBlockAck (); | 886 respHdr.SetImmediateBlockAck (); |
872 } | 887 } |
873 else | 888 else |
874 { | 889 { |
875 respHdr.SetDelayedBlockAck (); | 890 respHdr.SetDelayedBlockAck (); |
876 } | 891 } |
877 respHdr.SetTid (reqHdr->GetTid ()); | 892 respHdr.SetTid (reqHdr->GetTid ()); |
878 /* For now there's not no control about limit of reception. | 893 /* For now there's not no control about limit of reception. |
879 We assume that receiver has no limit on reception. | 894 We assume that receiver has no limit on reception. |
880 However we assume that a receiver sets a bufferSize in order to satisfy | 895 However we assume that a receiver sets a bufferSize in order to satisfy |
881 next equation: | 896 next equation: |
Tom Henderson
2010/01/30 23:21:14
minor nit; multi-line comment misses the "*" chara
| |
882 (bufferSize + 1) % 16 = 0 | 897 (bufferSize + 1) % 16 = 0 |
883 So if a recipient is able to buffer a packet, it should be also able to buf fer | 898 So if a recipient is able to buffer a packet, it should be also able to buf fer |
884 all possible packet's fragments. | 899 all possible packet's fragments. |
885 See section 7.3.1.14 in IEEE802.11e for more details. */ | 900 See section 7.3.1.14 in IEEE802.11e for more details. */ |
886 respHdr.SetBufferSize (1023); | 901 respHdr.SetBufferSize (1023); |
887 respHdr.SetTimeout (reqHdr->GetTimeout ()); | 902 respHdr.SetTimeout (reqHdr->GetTimeout ()); |
888 | 903 |
904 WifiActionHeader actionHdr; | |
905 WifiActionHeader::ActionValue action; | |
906 action.blockAck = WifiActionHeader::BLOCK_ACK_ADDBA_RESPONSE; | |
907 actionHdr.SetAction (WifiActionHeader::BLOCK_ACK, action); | |
908 | |
889 Ptr<Packet> packet = Create<Packet> (); | 909 Ptr<Packet> packet = Create<Packet> (); |
890 packet->AddHeader (respHdr); | 910 packet->AddHeader (respHdr); |
911 packet->AddHeader (actionHdr); | |
891 ·· | 912 ·· |
892 /* ns3::MacLow have to buffer all correctly received packet for this block ack session */ | 913 /* ns3::MacLow have to buffer all correctly received packet for this block ack session */ |
893 m_low->CreateBlockAckAgreement (&respHdr, originator, reqHdr->GetStartingSeque nce ()); | 914 m_low->CreateBlockAckAgreement (&respHdr, originator, reqHdr->GetStartingSeque nce ()); |
894 | 915 |
895 //Better a management queue?· | 916 //Better a management queue?· |
Tom Henderson
2010/01/30 23:21:14
minor nit: mixed C and C++ commenting styles with
| |
896 m_queues[QosUtilsMapTidToAc (reqHdr->GetTid ())]->PushFront (packet, hdr); | 917 m_queues[QosUtilsMapTidToAc (reqHdr->GetTid ())]->PushFront (packet, hdr); |
897 } | 918 } |
898 | 919 |
899 } //namespace ns3 | 920 } //namespace ns3 |
LEFT | RIGHT |