src/wifi/model/mac-low.cc
changeset 11420 ef4dc0386e71
parent 11398 1c3de04836e3
child 11432 d2656819dd54
equal deleted inserted replaced
11419:d118c95b966c 11420:ef4dc0386e71
  1309       txTime += m_phy->CalculateTxDuration (GetRtsSize (), rtsTxVector, preamble, m_phy->GetFrequency(), 0, 0);
  1309       txTime += m_phy->CalculateTxDuration (GetRtsSize (), rtsTxVector, preamble, m_phy->GetFrequency(), 0, 0);
  1310       txTime += GetCtsDuration (hdr->GetAddr1 (), rtsTxVector);
  1310       txTime += GetCtsDuration (hdr->GetAddr1 (), rtsTxVector);
  1311       txTime += Time (GetSifs () * 2);
  1311       txTime += Time (GetSifs () * 2);
  1312     }
  1312     }
  1313   WifiTxVector dataTxVector = GetDataTxVector (packet, hdr);
  1313   WifiTxVector dataTxVector = GetDataTxVector (packet, hdr);
  1314   if ( m_phy->GetGreenfield()&& m_stationManager->GetGreenfieldSupported (m_currentHdr.GetAddr1 ()))
  1314   if (m_phy->GetGreenfield () && m_stationManager->GetGreenfieldSupported (m_currentHdr.GetAddr1 ()))
  1315     preamble = WIFI_PREAMBLE_HT_GF;
  1315     preamble = WIFI_PREAMBLE_HT_GF;
  1316   else //Otherwise, RTS should always use non-HT PPDU (HT PPDU cases not supported yet)
  1316   else if (dataTxVector.GetMode().GetModulationClass () == WIFI_MOD_CLASS_HT)
       
  1317     preamble = WIFI_PREAMBLE_HT_MF;
       
  1318   else
  1317     preamble = WIFI_PREAMBLE_LONG;
  1319     preamble = WIFI_PREAMBLE_LONG;
  1318   uint32_t dataSize = GetSize (packet, hdr);
  1320   uint32_t dataSize = GetSize (packet, hdr);
  1319   txTime += m_phy->CalculateTxDuration (dataSize, dataTxVector, preamble, m_phy->GetFrequency(), 0, 0);
  1321   txTime += m_phy->CalculateTxDuration (dataSize, dataTxVector, preamble, m_phy->GetFrequency(), 0, 0);
  1320   if (params.MustWaitAck ())
  1322   if (params.MustWaitAck ())
  1321     {
  1323     {
  1333   Time txTime = CalculateOverallTxTime (packet, hdr, params);
  1335   Time txTime = CalculateOverallTxTime (packet, hdr, params);
  1334   if (params.HasNextPacket ())
  1336   if (params.HasNextPacket ())
  1335     {
  1337     {
  1336       WifiTxVector dataTxVector = GetDataTxVector (packet, hdr);
  1338       WifiTxVector dataTxVector = GetDataTxVector (packet, hdr);
  1337       WifiPreamble preamble;
  1339       WifiPreamble preamble;
  1338       //standard says RTS packets can have GF format sec 9.6.0e.1 page 110 bullet b 2
  1340       if (m_phy->GetGreenfield () && m_stationManager->GetGreenfieldSupported (m_currentHdr.GetAddr1 ()))
  1339       if ( m_phy->GetGreenfield()&& m_stationManager->GetGreenfieldSupported (m_currentHdr.GetAddr1 ()))
  1341          preamble = WIFI_PREAMBLE_HT_GF;
  1340          preamble= WIFI_PREAMBLE_HT_GF;
       
  1341       else if (dataTxVector.GetMode().GetModulationClass () == WIFI_MOD_CLASS_HT)
  1342       else if (dataTxVector.GetMode().GetModulationClass () == WIFI_MOD_CLASS_HT)
  1342         preamble= WIFI_PREAMBLE_HT_MF;
  1343         preamble = WIFI_PREAMBLE_HT_MF;
  1343       else
  1344       else
  1344         preamble=WIFI_PREAMBLE_LONG;
  1345         preamble = WIFI_PREAMBLE_LONG;
  1345       txTime += GetSifs ();
  1346       txTime += GetSifs ();
  1346       txTime += m_phy->CalculateTxDuration (params.GetNextPacketSize (), dataTxVector, preamble, m_phy->GetFrequency(), 0, 0);
  1347       txTime += m_phy->CalculateTxDuration (params.GetNextPacketSize (), dataTxVector, preamble, m_phy->GetFrequency(), 0, 0);
  1347     }
  1348     }
  1348   return txTime;
  1349   return txTime;
  1349 }
  1350 }
  1629   Time duration = Seconds (0);
  1630   Time duration = Seconds (0);
  1630 
  1631 
  1631   WifiPreamble preamble;
  1632   WifiPreamble preamble;
  1632   //standard says RTS packets can have GF format sec 9.6.0e.1 page 110 bullet b 2
  1633   //standard says RTS packets can have GF format sec 9.6.0e.1 page 110 bullet b 2
  1633   if (m_phy->GetGreenfield () && m_stationManager->GetGreenfieldSupported (m_currentHdr.GetAddr1 ()))
  1634   if (m_phy->GetGreenfield () && m_stationManager->GetGreenfieldSupported (m_currentHdr.GetAddr1 ()))
  1634     preamble= WIFI_PREAMBLE_HT_GF;
  1635     preamble = WIFI_PREAMBLE_HT_GF;
  1635   else //Otherwise, RTS should always use non-HT PPDU (HT PPDU cases not supported yet)
  1636   else //Otherwise, RTS should always use non-HT PPDU (HT PPDU cases not supported yet)
  1636     preamble = WIFI_PREAMBLE_LONG;
  1637     preamble = WIFI_PREAMBLE_LONG;
  1637 
  1638 
  1638   if (m_txParams.HasDurationId ())
  1639   if (m_txParams.HasDurationId ())
  1639     {
  1640     {
  1694 MacLow::StartDataTxTimers (WifiTxVector dataTxVector)
  1695 MacLow::StartDataTxTimers (WifiTxVector dataTxVector)
  1695 {
  1696 {
  1696   WifiPreamble preamble;
  1697   WifiPreamble preamble;
  1697  
  1698  
  1698   //Since it is data then it can have format = GF
  1699   //Since it is data then it can have format = GF
  1699   if (m_phy->GetGreenfield() && m_stationManager->GetGreenfieldSupported (m_currentHdr.GetAddr1 ()))
  1700   if (m_phy->GetGreenfield () && m_stationManager->GetGreenfieldSupported (m_currentHdr.GetAddr1 ()))
  1700     preamble = WIFI_PREAMBLE_HT_GF;
  1701     preamble = WIFI_PREAMBLE_HT_GF;
  1701   else if (dataTxVector.GetMode ().GetModulationClass () == WIFI_MOD_CLASS_HT)
  1702   else if (dataTxVector.GetMode ().GetModulationClass () == WIFI_MOD_CLASS_HT)
  1702     preamble = WIFI_PREAMBLE_HT_MF;
  1703     preamble = WIFI_PREAMBLE_HT_MF;
  1703   else
  1704   else
  1704     preamble = WIFI_PREAMBLE_LONG;
  1705     preamble = WIFI_PREAMBLE_LONG;
  1768   NS_LOG_FUNCTION (this);
  1769   NS_LOG_FUNCTION (this);
  1769   /* send this packet directly. No RTS is needed. */
  1770   /* send this packet directly. No RTS is needed. */
  1770   WifiTxVector dataTxVector = GetDataTxVector (m_currentPacket, &m_currentHdr);
  1771   WifiTxVector dataTxVector = GetDataTxVector (m_currentPacket, &m_currentHdr);
  1771   WifiPreamble preamble;
  1772   WifiPreamble preamble;
  1772           
  1773           
  1773   if (m_phy->GetGreenfield() && m_stationManager->GetGreenfieldSupported (m_currentHdr.GetAddr1 ()))
  1774   if (m_phy->GetGreenfield () && m_stationManager->GetGreenfieldSupported (m_currentHdr.GetAddr1 ()))
  1774      //In the future has to make sure that receiver has greenfield enabled
  1775      //In the future has to make sure that receiver has greenfield enabled
  1775      preamble = WIFI_PREAMBLE_HT_GF;
  1776      preamble = WIFI_PREAMBLE_HT_GF;
  1776   else if (dataTxVector.GetMode ().GetModulationClass () == WIFI_MOD_CLASS_HT)
  1777   else if (dataTxVector.GetMode ().GetModulationClass () == WIFI_MOD_CLASS_HT)
  1777     preamble = WIFI_PREAMBLE_HT_MF;
  1778     preamble = WIFI_PREAMBLE_HT_MF;
  1778   else
  1779   else
  1839   else
  1840   else
  1840     {
  1841     {
  1841       return false;
  1842       return false;
  1842     }
  1843     }
  1843 }
  1844 }
       
  1845 
  1844 void
  1846 void
  1845 MacLow::SendCtsToSelf (void)
  1847 MacLow::SendCtsToSelf (void)
  1846 {
  1848 {
  1847   WifiMacHeader cts;
  1849   WifiMacHeader cts;
  1848   cts.SetType (WIFI_MAC_CTL_CTS);
  1850   cts.SetType (WIFI_MAC_CTL_CTS);
  1925   m_sendDataEvent = Simulator::Schedule (txDuration,
  1927   m_sendDataEvent = Simulator::Schedule (txDuration,
  1926                                          &MacLow::SendDataAfterCts, this,
  1928                                          &MacLow::SendDataAfterCts, this,
  1927                                          cts.GetAddr1 (),
  1929                                          cts.GetAddr1 (),
  1928                                          duration);
  1930                                          duration);
  1929 }
  1931 }
       
  1932 
  1930 void
  1933 void
  1931 MacLow::SendCtsAfterRts (Mac48Address source, Time duration, WifiTxVector rtsTxVector, double rtsSnr)
  1934 MacLow::SendCtsAfterRts (Mac48Address source, Time duration, WifiTxVector rtsTxVector, double rtsSnr)
  1932 {
  1935 {
  1933   NS_LOG_FUNCTION (this << source << duration << rtsTxVector.GetMode () << rtsSnr);
  1936   NS_LOG_FUNCTION (this << source << duration << rtsTxVector.GetMode () << rtsSnr);
  1934   /* send a CTS when you receive a RTS
  1937   /* send a CTS when you receive a RTS
  2396   else
  2399   else
  2397     preamble = WIFI_PREAMBLE_LONG;
  2400     preamble = WIFI_PREAMBLE_LONG;
  2398   ForwardDown (packet, &hdr, blockAckReqTxVector, preamble);
  2401   ForwardDown (packet, &hdr, blockAckReqTxVector, preamble);
  2399   m_currentPacket = 0;
  2402   m_currentPacket = 0;
  2400 }
  2403 }
       
  2404 
  2401 void 
  2405 void 
  2402 MacLow::SendBlockAckAfterAmpdu (uint8_t tid, Mac48Address originator, Time duration, WifiTxVector blockAckReqTxVector)
  2406 MacLow::SendBlockAckAfterAmpdu (uint8_t tid, Mac48Address originator, Time duration, WifiTxVector blockAckReqTxVector)
  2403 {
  2407 {
  2404   NS_LOG_FUNCTION (this);
  2408   NS_LOG_FUNCTION (this);
  2405   CtrlBAckResponseHeader blockAck;
  2409   CtrlBAckResponseHeader blockAck;
  2580           m_receivedAtLeastOneMpdu = false;
  2584           m_receivedAtLeastOneMpdu = false;
  2581         }
  2585         }
  2582     }
  2586     }
  2583   else
  2587   else
  2584     {     
  2588     {     
  2585           ReceiveOk (aggregatedPacket,rxSnr, txVector, preamble, ampduSubframe);
  2589           ReceiveOk (aggregatedPacket, rxSnr, txVector, preamble, ampduSubframe);
  2586     }
  2590     }
  2587 }
  2591 }
  2588 
  2592 
  2589 bool 
  2593 bool 
  2590 MacLow::StopMpduAggregation(Ptr<const Packet> peekedPacket, WifiMacHeader peekedHdr, Ptr<Packet> aggregatedPacket, uint16_t size) const
  2594 MacLow::StopMpduAggregation(Ptr<const Packet> peekedPacket, WifiMacHeader peekedHdr, Ptr<Packet> aggregatedPacket, uint16_t size) const
  2591 {
  2595 {
  2592     WifiPreamble preamble;
  2596     WifiPreamble preamble;
  2593     WifiTxVector dataTxVector = GetDataTxVector (m_currentPacket, &m_currentHdr);
  2597     WifiTxVector dataTxVector = GetDataTxVector (m_currentPacket, &m_currentHdr);
  2594     if (m_phy->GetGreenfield () && m_stationManager->GetGreenfieldSupported (m_currentHdr.GetAddr1 ()))
  2598     if (m_phy->GetGreenfield () && m_stationManager->GetGreenfieldSupported (m_currentHdr.GetAddr1 ()))
  2595         preamble = WIFI_PREAMBLE_HT_GF;
  2599         preamble = WIFI_PREAMBLE_HT_GF;
  2596     else //Block ACK following implicit BAR always use non-HT PPDU
  2600     else if (dataTxVector.GetMode ().GetModulationClass () == WIFI_MOD_CLASS_HT)
       
  2601         preamble = WIFI_PREAMBLE_HT_MF;
       
  2602     else
  2597         preamble = WIFI_PREAMBLE_LONG;
  2603         preamble = WIFI_PREAMBLE_LONG;
  2598     
  2604     
  2599     if (peekedPacket == 0)
  2605     if (peekedPacket == 0)
  2600         return true;
  2606         return true;
  2601     
  2607