|
|
| 368 |
m_listener (0), |
368 |
m_listener (0), |
| 369 |
m_phyMacLowListener (0), |
369 |
m_phyMacLowListener (0), |
| 370 |
m_ctsToSelfSupported (false), |
370 |
m_ctsToSelfSupported (false), |
| 371 |
m_receivedAtLeastOneMpdu (false), |
|
|
| 372 |
m_nTxMpdus (0) |
371 |
m_nTxMpdus (0) |
| 373 |
{ |
372 |
{ |
| 374 |
NS_LOG_FUNCTION (this); |
373 |
NS_LOG_FUNCTION (this); |
|
|
| 534 |
MacLow::ResetPhy (void) |
533 |
MacLow::ResetPhy (void) |
| 535 |
{ |
534 |
{ |
| 536 |
m_phy->SetReceiveOkCallback (MakeNullCallback<void, Ptr<Packet>, double, WifiTxVector, enum WifiPreamble> ()); |
535 |
m_phy->SetReceiveOkCallback (MakeNullCallback<void, Ptr<Packet>, double, WifiTxVector, enum WifiPreamble> ()); |
| 537 |
m_phy->SetReceiveErrorCallback (MakeNullCallback<void, Ptr<Packet>, double, bool> ()); |
536 |
m_phy->SetReceiveErrorCallback (MakeNullCallback<void, Ptr<Packet>, double> ()); |
| 538 |
RemovePhyMacLowListener (m_phy); |
537 |
RemovePhyMacLowListener (m_phy); |
| 539 |
m_phy = 0; |
538 |
m_phy = 0; |
| 540 |
} |
539 |
} |
|
|
| 779 |
{ |
778 |
{ |
| 780 |
AmpduTag ampdu; |
779 |
AmpduTag ampdu; |
| 781 |
m_currentPacket->PeekPacketTag (ampdu); |
780 |
m_currentPacket->PeekPacketTag (ampdu); |
| 782 |
if (ampdu.GetNoOfMpdus () > 1) |
781 |
if (ampdu.GetRemainingNbOfMpdus () > 0) |
| 783 |
{ |
782 |
{ |
| 784 |
m_txParams.EnableCompressedBlockAck (); |
783 |
m_txParams.EnableCompressedBlockAck (); |
| 785 |
} |
784 |
} |
|
|
| 839 |
} |
838 |
} |
| 840 |
|
839 |
|
| 841 |
void |
840 |
void |
| 842 |
MacLow::ReceiveError (Ptr<Packet> packet, double rxSnr, bool isEndOfFrame) |
841 |
MacLow::ReceiveError (Ptr<Packet> packet, double rxSnr) |
| 843 |
{ |
842 |
{ |
| 844 |
NS_LOG_FUNCTION (this << packet << rxSnr << isEndOfFrame); |
843 |
NS_LOG_FUNCTION (this << packet << rxSnr); |
| 845 |
NS_LOG_DEBUG ("rx failed "); |
844 |
NS_LOG_DEBUG ("rx failed "); |
| 846 |
if (isEndOfFrame == true && m_receivedAtLeastOneMpdu == true) |
|
|
| 847 |
{ |
| 848 |
WifiMacHeader hdr; |
| 849 |
AmpduTag ampdu; |
| 850 |
if (packet->RemovePacketTag (ampdu)) |
| 851 |
{ |
| 852 |
MpduAggregator::DeaggregatedMpdus mpdu = MpduAggregator::Deaggregate (packet); |
| 853 |
mpdu.begin ()->first->PeekHeader (hdr); |
| 854 |
} |
| 855 |
else |
| 856 |
{ |
| 857 |
packet->PeekHeader (hdr); |
| 858 |
} |
| 859 |
if (hdr.GetAddr1 () != m_self) |
| 860 |
{ |
| 861 |
NS_LOG_DEBUG ("hdr addr1 " << hdr.GetAddr1 () << "not for me (" << m_self << "); returning"); |
| 862 |
return; |
| 863 |
} |
| 864 |
NS_ASSERT (m_lastReceivedHdr.IsQosData ()); |
| 865 |
NS_LOG_DEBUG ("last a-mpdu subframe detected/sendImmediateBlockAck from=" << m_lastReceivedHdr.GetAddr2 ()); |
| 866 |
m_sendAckEvent = Simulator::Schedule (GetSifs (), |
| 867 |
&MacLow::SendBlockAckAfterAmpdu, this, |
| 868 |
m_lastReceivedHdr.GetQosTid (), |
| 869 |
m_lastReceivedHdr.GetAddr2 (), |
| 870 |
m_lastReceivedHdr.GetDuration (), |
| 871 |
m_currentTxVector, |
| 872 |
rxSnr); |
| 873 |
m_receivedAtLeastOneMpdu = false; |
| 874 |
} |
| 875 |
if (m_txParams.MustWaitFastAck ()) |
845 |
if (m_txParams.MustWaitFastAck ()) |
| 876 |
{ |
846 |
{ |
| 877 |
NS_ASSERT (m_fastAckFailedTimeoutEvent.IsExpired ()); |
847 |
NS_ASSERT (m_fastAckFailedTimeoutEvent.IsExpired ()); |
|
|
| 1064 |
NS_ASSERT (i != m_bAckCaches.end ()); |
1034 |
NS_ASSERT (i != m_bAckCaches.end ()); |
| 1065 |
(*i).second.UpdateWithBlockAckReq (blockAckReq.GetStartingSequence ()); |
1035 |
(*i).second.UpdateWithBlockAckReq (blockAckReq.GetStartingSequence ()); |
| 1066 |
|
1036 |
|
| 1067 |
NS_ASSERT (m_sendAckEvent.IsExpired ()); |
1037 |
//NS_ASSERT (m_sendAckEvent.IsExpired ()); |
|
|
1038 |
m_sendAckEvent.Cancel (); |
| 1068 |
/* See section 11.5.3 in IEEE 802.11 for mean of this timer */ |
1039 |
/* See section 11.5.3 in IEEE 802.11 for mean of this timer */ |
| 1069 |
ResetBlockAckInactivityTimerIfNeeded (it->second.first); |
1040 |
ResetBlockAckInactivityTimerIfNeeded (it->second.first); |
| 1070 |
if ((*it).second.first.IsImmediateBlockAck ()) |
1041 |
if ((*it).second.first.IsImmediateBlockAck ()) |
|
|
| 1082 |
{ |
1053 |
{ |
| 1083 |
NS_FATAL_ERROR ("Delayed block ack not supported."); |
1054 |
NS_FATAL_ERROR ("Delayed block ack not supported."); |
| 1084 |
} |
1055 |
} |
| 1085 |
m_receivedAtLeastOneMpdu = false; |
|
|
| 1086 |
} |
1056 |
} |
| 1087 |
else |
1057 |
else |
| 1088 |
{ |
1058 |
{ |
|
|
| 1097 |
else if (hdr.IsCtl ()) |
1067 |
else if (hdr.IsCtl ()) |
| 1098 |
{ |
1068 |
{ |
| 1099 |
NS_LOG_DEBUG ("rx drop " << hdr.GetTypeString ()); |
1069 |
NS_LOG_DEBUG ("rx drop " << hdr.GetTypeString ()); |
| 1100 |
m_receivedAtLeastOneMpdu = false; |
|
|
| 1101 |
} |
1070 |
} |
| 1102 |
else if (hdr.GetAddr1 () == m_self) |
1071 |
else if (hdr.GetAddr1 () == m_self) |
| 1103 |
{ |
1072 |
{ |
|
|
| 1125 |
hdr.GetDuration (), |
1094 |
hdr.GetDuration (), |
| 1126 |
txVector.GetMode (), |
1095 |
txVector.GetMode (), |
| 1127 |
rxSnr); |
1096 |
rxSnr); |
| 1128 |
m_receivedAtLeastOneMpdu = false; |
|
|
| 1129 |
} |
1097 |
} |
| 1130 |
else if (hdr.IsQosBlockAck ()) |
1098 |
else if (hdr.IsQosBlockAck ()) |
| 1131 |
{ |
1099 |
{ |
|
|
| 1176 |
hdr.GetDuration (), |
1144 |
hdr.GetDuration (), |
| 1177 |
txVector.GetMode (), |
1145 |
txVector.GetMode (), |
| 1178 |
rxSnr); |
1146 |
rxSnr); |
| 1179 |
m_receivedAtLeastOneMpdu = false; |
|
|
| 1180 |
} |
1147 |
} |
| 1181 |
} |
1148 |
} |
| 1182 |
goto rxPacket; |
1149 |
goto rxPacket; |
|
|
| 1192 |
if (hdr.IsData () || hdr.IsMgt ()) |
1159 |
if (hdr.IsData () || hdr.IsMgt ()) |
| 1193 |
{ |
1160 |
{ |
| 1194 |
NS_LOG_DEBUG ("rx group from=" << hdr.GetAddr2 ()); |
1161 |
NS_LOG_DEBUG ("rx group from=" << hdr.GetAddr2 ()); |
| 1195 |
m_receivedAtLeastOneMpdu = false; |
|
|
| 1196 |
goto rxPacket; |
1162 |
goto rxPacket; |
| 1197 |
} |
1163 |
} |
| 1198 |
else |
1164 |
else |
|
|
| 1677 |
AmpduTag ampdutag; |
1643 |
AmpduTag ampdutag; |
| 1678 |
ampdutag.SetAmpdu (true); |
1644 |
ampdutag.SetAmpdu (true); |
| 1679 |
Time delay = Seconds (0); |
1645 |
Time delay = Seconds (0); |
|
|
1646 |
Time remainingAmpduDuration = m_phy->CalculateTxDuration (packet->GetSize (), txVector, preamble, m_phy->GetFrequency ()); |
| 1680 |
if (queueSize > 1 || vhtSingleMpdu) |
1647 |
if (queueSize > 1 || vhtSingleMpdu) |
| 1681 |
{ |
1648 |
{ |
| 1682 |
txVector.SetAggregation (true); |
1649 |
txVector.SetAggregation (true); |
|
|
| 1695 |
} |
1662 |
} |
| 1696 |
|
1663 |
|
| 1697 |
listenerIt->second->GetMpduAggregator ()->AddHeaderAndPad (newPacket, last, vhtSingleMpdu); |
1664 |
listenerIt->second->GetMpduAggregator ()->AddHeaderAndPad (newPacket, last, vhtSingleMpdu); |
| 1698 |
|
1665 |
|
| 1699 |
ampdutag.SetNoOfMpdus (queueSize); |
|
|
| 1700 |
newPacket->AddPacketTag (ampdutag); |
| 1701 |
|
| 1702 |
if (delay == Seconds (0)) |
1666 |
if (delay == Seconds (0)) |
| 1703 |
{ |
1667 |
{ |
| 1704 |
if (!vhtSingleMpdu) |
1668 |
if (!vhtSingleMpdu) |
|
|
| 1710 |
{ |
1674 |
{ |
| 1711 |
mpdutype = NORMAL_MPDU; |
1675 |
mpdutype = NORMAL_MPDU; |
| 1712 |
} |
1676 |
} |
|
|
1677 |
} |
| 1678 |
|
| 1679 |
Time mpduDuration = m_phy->CalculateTxDuration (newPacket->GetSize (), txVector, preamble, m_phy->GetFrequency (), mpdutype, 0); |
| 1680 |
remainingAmpduDuration -= mpduDuration; |
| 1681 |
|
| 1682 |
ampdutag.SetRemainingNbOfMpdus (queueSize - 1); |
| 1683 |
ampdutag.SetRemainingAmpduDuration (remainingAmpduDuration); |
| 1684 |
newPacket->AddPacketTag (ampdutag); |
| 1685 |
|
| 1686 |
if (delay == Seconds (0)) |
| 1687 |
{ |
| 1713 |
m_phy->SendPacket (newPacket, txVector, preamble, mpdutype); |
1688 |
m_phy->SendPacket (newPacket, txVector, preamble, mpdutype); |
| 1714 |
} |
1689 |
} |
| 1715 |
else |
1690 |
else |
|
|
| 1718 |
} |
1693 |
} |
| 1719 |
if (queueSize > 1) |
1694 |
if (queueSize > 1) |
| 1720 |
{ |
1695 |
{ |
| 1721 |
delay = delay + m_phy->CalculateTxDuration (GetSize (newPacket, &newHdr), txVector, preamble, m_phy->GetFrequency (), mpdutype, 0); |
1696 |
delay = delay + mpduDuration; |
| 1722 |
} |
1697 |
} |
|
|
1698 |
|
| 1723 |
preamble = WIFI_PREAMBLE_NONE; |
1699 |
preamble = WIFI_PREAMBLE_NONE; |
| 1724 |
} |
1700 |
} |
| 1725 |
} |
1701 |
} |
|
|
| 2668 |
StartDataTxTimers (blockAckReqTxVector); |
2644 |
StartDataTxTimers (blockAckReqTxVector); |
| 2669 |
} |
2645 |
} |
| 2670 |
|
2646 |
|
| 2671 |
NS_ASSERT (duration >= MicroSeconds (0)); |
2647 |
NS_ASSERT (duration >= NanoSeconds (0)); |
| 2672 |
hdr.SetDuration (duration); |
2648 |
hdr.SetDuration (duration); |
| 2673 |
//here should be present a control about immediate or delayed block ack |
2649 |
//here should be present a control about immediate or delayed block ack |
| 2674 |
//for now we assume immediate |
2650 |
//for now we assume immediate |
|
|
| 2813 |
if (aggregatedPacket->RemovePacketTag (ampdu)) |
2789 |
if (aggregatedPacket->RemovePacketTag (ampdu)) |
| 2814 |
{ |
2790 |
{ |
| 2815 |
ampduSubframe = true; |
2791 |
ampduSubframe = true; |
| 2816 |
m_currentTxVector = txVector; |
|
|
| 2817 |
MpduAggregator::DeaggregatedMpdus packets = MpduAggregator::Deaggregate (aggregatedPacket); |
2792 |
MpduAggregator::DeaggregatedMpdus packets = MpduAggregator::Deaggregate (aggregatedPacket); |
| 2818 |
MpduAggregator::DeaggregatedMpdusCI n = packets.begin (); |
2793 |
MpduAggregator::DeaggregatedMpdusCI n = packets.begin (); |
| 2819 |
|
2794 |
|
|
|
| 2829 |
NS_LOG_DEBUG ("Receive VHT single MPDU"); |
2804 |
NS_LOG_DEBUG ("Receive VHT single MPDU"); |
| 2830 |
ampduSubframe = false; |
2805 |
ampduSubframe = false; |
| 2831 |
} |
2806 |
} |
|
|
2807 |
else if (preamble != WIFI_PREAMBLE_NONE || !m_sendAckEvent.IsRunning ()) |
| 2808 |
{ |
| 2809 |
m_sendAckEvent = Simulator::Schedule (ampdu.GetRemainingAmpduDuration () + GetSifs (), |
| 2810 |
&MacLow::SendBlockAckAfterAmpdu, this, |
| 2811 |
firsthdr.GetQosTid (), |
| 2812 |
firsthdr.GetAddr2 (), |
| 2813 |
firsthdr.GetDuration (), |
| 2814 |
txVector, |
| 2815 |
rxSnr); |
| 2816 |
} |
| 2832 |
|
2817 |
|
| 2833 |
if (firsthdr.GetAddr1 () == m_self) |
2818 |
if (firsthdr.GetAddr1 () == m_self) |
| 2834 |
{ |
2819 |
{ |
| 2835 |
if (!vhtSingleMpdu) |
|
|
| 2836 |
{ |
| 2837 |
m_receivedAtLeastOneMpdu = true; |
| 2838 |
} |
| 2839 |
if (firsthdr.IsAck () || firsthdr.IsBlockAck () || firsthdr.IsBlockAckReq ()) |
2820 |
if (firsthdr.IsAck () || firsthdr.IsBlockAck () || firsthdr.IsBlockAckReq ()) |
| 2840 |
{ |
2821 |
{ |
| 2841 |
ReceiveOk ((*n).first, rxSnr, txVector, preamble, ampduSubframe); |
2822 |
ReceiveOk ((*n).first, rxSnr, txVector, preamble, ampduSubframe); |
|
|
| 2856 |
} |
2837 |
} |
| 2857 |
} |
2838 |
} |
| 2858 |
|
2839 |
|
| 2859 |
if (ampdu.GetNoOfMpdus () == 1 && !vhtSingleMpdu) |
2840 |
if (ampdu.GetRemainingNbOfMpdus () == 0 && !vhtSingleMpdu) |
| 2860 |
{ |
2841 |
{ |
| 2861 |
if (normalAck) |
2842 |
if (normalAck) |
| 2862 |
{ |
2843 |
{ |
|
|
| 2869 |
AgreementsI it = m_bAckAgreements.find (std::make_pair (firsthdr.GetAddr2 (), tid)); |
2850 |
AgreementsI it = m_bAckAgreements.find (std::make_pair (firsthdr.GetAddr2 (), tid)); |
| 2870 |
if (it != m_bAckAgreements.end ()) |
2851 |
if (it != m_bAckAgreements.end ()) |
| 2871 |
{ |
2852 |
{ |
| 2872 |
NS_ASSERT (m_sendAckEvent.IsExpired ()); |
|
|
| 2873 |
/* See section 11.5.3 in IEEE 802.11 for mean of this timer */ |
2853 |
/* See section 11.5.3 in IEEE 802.11 for mean of this timer */ |
| 2874 |
ResetBlockAckInactivityTimerIfNeeded (it->second.first); |
2854 |
ResetBlockAckInactivityTimerIfNeeded (it->second.first); |
| 2875 |
NS_LOG_DEBUG ("rx A-MPDU/sendImmediateBlockAck from=" << firsthdr.GetAddr2 ()); |
2855 |
NS_LOG_DEBUG ("rx A-MPDU/sendImmediateBlockAck from=" << firsthdr.GetAddr2 ()); |
| 2876 |
m_sendAckEvent = Simulator::Schedule (GetSifs (), |
2856 |
NS_ASSERT (m_sendAckEvent.IsRunning ()); |
| 2877 |
&MacLow::SendBlockAckAfterAmpdu, this, |
|
|
| 2878 |
firsthdr.GetQosTid (), |
| 2879 |
firsthdr.GetAddr2 (), |
| 2880 |
firsthdr.GetDuration (), |
| 2881 |
txVector, |
| 2882 |
rxSnr); |
| 2883 |
} |
2857 |
} |
| 2884 |
else |
2858 |
else |
| 2885 |
{ |
2859 |
{ |
| 2886 |
NS_LOG_DEBUG ("There's not a valid agreement for this block ack request."); |
2860 |
NS_LOG_DEBUG ("There's not a valid agreement for this block ack request."); |
| 2887 |
} |
2861 |
} |
| 2888 |
} |
2862 |
} |
| 2889 |
m_receivedAtLeastOneMpdu = false; |
|
|
| 2890 |
} |
2863 |
} |
| 2891 |
} |
2864 |
} |
| 2892 |
else |
2865 |
else |
|
|
| 3173 |
listenerIt->second->GetMpduAggregator ()->Aggregate (newPacket, currentAggregatedPacket); |
3146 |
listenerIt->second->GetMpduAggregator ()->Aggregate (newPacket, currentAggregatedPacket); |
| 3174 |
currentAggregatedPacket->AddHeader (blockAckReq); |
3147 |
currentAggregatedPacket->AddHeader (blockAckReq); |
| 3175 |
} |
3148 |
} |
|
|
3149 |
|
| 3176 |
if (qosPolicy == 0) |
3150 |
if (qosPolicy == 0) |
| 3177 |
{ |
3151 |
{ |
| 3178 |
listenerIt->second->CompleteTransfer (hdr.GetAddr1 (), tid); |
3152 |
listenerIt->second->CompleteTransfer (hdr.GetAddr1 (), tid); |
| 3179 |
} |
3153 |
} |
|
|
3154 |
|
| 3180 |
//Add packet tag |
3155 |
//Add packet tag |
| 3181 |
AmpduTag ampdutag; |
3156 |
AmpduTag ampdutag; |
| 3182 |
ampdutag.SetAmpdu (true); |
3157 |
ampdutag.SetAmpdu (true); |
| 3183 |
ampdutag.SetNoOfMpdus (i); |
3158 |
ampdutag.SetRemainingNbOfMpdus (i - 1); |
| 3184 |
newPacket = currentAggregatedPacket; |
3159 |
newPacket = currentAggregatedPacket; |
| 3185 |
newPacket->AddPacketTag (ampdutag); |
3160 |
newPacket->AddPacketTag (ampdutag); |
|
|
3161 |
|
| 3186 |
NS_LOG_DEBUG ("tx unicast A-MPDU"); |
3162 |
NS_LOG_DEBUG ("tx unicast A-MPDU"); |
| 3187 |
listenerIt->second->SetAmpdu (hdr.GetAddr1 (), true); |
3163 |
listenerIt->second->SetAmpdu (hdr.GetAddr1 (), true); |
| 3188 |
} |
3164 |
} |
|
|
| 3217 |
//Add packet tag |
3193 |
//Add packet tag |
| 3218 |
AmpduTag ampdutag; |
3194 |
AmpduTag ampdutag; |
| 3219 |
ampdutag.SetAmpdu (true); |
3195 |
ampdutag.SetAmpdu (true); |
| 3220 |
ampdutag.SetNoOfMpdus (1); |
|
|
| 3221 |
|
| 3222 |
newPacket = currentAggregatedPacket; |
3196 |
newPacket = currentAggregatedPacket; |
| 3223 |
newPacket->AddHeader (peekedHdr); |
3197 |
newPacket->AddHeader (peekedHdr); |
| 3224 |
WifiMacTrailer fcs; |
3198 |
WifiMacTrailer fcs; |