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

(-)a/src/devices/wifi/wifi-test.cc (+118 lines)
 Lines 289-294    Link Here 
289
289
290
//-----------------------------------------------------------------------------
290
//-----------------------------------------------------------------------------
291
291
292
/**
293
 * Make sure that when two broadcast packets are queued on the same
294
 * device in a short succession no virtual collision occurs 
295
 * 
296
 */
297
class Bug555Test : public TestCase
298
{
299
public:
300
  Bug555Test ();
301
302
  virtual bool DoRun (void);
303
304
  void Receive (Ptr<Packet>, double x, WifiMode mode, enum WifiPreamble preamble);
305
306
private:
307
  void RunOne (void);
308
  void CreateOne (Vector pos, Ptr<YansWifiChannel> channel);
309
  void SendOnePacket (Ptr<WifiNetDevice> dev);
310
311
  ObjectFactory m_manager;
312
  ObjectFactory m_mac; 
313
  ObjectFactory m_propDelay;
314
315
  unsigned int m_numReceivedPackets;
316
};
317
318
Bug555Test::Bug555Test ()
319
  : TestCase ("Bug555")
320
{
321
}
322
323
void
324
Bug555Test::SendOnePacket (Ptr<WifiNetDevice> dev)
325
{
326
  Ptr<Packet> p = Create<Packet> (1000);
327
  dev->Send (p, dev->GetBroadcast (), 1);
328
}
329
330
bool
331
Bug555Test::DoRun (void)
332
{
333
  m_mac.SetTypeId ("ns3::AdhocWifiMac");
334
  m_propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
335
  m_manager.SetTypeId ("ns3::ConstantRateWifiManager");
336
337
  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
338
  Ptr<PropagationDelayModel> propDelay = m_propDelay.Create<PropagationDelayModel> ();
339
  Ptr<PropagationLossModel> propLoss = CreateObject<RandomPropagationLossModel> ();
340
  channel->SetPropagationDelayModel (propDelay);
341
  channel->SetPropagationLossModel (propLoss);
342
343
  Ptr<Node> txNode = CreateObject<Node> ();
344
  Ptr<WifiNetDevice> txDev = CreateObject<WifiNetDevice> ();
345
  Ptr<WifiMac> txMac = m_mac.Create<WifiMac> ();
346
  txMac->ConfigureStandard (WIFI_PHY_STANDARD_80211a);
347
  Ptr<ConstantPositionMobilityModel> txMobility = CreateObject<ConstantPositionMobilityModel> ();
348
  Ptr<YansWifiPhy> txPhy = CreateObject<YansWifiPhy> ();
349
  Ptr<ErrorRateModel> txError = CreateObject<YansErrorRateModel> ();
350
  txPhy->SetErrorRateModel (txError);
351
  txPhy->SetChannel (channel);
352
  txPhy->SetDevice (txDev);
353
  txPhy->SetMobility (txNode);
354
  txPhy->ConfigureStandard (WIFI_PHY_STANDARD_80211a);
355
356
  txMobility->SetPosition (Vector (0.0, 0.0, 0.0));
357
  txNode->AggregateObject (txMobility);
358
  txMac->SetAddress (Mac48Address::Allocate ());
359
  txDev->SetMac (txMac);
360
  txDev->SetPhy (txPhy);
361
  txDev->SetRemoteStationManager (m_manager.Create<WifiRemoteStationManager> ());
362
  txNode->AddDevice (txDev);
363
364
365
  Ptr<Node> rxNode = CreateObject<Node> ();
366
  Ptr<WifiNetDevice> rxDev = CreateObject<WifiNetDevice> ();
367
  Ptr<WifiMac> rxMac = m_mac.Create<WifiMac> ();
368
  rxMac->ConfigureStandard (WIFI_PHY_STANDARD_80211a);
369
  Ptr<ConstantPositionMobilityModel> rxMobility = CreateObject<ConstantPositionMobilityModel> ();
370
  Ptr<YansWifiPhy> rxPhy = CreateObject<YansWifiPhy> ();
371
  Ptr<ErrorRateModel> rxError = CreateObject<YansErrorRateModel> ();
372
  rxPhy->SetErrorRateModel (rxError);
373
  rxPhy->SetChannel (channel);
374
  rxPhy->SetDevice (rxDev);
375
  rxPhy->SetMobility (rxNode);
376
  rxPhy->ConfigureStandard (WIFI_PHY_STANDARD_80211a);
377
  Ptr<WifiRemoteStationManager> manager = m_manager.Create<WifiRemoteStationManager> ();
378
  rxMobility->SetPosition (Vector (0.0, 0.0, 0.0));
379
  rxNode->AggregateObject (rxMobility);
380
  rxMac->SetAddress (Mac48Address::Allocate ());
381
  rxDev->SetMac (rxMac);
382
  rxDev->SetPhy (rxPhy);
383
  rxDev->SetRemoteStationManager (m_manager.Create<WifiRemoteStationManager> ());
384
  rxNode->AddDevice (rxDev);
385
386
387
  rxPhy->SetReceiveOkCallback (MakeCallback (&Bug555Test::Receive, this));
388
389
  m_numReceivedPackets = 0;
390
  Simulator::Schedule (Seconds (1.000000), &Bug555Test::SendOnePacket, this, txDev);
391
  Simulator::Schedule (Seconds (1.000040), &Bug555Test::SendOnePacket, this, txDev);
392
393
  Simulator::Stop (Seconds (10.0));
394
  Simulator::Run ();
395
  Simulator::Destroy ();
396
397
  return (m_numReceivedPackets != 2);
398
}
399
400
void 
401
Bug555Test:: Receive (Ptr<Packet>, double x, WifiMode mode, enum WifiPreamble preamble)
402
{
403
  ++m_numReceivedPackets;
404
}
405
406
407
//-----------------------------------------------------------------------------
408
292
class WifiTestSuite : public TestSuite
409
class WifiTestSuite : public TestSuite
293
{
410
{
294
public:
411
public:
 Lines 301-306    Link Here 
301
  AddTestCase (new WifiTest);
418
  AddTestCase (new WifiTest);
302
  AddTestCase (new QosUtilsIsOldPacketTest);
419
  AddTestCase (new QosUtilsIsOldPacketTest);
303
  AddTestCase (new InterferenceHelperSequenceTest); // Bug 991
420
  AddTestCase (new InterferenceHelperSequenceTest); // Bug 991
421
  AddTestCase (new Bug555Test); 
304
}
422
}
305
423
306
WifiTestSuite g_wifiTestSuite;
424
WifiTestSuite g_wifiTestSuite;

Return to bug 555