LEFT | RIGHT |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2009 IITP RAS | 3 * Copyright (c) 2009 IITP RAS |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 2 as | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 27 matching lines...) Expand all Loading... |
38 NS_LOG_COMPONENT_DEFINE ("MeshWifiInterfaceMac"); | 38 NS_LOG_COMPONENT_DEFINE ("MeshWifiInterfaceMac"); |
39 | 39 |
40 namespace ns3 { | 40 namespace ns3 { |
41 | 41 |
42 NS_OBJECT_ENSURE_REGISTERED (MeshWifiInterfaceMac); | 42 NS_OBJECT_ENSURE_REGISTERED (MeshWifiInterfaceMac); |
43 | 43 |
44 TypeId | 44 TypeId |
45 MeshWifiInterfaceMac::GetTypeId () | 45 MeshWifiInterfaceMac::GetTypeId () |
46 { | 46 { |
47 static TypeId tid = TypeId ("ns3::MeshWifiInterfaceMac") | 47 static TypeId tid = TypeId ("ns3::MeshWifiInterfaceMac") |
48 .SetParent<WifiMac> () | 48 .SetParent<RegularWifiMac> () |
49 .AddConstructor<MeshWifiInterfaceMac> () | 49 .AddConstructor<MeshWifiInterfaceMac> () |
50 .AddAttribute ( "BeaconInterval", | 50 .AddAttribute ( "BeaconInterval", |
51 "Beacon Interval", | 51 "Beacon Interval", |
52 TimeValue (Seconds (0.5)), | 52 TimeValue (Seconds (0.5)), |
53 | 53 |
54 MakeTimeAccessor ( | 54 MakeTimeAccessor ( |
55 &MeshWifiInterfaceMac::m_beaconInterval), | 55 &MeshWifiInterfaceMac::m_beaconInterval), |
56 MakeTimeChecker () | 56 MakeTimeChecker () |
57 ) | 57 ) |
58 .AddAttribute ( "RandomStart", | 58 .AddAttribute ( "RandomStart", |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 } | 101 } |
102 bool | 102 bool |
103 MeshWifiInterfaceMac::SupportsSendFrom () const | 103 MeshWifiInterfaceMac::SupportsSendFrom () const |
104 { | 104 { |
105 return true; | 105 return true; |
106 } | 106 } |
107 void | 107 void |
108 MeshWifiInterfaceMac::SetLinkUpCallback (Callback<void> linkUp) | 108 MeshWifiInterfaceMac::SetLinkUpCallback (Callback<void> linkUp) |
109 { | 109 { |
110 NS_LOG_FUNCTION (this); | 110 NS_LOG_FUNCTION (this); |
111 WifiMac::SetLinkUpCallback (linkUp); | 111 RegularWifiMac::SetLinkUpCallback (linkUp); |
112 | 112 |
113 // The approach taken here is that, from the point of view of a mesh | 113 // The approach taken here is that, from the point of view of a mesh |
114 // node, the link is always up, so we immediately invoke the | 114 // node, the link is always up, so we immediately invoke the |
115 // callback if one is set | 115 // callback if one is set |
116 linkUp (); | 116 linkUp (); |
117 } | 117 } |
118 void | 118 void |
119 MeshWifiInterfaceMac::DoDispose () | 119 MeshWifiInterfaceMac::DoDispose () |
120 { | 120 { |
121 NS_LOG_FUNCTION (this); | 121 NS_LOG_FUNCTION (this); |
122 m_plugins.clear (); | 122 m_plugins.clear (); |
123 m_beaconSendEvent.Cancel (); | 123 m_beaconSendEvent.Cancel (); |
124 | 124 |
125 WifiMac::DoDispose (); | 125 RegularWifiMac::DoDispose (); |
126 } | 126 } |
127 //----------------------------------------------------------------------------- | 127 //----------------------------------------------------------------------------- |
128 // Plugins | 128 // Plugins |
129 //----------------------------------------------------------------------------- | 129 //----------------------------------------------------------------------------- |
130 void | 130 void |
131 MeshWifiInterfaceMac::InstallPlugin (Ptr<MeshWifiInterfaceMacPlugin> plugin) | 131 MeshWifiInterfaceMac::InstallPlugin (Ptr<MeshWifiInterfaceMacPlugin> plugin) |
132 { | 132 { |
133 NS_LOG_FUNCTION (this); | 133 NS_LOG_FUNCTION (this); |
134 | 134 |
135 plugin->SetParent (this); | 135 plugin->SetParent (this); |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 NS_ASSERT (Simulator::Now ().GetMicroSeconds () == GetTbtt ().GetMicroSeconds
()); // assert that beacon is just on time | 382 NS_ASSERT (Simulator::Now ().GetMicroSeconds () == GetTbtt ().GetMicroSeconds
()); // assert that beacon is just on time |
383 | 383 |
384 // Form & send beacon | 384 // Form & send beacon |
385 MeshWifiBeacon beacon (GetSsid (), GetSupportedRates (), m_beaconInterval.GetM
icroSeconds ()); | 385 MeshWifiBeacon beacon (GetSsid (), GetSupportedRates (), m_beaconInterval.GetM
icroSeconds ()); |
386 | 386 |
387 // Ask all plugins to add their specific information elements to beacon | 387 // Ask all plugins to add their specific information elements to beacon |
388 for (PluginList::const_iterator i = m_plugins.begin (); i != m_plugins.end ();
++i) | 388 for (PluginList::const_iterator i = m_plugins.begin (); i != m_plugins.end ();
++i) |
389 { | 389 { |
390 (*i)->UpdateBeacon (beacon); | 390 (*i)->UpdateBeacon (beacon); |
391 } | 391 } |
392 m_dca->Queue (beacon.CreatePacket (), beacon.CreateHeader (GetAddress (), GetM
eshPointAddress ())); | 392 m_beaconDca->Queue (beacon.CreatePacket (), |
| 393 beacon.CreateHeader (GetAddress (), |
| 394 GetMeshPointAddress ())); |
393 | 395 |
394 ScheduleNextBeacon (); | 396 ScheduleNextBeacon (); |
395 } | 397 } |
396 void | 398 void |
397 MeshWifiInterfaceMac::Receive (Ptr<Packet> packet, WifiMacHeader const *hdr) | 399 MeshWifiInterfaceMac::Receive (Ptr<Packet> packet, WifiMacHeader const *hdr) |
398 { | 400 { |
399 // Process beacon | 401 // Process beacon |
400 if ((hdr->GetAddr1 () != GetAddress ()) && (hdr->GetAddr1 () != Mac48Address::
GetBroadcast ())) | 402 if ((hdr->GetAddr1 () != GetAddress ()) && (hdr->GetAddr1 () != Mac48Address::
GetBroadcast ())) |
401 { | 403 { |
402 return; | 404 return; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 if (hdr->IsQosData ()) | 451 if (hdr->IsQosData ()) |
450 { | 452 { |
451 packet->AddPacketTag (QosTag (hdr->GetQosTid ())); | 453 packet->AddPacketTag (QosTag (hdr->GetQosTid ())); |
452 } | 454 } |
453 // Forward data up | 455 // Forward data up |
454 if (hdr->IsData ()) | 456 if (hdr->IsData ()) |
455 { | 457 { |
456 ForwardUp (packet, hdr->GetAddr4 (), hdr->GetAddr3 ()); | 458 ForwardUp (packet, hdr->GetAddr4 (), hdr->GetAddr3 ()); |
457 } | 459 } |
458 | 460 |
459 // We don't bother invoking WifiMac::Receive() here, because we've | 461 // We don't bother invoking RegularWifiMac::Receive() here, because |
460 // explicitly handled all the frames we care about. This is in | 462 // we've explicitly handled all the frames we care about. This is in |
461 // contrast to most classes which derive from WifiMac. | 463 // contrast to most classes which derive from RegularWifiMac. |
462 } | 464 } |
463 uint32_t | 465 uint32_t |
464 MeshWifiInterfaceMac::GetLinkMetric (Mac48Address peerAddress) | 466 MeshWifiInterfaceMac::GetLinkMetric (Mac48Address peerAddress) |
465 { | 467 { |
466 uint32_t metric = 1; | 468 uint32_t metric = 1; |
467 if (!m_linkMetricCallback.IsNull ()) | 469 if (!m_linkMetricCallback.IsNull ()) |
468 { | 470 { |
469 metric = m_linkMetricCallback (peerAddress, this); | 471 metric = m_linkMetricCallback (peerAddress, this); |
470 } | 472 } |
471 return metric; | 473 return metric; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 } | 515 } |
514 void | 516 void |
515 MeshWifiInterfaceMac::ResetStats () | 517 MeshWifiInterfaceMac::ResetStats () |
516 { | 518 { |
517 m_stats = Statistics (); | 519 m_stats = Statistics (); |
518 } | 520 } |
519 | 521 |
520 void | 522 void |
521 MeshWifiInterfaceMac::FinishConfigureStandard (enum WifiPhyStandard standard) | 523 MeshWifiInterfaceMac::FinishConfigureStandard (enum WifiPhyStandard standard) |
522 { | 524 { |
523 WifiMac::FinishConfigureStandard (standard); | 525 RegularWifiMac::FinishConfigureStandard (standard); |
524 m_standard = standard; | 526 m_standard = standard; |
525 | |
526 // We use the single DCF provided by WifiMac for the purpose of | |
527 // Beacon transmission. For this we need to reconfigure the channel | |
528 // access parameters slightly, and do so here, after· | |
529 m_dca->SetMinCw (0); | |
530 m_dca->SetMaxCw (0); | |
531 m_dca->SetAifsn (1); | |
532 } | 527 } |
533 WifiPhyStandard | 528 WifiPhyStandard |
534 MeshWifiInterfaceMac::GetPhyStandard () const | 529 MeshWifiInterfaceMac::GetPhyStandard () const |
535 { | 530 { |
536 return m_standard; | 531 return m_standard; |
537 } | 532 } |
538 } // namespace ns3 | 533 } // namespace ns3 |
539 | 534 |
LEFT | RIGHT |