View | Details | Raw Unified | Return to bug 2493
Collapse All | Expand All

(-)a/src/wifi/model/dcf-manager.h (-12 / +12 lines)
 Lines 140-155    Link Here 
140
   */
140
   */
141
  bool IsAccessRequested (void) const;
141
  bool IsAccessRequested (void) const;
142
142
143
144
private:
145
  friend class DcfManager;
146
147
  /**
143
  /**
148
   * Return the current number of backoff slots.
144
   * Return the current number of backoff slots.
149
   *
145
   *
150
   * \return the current number of backoff slots
146
   * \return the current number of backoff slots
151
   */
147
   */
152
  uint32_t GetBackoffSlots (void) const;
148
  uint32_t GetBackoffSlots (void) const;
149
150
private:
151
  friend class DcfManager;
152
153
  /**
153
  /**
154
   * Return the time when the backoff procedure started.
154
   * Return the time when the backoff procedure started.
155
   *
155
   *
 Lines 427-432    Link Here 
427
   */
427
   */
428
  void NotifyCtsTimeoutResetNow ();
428
  void NotifyCtsTimeoutResetNow ();
429
429
430
  /**
431
   * Check if the device is busy sending or receiving,
432
   * or NAV busy.
433
   *
434
   * \return true if the device is busy,
435
   *         false otherwise
436
   */
437
  bool IsBusy (void) const;
430
438
431
private:
439
private:
432
  /**
440
  /**
 Lines 527-540    Link Here 
527
   * Grant access to DCF
535
   * Grant access to DCF
528
   */
536
   */
529
  void DoGrantAccess (void);
537
  void DoGrantAccess (void);
530
  /**
531
   * Check if the device is busy sending or receiving,
532
   * or NAV busy.
533
   *
534
   * \return true if the device is busy,
535
   *         false otherwise
536
   */
537
  bool IsBusy (void) const;
538
538
539
  /**
539
  /**
540
   * typedef for a vector of DcfStates
540
   * typedef for a vector of DcfStates
(-)a/src/wifi/model/edca-txop-n.cc (-21 / +73 lines)
 Lines 718-725    Link Here 
718
    {
718
    {
719
      m_dcf->UpdateFailedCw ();
719
      m_dcf->UpdateFailedCw ();
720
    }
720
    }
721
  m_backoffTrace = m_rng->GetNext (0, m_dcf->GetCw ());
721
  StartBackoffIfNeeded ();
722
  m_dcf->StartBackoffNow (m_backoffTrace);
723
  RestartAccessIfNeeded ();
722
  RestartAccessIfNeeded ();
724
}
723
}
725
724
 Lines 727-734    Link Here 
727
EdcaTxopN::NotifyCollision (void)
726
EdcaTxopN::NotifyCollision (void)
728
{
727
{
729
  NS_LOG_FUNCTION (this);
728
  NS_LOG_FUNCTION (this);
730
  m_backoffTrace = m_rng->GetNext (0, m_dcf->GetCw ());
729
  StartBackoffIfNeeded ();
731
  m_dcf->StartBackoffNow (m_backoffTrace);
732
  RestartAccessIfNeeded ();
730
  RestartAccessIfNeeded ();
733
}
731
}
734
732
 Lines 862-869    Link Here 
862
      m_dcf->UpdateFailedCw ();
860
      m_dcf->UpdateFailedCw ();
863
      m_cwTrace = m_dcf->GetCw ();
861
      m_cwTrace = m_dcf->GetCw ();
864
    }
862
    }
865
  m_backoffTrace = m_rng->GetNext (0, m_dcf->GetCw ());
863
  StartBackoffIfNeeded ();
866
  m_dcf->StartBackoffNow (m_backoffTrace);
867
  RestartAccessIfNeeded ();
864
  RestartAccessIfNeeded ();
868
}
865
}
869
866
 Lines 899-905    Link Here 
899
  NS_LOG_FUNCTION (this << packet << &hdr);
896
  NS_LOG_FUNCTION (this << packet << &hdr);
900
  m_stationManager->PrepareForQueue (hdr.GetAddr1 (), &hdr, packet);
897
  m_stationManager->PrepareForQueue (hdr.GetAddr1 (), &hdr, packet);
901
  m_queue->Enqueue (packet, hdr);
898
  m_queue->Enqueue (packet, hdr);
902
  StartAccessIfNeeded ();
899
  if (m_dcf->GetBackoffSlots () == 0 && m_manager->IsBusy () && !HasTxop ())
900
    {
901
      NS_LOG_DEBUG ("Starting backoff; slots=" << m_dcf->GetBackoffSlots () << " busy= " << m_manager->IsBusy ());
902
      m_backoffTrace = m_rng->GetNext (0, m_dcf->GetCw ());
903
      NS_LOG_DEBUG ("Drawing new backoff " << m_backoffTrace);
904
      m_dcf->StartBackoffNow (m_backoffTrace);
905
      RestartAccessIfNeeded ();
906
    }
907
  else
908
    {
909
      StartAccessIfNeeded ();
910
    }
903
}
911
}
904
912
905
void
913
void
 Lines 938-948    Link Here 
938
        }
946
        }
939
      m_currentPacket = 0;
947
      m_currentPacket = 0;
940
      m_dcf->ResetCw ();
948
      m_dcf->ResetCw ();
941
      if (!HasTxop ())
949
      m_cwTrace = m_dcf->GetCw ();
950
      if (HasPendingQosMpduWithSameTidAndAddress () && !HasTxop () && m_dcf->GetBackoffSlots () == 0)
942
        {
951
        {
943
          m_cwTrace = m_dcf->GetCw ();
952
          StartBackoffIfNeeded ();
944
          m_backoffTrace = m_rng->GetNext (0, m_dcf->GetCw ());
945
          m_dcf->StartBackoffNow (m_backoffTrace);
946
          RestartAccessIfNeeded ();
953
          RestartAccessIfNeeded ();
947
        }
954
        }
948
    }
955
    }
 Lines 1012-1019    Link Here 
1012
      m_dcf->UpdateFailedCw ();
1019
      m_dcf->UpdateFailedCw ();
1013
      m_cwTrace = m_dcf->GetCw ();
1020
      m_cwTrace = m_dcf->GetCw ();
1014
    }
1021
    }
1015
  m_backoffTrace = m_rng->GetNext (0, m_dcf->GetCw ());
1022
  StartBackoffIfNeeded ();
1016
  m_dcf->StartBackoffNow (m_backoffTrace);
1017
  RestartAccessIfNeeded ();
1023
  RestartAccessIfNeeded ();
1018
}
1024
}
1019
1025
 Lines 1087-1094    Link Here 
1087
      m_dcf->ResetCw ();
1093
      m_dcf->ResetCw ();
1088
      m_cwTrace = m_dcf->GetCw ();
1094
      m_cwTrace = m_dcf->GetCw ();
1089
    }
1095
    }
1090
  m_backoffTrace = m_rng->GetNext (0, m_dcf->GetCw ());
1096
  StartBackoffIfNeeded ();
1091
  m_dcf->StartBackoffNow (m_backoffTrace);
1092
  RestartAccessIfNeeded ();
1097
  RestartAccessIfNeeded ();
1093
}
1098
}
1094
1099
 Lines 1260-1267    Link Here 
1260
                                                                 &tstamp);
1265
                                                                 &tstamp);
1261
  if (peekedPacket == 0)
1266
  if (peekedPacket == 0)
1262
    {
1267
    {
1268
      NS_LOG_DEBUG ("No pending packet; returning");
1263
      return;
1269
      return;
1264
    }
1270
    }
1271
  if (!HasTxop () && m_dcf->GetBackoffSlots () == 0)
1272
    {
1273
      NS_LOG_DEBUG ("No TXOP left; start backoff again");
1274
      m_backoffTrace = m_rng->GetNext (0, m_dcf->GetCw ());
1275
      NS_LOG_DEBUG ("Drawing new backoff " << m_backoffTrace);
1276
      m_dcf->StartBackoffNow (m_backoffTrace);
1277
      RestartAccessIfNeeded ();
1278
    }
1265
    
1279
    
1266
  MacLowTransmissionParameters params;
1280
  MacLowTransmissionParameters params;
1267
  params.DisableOverrideDurationId ();
1281
  params.DisableOverrideDurationId ();
 Lines 1295-1300    Link Here 
1295
    }
1309
    }
1296
}
1310
}
1297
1311
1312
void
1313
EdcaTxopN::StartBackoffIfNeeded (void)
1314
{
1315
  NS_LOG_FUNCTION (this);
1316
  if (m_dcf->GetBackoffSlots () == 0)
1317
    {
1318
      m_backoffTrace = m_rng->GetNext (0, m_dcf->GetCw ());
1319
      NS_LOG_DEBUG ("Drawing new backoff " << m_backoffTrace);
1320
      m_dcf->StartBackoffNow (m_backoffTrace);
1321
    }
1322
}
1323
1298
Time
1324
Time
1299
EdcaTxopN::GetTxopRemaining (void)
1325
EdcaTxopN::GetTxopRemaining (void)
1300
{
1326
{
 Lines 1353-1358    Link Here 
1353
  return (GetTxopRemaining () >= Low ()->CalculateOverallTxTime (peekedPacket, &hdr, params));
1379
  return (GetTxopRemaining () >= Low ()->CalculateOverallTxTime (peekedPacket, &hdr, params));
1354
}
1380
}
1355
1381
1382
bool
1383
EdcaTxopN::HasPendingQosMpduWithSameTidAndAddress (void) const
1384
{
1385
  NS_LOG_FUNCTION (this);
1386
  WifiMacHeader hdr;
1387
  Time tstamp;
1388
  if (!m_currentHdr.IsQosData ())
1389
    {
1390
      NS_LOG_DEBUG ("Current header is not QoS data; returning false");
1391
      return false;
1392
    }
1393
1394
  Ptr<const Packet> peekedPacket = m_queue->PeekByTidAndAddress (&hdr,
1395
                                                                 m_currentHdr.GetQosTid (),
1396
                                                                 WifiMacHeader::ADDR1,
1397
                                                                 m_currentHdr.GetAddr1 (),
1398
                                                                 &tstamp);
1399
  if (peekedPacket == 0)
1400
    {
1401
      NS_LOG_DEBUG ("No pending MPDU matching current header TID and address; returning false");
1402
      return false;
1403
    }
1404
  else
1405
    {
1406
      NS_LOG_DEBUG ("Pending MPDU found; returning true");
1407
      return true;
1408
    }
1409
}
1410
1356
void
1411
void
1357
EdcaTxopN::Cancel (void)
1412
EdcaTxopN::Cancel (void)
1358
{
1413
{
 Lines 1368-1375    Link Here 
1368
  m_currentPacket = 0;
1423
  m_currentPacket = 0;
1369
  m_dcf->ResetCw ();
1424
  m_dcf->ResetCw ();
1370
  m_cwTrace = m_dcf->GetCw ();
1425
  m_cwTrace = m_dcf->GetCw ();
1371
  m_backoffTrace = m_rng->GetNext (0, m_dcf->GetCw ());
1426
  StartBackoffIfNeeded ();
1372
  m_dcf->StartBackoffNow (m_backoffTrace);
1373
  StartAccessIfNeeded ();
1427
  StartAccessIfNeeded ();
1374
}
1428
}
1375
1429
 Lines 1552-1559    Link Here 
1552
  m_currentPacket = 0;
1606
  m_currentPacket = 0;
1553
  m_dcf->ResetCw ();
1607
  m_dcf->ResetCw ();
1554
  m_cwTrace = m_dcf->GetCw ();
1608
  m_cwTrace = m_dcf->GetCw ();
1555
  m_backoffTrace = m_rng->GetNext (0, m_dcf->GetCw ());
1609
  StartBackoffIfNeeded ();
1556
  m_dcf->StartBackoffNow (m_backoffTrace);
1557
  RestartAccessIfNeeded ();
1610
  RestartAccessIfNeeded ();
1558
}
1611
}
1559
1612
 Lines 1830-1837    Link Here 
1830
  NS_LOG_FUNCTION (this);
1883
  NS_LOG_FUNCTION (this);
1831
  m_dcf->ResetCw ();
1884
  m_dcf->ResetCw ();
1832
  m_cwTrace = m_dcf->GetCw ();
1885
  m_cwTrace = m_dcf->GetCw ();
1833
  m_backoffTrace = m_rng->GetNext (0, m_dcf->GetCw ());
1886
  StartBackoffIfNeeded ();
1834
  m_dcf->StartBackoffNow (m_backoffTrace);
1835
  ns3::Dcf::DoInitialize ();
1887
  ns3::Dcf::DoInitialize ();
1836
}
1888
}
1837
1889
(-)a/src/wifi/model/edca-txop-n.h (-1 / +11 lines)
 Lines 547-556    Link Here 
547
  /*
547
  /*
548
   * Check if the station has TXOP granted for the next MPDU.
548
   * Check if the station has TXOP granted for the next MPDU.
549
   *
549
   *
550
   * \return true if the station has TXOP granted for the next MPDU,
550
   * \return true if the station has another MPDU ready and TXOP granted for it,
551
   *         false otherwise
551
   *         false otherwise
552
   */
552
   */
553
  bool HasTxop (void);
553
  bool HasTxop (void);
554
  /*
555
   * Check if the station has a MPDU pending with the same TID and address
556
   * as the current packet.
557
   *
558
   * \return true if the station has a MPDU pending with the same TID and
559
   *         address as the current packet, false otherwise 
560
   */
561
  bool HasPendingQosMpduWithSameTidAndAddress (void) const;
562
563
  void StartBackoffIfNeeded (void);
554
564
555
  AcIndex m_ac;
565
  AcIndex m_ac;
556
  class Dcf;
566
  class Dcf;

Return to bug 2493