|
|
| 913 |
MacLow::GetAckDuration (Mac48Address to, WifiMode dataTxMode) const |
913 |
MacLow::GetAckDuration (Mac48Address to, WifiMode dataTxMode) const |
| 914 |
{ |
914 |
{ |
| 915 |
WifiMode ackMode = GetAckTxModeForData (to, dataTxMode); |
915 |
WifiMode ackMode = GetAckTxModeForData (to, dataTxMode); |
|
|
916 |
return GetAckDuration (ackMode); |
| 917 |
} |
| 918 |
Time |
| 919 |
MacLow::GetAckDuration (WifiMode ackMode) const |
| 920 |
{ |
| 916 |
return m_phy->CalculateTxDuration (GetAckSize (), ackMode, WIFI_PREAMBLE_LONG); |
921 |
return m_phy->CalculateTxDuration (GetAckSize (), ackMode, WIFI_PREAMBLE_LONG); |
| 917 |
} |
922 |
} |
| 918 |
Time |
923 |
Time |
|
|
| 932 |
MacLow::GetCtsDuration (Mac48Address to, WifiMode rtsTxMode) const |
937 |
MacLow::GetCtsDuration (Mac48Address to, WifiMode rtsTxMode) const |
| 933 |
{ |
938 |
{ |
| 934 |
WifiMode ctsMode = GetCtsTxModeForRts (to, rtsTxMode); |
939 |
WifiMode ctsMode = GetCtsTxModeForRts (to, rtsTxMode); |
|
|
940 |
return GetCtsDuration (ctsMode); |
| 941 |
} |
| 942 |
|
| 943 |
Time |
| 944 |
MacLow::GetCtsDuration (WifiMode ctsMode) const |
| 945 |
{ |
| 935 |
return m_phy->CalculateTxDuration (GetCtsSize (), ctsMode, WIFI_PREAMBLE_LONG); |
946 |
return m_phy->CalculateTxDuration (GetCtsSize (), ctsMode, WIFI_PREAMBLE_LONG); |
| 936 |
} |
947 |
} |
|
|
948 |
|
| 937 |
uint32_t |
949 |
uint32_t |
| 938 |
MacLow::GetCtsSize (void) const |
950 |
MacLow::GetCtsSize (void) const |
| 939 |
{ |
951 |
{ |
|
|
| 948 |
return packet->GetSize () + hdr->GetSize () + fcs.GetSerializedSize (); |
960 |
return packet->GetSize () + hdr->GetSize () + fcs.GetSerializedSize (); |
| 949 |
} |
961 |
} |
| 950 |
|
962 |
|
| 951 |
WifiMode |
963 |
WifiTxVector |
| 952 |
MacLow::GetRtsTxMode (Ptr<const Packet> packet, const WifiMacHeader *hdr) const |
964 |
MacLow::GetRtsTxVector (Ptr<const Packet> packet, const WifiMacHeader *hdr) const |
| 953 |
{ |
965 |
{ |
| 954 |
Mac48Address to = hdr->GetAddr1 (); |
966 |
Mac48Address to = hdr->GetAddr1 (); |
| 955 |
return m_stationManager->GetRtsMode (to, hdr, packet); |
967 |
return m_stationManager->GetRtsTxVector (to, hdr, packet); |
| 956 |
} |
968 |
} |
| 957 |
WifiMode |
969 |
WifiTxVector |
| 958 |
MacLow::GetDataTxMode (Ptr<const Packet> packet, const WifiMacHeader *hdr) const |
970 |
MacLow::GetDataTxVector (Ptr<const Packet> packet, const WifiMacHeader *hdr) const |
| 959 |
{ |
971 |
{ |
| 960 |
Mac48Address to = hdr->GetAddr1 (); |
972 |
Mac48Address to = hdr->GetAddr1 (); |
| 961 |
WifiMacTrailer fcs; |
973 |
WifiMacTrailer fcs; |
| 962 |
uint32_t size = packet->GetSize () + hdr->GetSize () + fcs.GetSerializedSize (); |
974 |
uint32_t size = packet->GetSize () + hdr->GetSize () + fcs.GetSerializedSize (); |
| 963 |
return m_stationManager->GetDataMode (to, hdr, packet, size); |
975 |
return m_stationManager->GetDataTxVector (to, hdr, packet, size); |
|
|
976 |
} |
| 977 |
WifiTxVector |
| 978 |
MacLow::GetCtsTxVector (Mac48Address to, WifiMode rtsTxMode) const |
| 979 |
{ |
| 980 |
return m_stationManager->GetCtsTxVector (to, rtsTxMode); |
| 981 |
} |
| 982 |
WifiTxVector |
| 983 |
MacLow::GetAckTxVector (Mac48Address to, WifiMode dataTxMode) const |
| 984 |
{ |
| 985 |
return m_stationManager->GetAckTxVector (to, dataTxMode); |
| 986 |
} |
| 987 |
WifiTxVector |
| 988 |
MacLow::GetBlockAckTxVector (Mac48Address to, WifiMode dataTxMode) const |
| 989 |
{ |
| 990 |
return m_stationManager->GetBlockAckTxVector (to, dataTxMode); |
| 964 |
} |
991 |
} |
| 965 |
|
992 |
|
| 966 |
WifiMode |
993 |
WifiMode |
| 967 |
MacLow::GetCtsTxModeForRts (Mac48Address to, WifiMode rtsTxMode) const |
994 |
MacLow::GetCtsTxModeForRts (Mac48Address to, WifiMode rtsTxMode) const |
| 968 |
{ |
995 |
{ |
| 969 |
return m_stationManager->GetCtsMode (to, rtsTxMode); |
996 |
return GetCtsTxVector (to, rtsTxMode).mode; |
| 970 |
} |
997 |
} |
| 971 |
WifiMode |
998 |
WifiMode |
| 972 |
MacLow::GetAckTxModeForData (Mac48Address to, WifiMode dataTxMode) const |
999 |
MacLow::GetAckTxModeForData (Mac48Address to, WifiMode dataTxMode) const |
| 973 |
{ |
1000 |
{ |
| 974 |
return m_stationManager->GetAckMode (to, dataTxMode); |
1001 |
return GetAckTxVector (to, dataTxMode).mode; |
| 975 |
} |
1002 |
} |
| 976 |
|
1003 |
|
| 977 |
|
1004 |
|
| 978 |
Time |
|
|
| 979 |
MacLow::CalculateOverallTxTime (Ptr<const Packet> packet, |
| 980 |
const WifiMacHeader* hdr, |
| 981 |
const MacLowTransmissionParameters& params) const |
| 982 |
{ |
| 983 |
Time txTime = Seconds (0); |
| 984 |
WifiMode rtsMode = GetRtsTxMode (packet, hdr); |
| 985 |
WifiMode dataMode = GetDataTxMode (packet, hdr); |
| 986 |
if (params.MustSendRts ()) |
| 987 |
{ |
| 988 |
txTime += m_phy->CalculateTxDuration (GetRtsSize (), rtsMode, WIFI_PREAMBLE_LONG); |
| 989 |
txTime += GetCtsDuration (hdr->GetAddr1 (), rtsMode); |
| 990 |
txTime += GetSifs () * Scalar (2); |
| 991 |
} |
| 992 |
uint32_t dataSize = GetSize (packet, hdr); |
| 993 |
txTime += m_phy->CalculateTxDuration (dataSize, dataMode, WIFI_PREAMBLE_LONG); |
| 994 |
if (params.MustWaitAck ()) |
| 995 |
{ |
| 996 |
txTime += GetSifs (); |
| 997 |
txTime += GetAckDuration (hdr->GetAddr1 (), dataMode); |
| 998 |
} |
| 999 |
return txTime; |
| 1000 |
} |
| 1001 |
|
| 1002 |
Time |
| 1003 |
MacLow::CalculateTransmissionTime (Ptr<const Packet> packet, |
| 1004 |
const WifiMacHeader* hdr, |
| 1005 |
const MacLowTransmissionParameters& params) const |
| 1006 |
{ |
| 1007 |
Time txTime = CalculateOverallTxTime (packet, hdr, params); |
| 1008 |
if (params.HasNextPacket ()) |
| 1009 |
{ |
| 1010 |
WifiMode dataMode = GetDataTxMode (packet, hdr); |
| 1011 |
txTime += GetSifs (); |
| 1012 |
txTime += m_phy->CalculateTxDuration (params.GetNextPacketSize (), dataMode, WIFI_PREAMBLE_LONG); |
| 1013 |
} |
| 1014 |
return txTime; |
| 1015 |
} |
| 1016 |
|
| 1017 |
void |
1005 |
void |
| 1018 |
MacLow::NotifyNav (const WifiMacHeader &hdr, WifiMode txMode, WifiPreamble preamble) |
1006 |
MacLow::NotifyNav (const WifiMacHeader &hdr, WifiMode txMode, WifiPreamble preamble) |
| 1019 |
{ |
1007 |
{ |
|
|
| 1126 |
|
1114 |
|
| 1127 |
void |
1115 |
void |
| 1128 |
MacLow::ForwardDown (Ptr<const Packet> packet, const WifiMacHeader* hdr, |
1116 |
MacLow::ForwardDown (Ptr<const Packet> packet, const WifiMacHeader* hdr, |
| 1129 |
WifiMode txMode) |
1117 |
WifiTxVector txVector) |
| 1130 |
{ |
1118 |
{ |
| 1131 |
NS_LOG_FUNCTION (this << packet << hdr << txMode); |
1119 |
NS_LOG_FUNCTION (this << packet << hdr << txVector); |
| 1132 |
NS_LOG_DEBUG ("send " << hdr->GetTypeString () << |
1120 |
NS_LOG_DEBUG ("send " << hdr->GetTypeString () << |
| 1133 |
", to=" << hdr->GetAddr1 () << |
1121 |
", to=" << hdr->GetAddr1 () << |
| 1134 |
", size=" << packet->GetSize () << |
1122 |
", size=" << packet->GetSize () << |
| 1135 |
", mode=" << txMode << |
1123 |
", mode=" << txVector.mode << |
| 1136 |
", duration=" << hdr->GetDuration () << |
1124 |
", pwrlvl=" << (uint16_t) txVector.txPowerLevel << |
| 1137 |
", seq=0x"<< std::hex << m_currentHdr.GetSequenceControl () << std::dec); |
1125 |
", duration=" << hdr->GetDuration () << |
| 1138 |
m_phy->SendPacket (packet, txMode, WIFI_PREAMBLE_LONG, 0); |
1126 |
", seq=0x"<< std::hex << m_currentHdr.GetSequenceControl () << std::dec); |
|
|
1127 |
m_phy->SendPacket (packet, txVector.mode, WIFI_PREAMBLE_LONG, txVector.txPowerLevel); |
| 1139 |
} |
1128 |
} |
| 1140 |
|
1129 |
|
| 1141 |
void |
1130 |
void |
|
|
| 1225 |
rts.SetNoMoreFragments (); |
1214 |
rts.SetNoMoreFragments (); |
| 1226 |
rts.SetAddr1 (m_currentHdr.GetAddr1 ()); |
1215 |
rts.SetAddr1 (m_currentHdr.GetAddr1 ()); |
| 1227 |
rts.SetAddr2 (m_self); |
1216 |
rts.SetAddr2 (m_self); |
| 1228 |
WifiMode rtsTxMode = GetRtsTxMode (m_currentPacket, &m_currentHdr); |
1217 |
WifiTxVector rtsTxVector = GetRtsTxVector (m_currentPacket, &m_currentHdr); |
| 1229 |
Time duration = Seconds (0); |
1218 |
Time duration = Seconds (0); |
| 1230 |
if (m_txParams.HasDurationId ()) |
1219 |
if (m_txParams.HasDurationId ()) |
| 1231 |
{ |
1220 |
{ |
|
|
| 1233 |
} |
1222 |
} |
| 1234 |
else |
1223 |
else |
| 1235 |
{ |
1224 |
{ |
| 1236 |
WifiMode dataTxMode = GetDataTxMode (m_currentPacket, &m_currentHdr); |
1225 |
WifiTxVector dataTxVector = GetDataTxVector (m_currentPacket, &m_currentHdr); |
| 1237 |
duration += GetSifs (); |
1226 |
duration += GetSifs (); |
| 1238 |
duration += GetCtsDuration (m_currentHdr.GetAddr1 (), rtsTxMode); |
1227 |
duration += GetCtsDuration (m_currentHdr.GetAddr1 (), rtsTxVector.mode); |
| 1239 |
duration += GetSifs (); |
1228 |
duration += GetSifs (); |
| 1240 |
duration += m_phy->CalculateTxDuration (GetSize (m_currentPacket, &m_currentHdr), |
1229 |
duration += m_phy->CalculateTxDuration (GetSize (m_currentPacket, &m_currentHdr), |
| 1241 |
dataTxMode, WIFI_PREAMBLE_LONG); |
1230 |
dataTxVector.mode, WIFI_PREAMBLE_LONG); |
| 1242 |
duration += GetSifs (); |
1231 |
duration += GetSifs (); |
| 1243 |
duration += GetAckDuration (m_currentHdr.GetAddr1 (), dataTxMode); |
1232 |
duration += GetAckDuration (m_currentHdr.GetAddr1 (), dataTxVector.mode); |
| 1244 |
} |
1233 |
} |
| 1245 |
rts.SetDuration (duration); |
1234 |
rts.SetDuration (duration); |
| 1246 |
|
1235 |
|
| 1247 |
Time txDuration = m_phy->CalculateTxDuration (GetRtsSize (), rtsTxMode, WIFI_PREAMBLE_LONG); |
1236 |
Time txDuration = m_phy->CalculateTxDuration (GetRtsSize (), rtsTxVector.mode, WIFI_PREAMBLE_LONG); |
| 1248 |
Time timerDelay = txDuration + GetCtsTimeout (); |
1237 |
Time timerDelay = txDuration + GetCtsTimeout (); |
| 1249 |
|
1238 |
|
| 1250 |
NS_ASSERT (m_ctsTimeoutEvent.IsExpired ()); |
1239 |
NS_ASSERT (m_ctsTimeoutEvent.IsExpired ()); |
|
|
| 1256 |
WifiMacTrailer fcs; |
1245 |
WifiMacTrailer fcs; |
| 1257 |
packet->AddTrailer (fcs); |
1246 |
packet->AddTrailer (fcs); |
| 1258 |
|
1247 |
|
| 1259 |
ForwardDown (packet, &rts, rtsTxMode); |
1248 |
ForwardDown (packet, &rts, rtsTxVector); |
| 1260 |
} |
1249 |
} |
| 1261 |
|
1250 |
|
| 1262 |
void |
1251 |
void |
| 1263 |
MacLow::StartDataTxTimers (void) |
1252 |
MacLow::StartDataTxTimers (WifiMode dataTxMode) |
| 1264 |
{ |
1253 |
{ |
| 1265 |
WifiMode dataTxMode = GetDataTxMode (m_currentPacket, &m_currentHdr); |
|
|
| 1266 |
Time txDuration = m_phy->CalculateTxDuration (GetSize (m_currentPacket, &m_currentHdr), dataTxMode, WIFI_PREAMBLE_LONG); |
1254 |
Time txDuration = m_phy->CalculateTxDuration (GetSize (m_currentPacket, &m_currentHdr), dataTxMode, WIFI_PREAMBLE_LONG); |
| 1267 |
if (m_txParams.MustWaitNormalAck ()) |
1255 |
if (m_txParams.MustWaitNormalAck ()) |
| 1268 |
{ |
1256 |
{ |
|
|
| 1316 |
{ |
1304 |
{ |
| 1317 |
NS_LOG_FUNCTION (this); |
1305 |
NS_LOG_FUNCTION (this); |
| 1318 |
/* send this packet directly. No RTS is needed. */ |
1306 |
/* send this packet directly. No RTS is needed. */ |
| 1319 |
StartDataTxTimers (); |
|
|
| 1320 |
|
1307 |
|
| 1321 |
WifiMode dataTxMode = GetDataTxMode (m_currentPacket, &m_currentHdr); |
1308 |
WifiTxVector dataTxVector = GetDataTxVector (m_currentPacket, &m_currentHdr); |
|
|
1309 |
StartDataTxTimers (dataTxVector.mode); |
| 1310 |
|
| 1322 |
Time duration = Seconds (0.0); |
1311 |
Time duration = Seconds (0.0); |
| 1323 |
if (m_txParams.HasDurationId ()) |
1312 |
if (m_txParams.HasDurationId ()) |
| 1324 |
{ |
1313 |
{ |
|
|
| 1329 |
if (m_txParams.MustWaitBasicBlockAck ()) |
1318 |
if (m_txParams.MustWaitBasicBlockAck ()) |
| 1330 |
{ |
1319 |
{ |
| 1331 |
duration += GetSifs (); |
1320 |
duration += GetSifs (); |
| 1332 |
duration += GetBlockAckDuration (m_currentHdr.GetAddr1 (), dataTxMode, BASIC_BLOCK_ACK); |
1321 |
duration += GetBlockAckDuration (m_currentHdr.GetAddr1 (), dataTxVector.mode, BASIC_BLOCK_ACK); |
| 1333 |
} |
1322 |
} |
| 1334 |
else if (m_txParams.MustWaitCompressedBlockAck ()) |
1323 |
else if (m_txParams.MustWaitCompressedBlockAck ()) |
| 1335 |
{ |
1324 |
{ |
| 1336 |
duration += GetSifs (); |
1325 |
duration += GetSifs (); |
| 1337 |
duration += GetBlockAckDuration (m_currentHdr.GetAddr1 (), dataTxMode, COMPRESSED_BLOCK_ACK); |
1326 |
duration += GetBlockAckDuration (m_currentHdr.GetAddr1 (), dataTxVector.mode, COMPRESSED_BLOCK_ACK); |
| 1338 |
} |
1327 |
} |
| 1339 |
else if (m_txParams.MustWaitAck ()) |
1328 |
else if (m_txParams.MustWaitAck ()) |
| 1340 |
{ |
1329 |
{ |
| 1341 |
duration += GetSifs (); |
1330 |
duration += GetSifs (); |
| 1342 |
duration += GetAckDuration (m_currentHdr.GetAddr1 (), dataTxMode); |
1331 |
duration += GetAckDuration (m_currentHdr.GetAddr1 (), dataTxVector.mode); |
| 1343 |
} |
1332 |
} |
| 1344 |
if (m_txParams.HasNextPacket ()) |
1333 |
if (m_txParams.HasNextPacket ()) |
| 1345 |
{ |
1334 |
{ |
| 1346 |
duration += GetSifs (); |
1335 |
duration += GetSifs (); |
| 1347 |
duration += m_phy->CalculateTxDuration (m_txParams.GetNextPacketSize (), |
1336 |
duration += m_phy->CalculateTxDuration (m_txParams.GetNextPacketSize (), |
| 1348 |
dataTxMode, WIFI_PREAMBLE_LONG); |
1337 |
dataTxVector.mode, WIFI_PREAMBLE_LONG); |
| 1349 |
if (m_txParams.MustWaitAck ()) |
1338 |
if (m_txParams.MustWaitAck ()) |
| 1350 |
{ |
1339 |
{ |
| 1351 |
duration += GetSifs (); |
1340 |
duration += GetSifs (); |
| 1352 |
duration += GetAckDuration (m_currentHdr.GetAddr1 (), dataTxMode); |
1341 |
duration += GetAckDuration (m_currentHdr.GetAddr1 (), dataTxVector.mode); |
| 1353 |
} |
1342 |
} |
| 1354 |
} |
1343 |
} |
| 1355 |
} |
1344 |
} |
|
|
| 1359 |
WifiMacTrailer fcs; |
1348 |
WifiMacTrailer fcs; |
| 1360 |
m_currentPacket->AddTrailer (fcs); |
1349 |
m_currentPacket->AddTrailer (fcs); |
| 1361 |
|
1350 |
|
| 1362 |
ForwardDown (m_currentPacket, &m_currentHdr, dataTxMode); |
1351 |
ForwardDown (m_currentPacket, &m_currentHdr, dataTxVector); |
| 1363 |
m_currentPacket = 0; |
1352 |
m_currentPacket = 0; |
| 1364 |
} |
1353 |
} |
| 1365 |
|
1354 |
|
|
|
| 1383 |
/* send a CTS when you receive a RTS |
1372 |
/* send a CTS when you receive a RTS |
| 1384 |
* right after SIFS. |
1373 |
* right after SIFS. |
| 1385 |
*/ |
1374 |
*/ |
| 1386 |
WifiMode ctsTxMode = GetCtsTxModeForRts (source, rtsTxMode); |
1375 |
WifiTxVector ctsTxVector = GetCtsTxVector (source, rtsTxMode); |
| 1387 |
WifiMacHeader cts; |
1376 |
WifiMacHeader cts; |
| 1388 |
cts.SetType (WIFI_MAC_CTL_CTS); |
1377 |
cts.SetType (WIFI_MAC_CTL_CTS); |
| 1389 |
cts.SetDsNotFrom (); |
1378 |
cts.SetDsNotFrom (); |
|
|
| 1391 |
cts.SetNoMoreFragments (); |
1380 |
cts.SetNoMoreFragments (); |
| 1392 |
cts.SetNoRetry (); |
1381 |
cts.SetNoRetry (); |
| 1393 |
cts.SetAddr1 (source); |
1382 |
cts.SetAddr1 (source); |
| 1394 |
duration -= GetCtsDuration (source, rtsTxMode); |
1383 |
duration -= GetCtsDuration (ctsTxVector.mode); |
| 1395 |
duration -= GetSifs (); |
1384 |
duration -= GetSifs (); |
| 1396 |
NS_ASSERT (duration >= MicroSeconds (0)); |
1385 |
NS_ASSERT (duration >= MicroSeconds (0)); |
| 1397 |
cts.SetDuration (duration); |
1386 |
cts.SetDuration (duration); |
|
|
| 1405 |
tag.Set (rtsSnr); |
1394 |
tag.Set (rtsSnr); |
| 1406 |
packet->AddPacketTag (tag); |
1395 |
packet->AddPacketTag (tag); |
| 1407 |
|
1396 |
|
| 1408 |
ForwardDown (packet, &cts, ctsTxMode); |
1397 |
ForwardDown (packet, &cts, ctsTxVector); |
| 1409 |
} |
1398 |
} |
| 1410 |
|
1399 |
|
| 1411 |
void |
1400 |
void |
| 1412 |
MacLow::SendDataAfterCts (Mac48Address source, Time duration, WifiMode txMode) |
1401 |
MacLow::SendDataAfterCts (Mac48Address source, Time duration, WifiMode ctsTxMode) |
| 1413 |
{ |
1402 |
{ |
| 1414 |
NS_LOG_FUNCTION (this); |
1403 |
NS_LOG_FUNCTION (this); |
| 1415 |
/* send the third step in a |
1404 |
/* send the third step in a |
| 1416 |
* RTS/CTS/DATA/ACK hanshake |
1405 |
* RTS/CTS/DATA/ACK hanshake |
| 1417 |
*/ |
1406 |
*/ |
| 1418 |
NS_ASSERT (m_currentPacket != 0); |
1407 |
NS_ASSERT (m_currentPacket != 0); |
| 1419 |
StartDataTxTimers (); |
1408 |
WifiTxVector dataTxVector = GetDataTxVector (m_currentPacket, &m_currentHdr); |
|
|
1409 |
StartDataTxTimers (dataTxVector.mode); |
| 1420 |
|
1410 |
|
| 1421 |
WifiMode dataTxMode = GetDataTxMode (m_currentPacket, &m_currentHdr); |
1411 |
|
| 1422 |
Time newDuration = Seconds (0); |
1412 |
Time newDuration = Seconds (0); |
| 1423 |
newDuration += GetSifs (); |
1413 |
newDuration += GetSifs (); |
| 1424 |
newDuration += GetAckDuration (m_currentHdr.GetAddr1 (), dataTxMode); |
1414 |
newDuration += GetAckDuration (m_currentHdr.GetAddr1 (), dataTxVector.mode); |
| 1425 |
Time txDuration = m_phy->CalculateTxDuration (GetSize (m_currentPacket, &m_currentHdr), |
1415 |
Time txDuration = m_phy->CalculateTxDuration (GetSize (m_currentPacket, &m_currentHdr), |
| 1426 |
dataTxMode, WIFI_PREAMBLE_LONG); |
1416 |
dataTxVector.mode, WIFI_PREAMBLE_LONG); |
| 1427 |
duration -= txDuration; |
1417 |
duration -= txDuration; |
| 1428 |
duration -= GetSifs (); |
1418 |
duration -= GetSifs (); |
| 1429 |
|
1419 |
|
|
|
| 1435 |
WifiMacTrailer fcs; |
1425 |
WifiMacTrailer fcs; |
| 1436 |
m_currentPacket->AddTrailer (fcs); |
1426 |
m_currentPacket->AddTrailer (fcs); |
| 1437 |
|
1427 |
|
| 1438 |
ForwardDown (m_currentPacket, &m_currentHdr, dataTxMode); |
1428 |
ForwardDown (m_currentPacket, &m_currentHdr, dataTxVector); |
| 1439 |
m_currentPacket = 0; |
1429 |
m_currentPacket = 0; |
| 1440 |
} |
1430 |
} |
| 1441 |
|
1431 |
|
|
|
| 1462 |
/* send an ACK when you receive |
1452 |
/* send an ACK when you receive |
| 1463 |
* a packet after SIFS. |
1453 |
* a packet after SIFS. |
| 1464 |
*/ |
1454 |
*/ |
| 1465 |
WifiMode ackTxMode = GetAckTxModeForData (source, dataTxMode); |
1455 |
WifiTxVector ackTxVector = GetAckTxVector (source, dataTxMode); |
| 1466 |
WifiMacHeader ack; |
1456 |
WifiMacHeader ack; |
| 1467 |
ack.SetType (WIFI_MAC_CTL_ACK); |
1457 |
ack.SetType (WIFI_MAC_CTL_ACK); |
| 1468 |
ack.SetDsNotFrom (); |
1458 |
ack.SetDsNotFrom (); |
|
|
| 1473 |
duration -= GetAckDuration (source, dataTxMode); |
1463 |
duration -= GetAckDuration (source, dataTxMode); |
| 1474 |
duration -= GetSifs (); |
1464 |
duration -= GetSifs (); |
| 1475 |
NS_ASSERT (duration >= MicroSeconds (0)); |
1465 |
NS_ASSERT (duration >= MicroSeconds (0)); |
|
|
1466 |
NS_ASSERT (ack.IsMoreFragments () ^ (duration == MicroSeconds (0))); // Section 7.2.1.3 ACK frame format |
| 1476 |
ack.SetDuration (duration); |
1467 |
ack.SetDuration (duration); |
| 1477 |
|
1468 |
|
| 1478 |
Ptr<Packet> packet = Create<Packet> (); |
1469 |
Ptr<Packet> packet = Create<Packet> (); |
|
|
| 1484 |
tag.Set (dataSnr); |
1475 |
tag.Set (dataSnr); |
| 1485 |
packet->AddPacketTag (tag); |
1476 |
packet->AddPacketTag (tag); |
| 1486 |
|
1477 |
|
| 1487 |
ForwardDown (packet, &ack, ackTxMode); |
1478 |
ForwardDown (packet, &ack, ackTxVector); |
| 1488 |
} |
1479 |
} |
| 1489 |
|
1480 |
|
| 1490 |
bool |
1481 |
bool |
|
|
| 1539 |
Time timeout = MicroSeconds (1024 * agreement.GetTimeout ()); |
1530 |
Time timeout = MicroSeconds (1024 * agreement.GetTimeout ()); |
| 1540 |
|
1531 |
|
| 1541 |
AcIndex ac = QosUtilsMapTidToAc (agreement.GetTid ()); |
1532 |
AcIndex ac = QosUtilsMapTidToAc (agreement.GetTid ()); |
| 1542 |
|
1533 |
|
| 1543 |
it->second.first.m_inactivityEvent = Simulator::Schedule (timeout, |
1534 |
it->second.first.m_inactivityEvent = Simulator::Schedule (timeout, |
| 1544 |
&MacLowBlockAckEventListener::BlockAckInactivityTimeout, |
1535 |
&MacLowBlockAckEventListener::BlockAckInactivityTimeout, |
| 1545 |
m_edcaListeners[ac], |
1536 |
m_edcaListeners[ac], |
|
|
| 1669 |
|
1660 |
|
| 1670 |
m_currentPacket = packet; |
1661 |
m_currentPacket = packet; |
| 1671 |
m_currentHdr = hdr; |
1662 |
m_currentHdr = hdr; |
|
|
1663 |
|
| 1664 |
WifiTxVector blockAckTxVector = GetBlockAckTxVector (originator, blockAckReqTxMode); |
| 1665 |
|
| 1672 |
if (immediate) |
1666 |
if (immediate) |
| 1673 |
{ |
1667 |
{ |
| 1674 |
m_txParams.DisableAck (); |
1668 |
m_txParams.DisableAck (); |
| 1675 |
duration -= GetSifs (); |
1669 |
duration -= GetSifs (); |
| 1676 |
if (blockAck->IsBasic ()) |
1670 |
if (blockAck->IsBasic ()) |
| 1677 |
{ |
1671 |
{ |
| 1678 |
duration -= GetBlockAckDuration (originator, blockAckReqTxMode, BASIC_BLOCK_ACK); |
1672 |
duration -= GetBlockAckDuration (originator, blockAckTxVector.mode, BASIC_BLOCK_ACK); |
| 1679 |
} |
1673 |
} |
| 1680 |
else if (blockAck->IsCompressed ()) |
1674 |
else if (blockAck->IsCompressed ()) |
| 1681 |
{ |
1675 |
{ |
| 1682 |
duration -= GetBlockAckDuration (originator, blockAckReqTxMode, COMPRESSED_BLOCK_ACK); |
1676 |
duration -= GetBlockAckDuration (originator, blockAckTxVector.mode, COMPRESSED_BLOCK_ACK); |
| 1683 |
} |
1677 |
} |
| 1684 |
else if (blockAck->IsMultiTid ()) |
1678 |
else if (blockAck->IsMultiTid ()) |
| 1685 |
{ |
1679 |
{ |
|
|
| 1690 |
{ |
1684 |
{ |
| 1691 |
m_txParams.EnableAck (); |
1685 |
m_txParams.EnableAck (); |
| 1692 |
duration += GetSifs (); |
1686 |
duration += GetSifs (); |
| 1693 |
duration += GetAckDuration (originator, blockAckReqTxMode); |
1687 |
duration += GetAckDuration (originator, blockAckTxVector.mode); |
| 1694 |
} |
1688 |
} |
| 1695 |
m_txParams.DisableNextData (); |
1689 |
m_txParams.DisableNextData (); |
| 1696 |
|
1690 |
|
| 1697 |
StartDataTxTimers (); |
1691 |
StartDataTxTimers (blockAckTxVector.mode); |
| 1698 |
|
1692 |
|
| 1699 |
NS_ASSERT (duration >= MicroSeconds (0)); |
1693 |
NS_ASSERT (duration >= MicroSeconds (0)); |
| 1700 |
hdr.SetDuration (duration); |
1694 |
hdr.SetDuration (duration); |
|
|
| 1703 |
packet->AddHeader (hdr); |
1697 |
packet->AddHeader (hdr); |
| 1704 |
WifiMacTrailer fcs; |
1698 |
WifiMacTrailer fcs; |
| 1705 |
packet->AddTrailer (fcs); |
1699 |
packet->AddTrailer (fcs); |
| 1706 |
ForwardDown (packet, &hdr, blockAckReqTxMode); |
1700 |
ForwardDown (packet, &hdr, blockAckTxVector); |
| 1707 |
m_currentPacket = 0; |
1701 |
m_currentPacket = 0; |
| 1708 |
} |
1702 |
} |
| 1709 |
|
1703 |
|