--- a/examples/mesh.cc Thu Mar 19 11:49:23 2009 +0300
+++ b/examples/mesh.cc Thu Mar 19 12:46:56 2009 +0300
@@ -63,14 +63,12 @@
//wifi.SetPhy ("ns3::WifiPhy");
wifi.SetRemoteStationManager ("ns3::AarfWifiManager");
Ssid ssid = Ssid ("MyMeSH");
- wifi.SetMac ("ns3::MeshWifiMac",
+ wifi.SetMac ("ns3::MeshWifiInterfaceMac",
"Ssid", SsidValue (ssid),
"RandomStart", TimeValue (Seconds (randomStart))
);
- wifi.SetPeerLinkManager ("ns3::WifiPeerManager");
- wifi.SetL2RoutingProtocol ("ns3::Hwmp");
wifi.SetL2RoutingNetDevice ("ns3::MeshPointDevice");
- meshDevices = wifi.Install (wifiPhy,nodes,1);
+ meshDevices = wifi.Install (wifiPhy,nodes);
// Installing Mobility.
mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
"MinX", DoubleValue (0.0),
@@ -81,6 +79,7 @@
"LayoutType", StringValue ("RowFirst"));
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.Install (nodes);
+#if 0
// Setting Internet Stack:
InternetStackHelper stack;
stack.Install (nodes);
@@ -99,6 +98,7 @@
clientApps.Start (Seconds (2.0));
clientApps.Stop (Seconds (10.0));
//end
+#endif
Simulator::Stop (Seconds (10.0));
Simulator::Run ();
Simulator::Destroy ();
--- a/src/devices/mesh/mesh-wifi-helper.cc Thu Mar 19 11:49:23 2009 +0300
+++ b/src/devices/mesh/mesh-wifi-helper.cc Thu Mar 19 12:46:56 2009 +0300
@@ -21,34 +21,24 @@
#include "ns3/mesh-wifi-helper.h"
+#include "ns3/mesh-point-device.h"
#include "ns3/wifi-net-device.h"
-#include "ns3/wifi-mac.h"
#include "ns3/wifi-phy.h"
-#include "ns3/wifi-remote-station-manager.h"
#include "ns3/wifi-channel.h"
-#include "ns3/yans-wifi-channel.h"
-#include "ns3/propagation-delay-model.h"
-#include "ns3/propagation-loss-model.h"
-#include "ns3/mobility-model.h"
-#include "ns3/log.h"
-#include "ns3/pcap-writer.h"
-#include "ns3/config.h"
-#include "ns3/simulator.h"
-#include "ns3/hwmp.h"
+#include "ns3/wifi-remote-station-manager.h"
+#include "ns3/mesh-wifi-interface-mac.h"
-NS_LOG_COMPONENT_DEFINE ("MeshWifiHelper");
namespace ns3 {
MeshWifiHelper::MeshWifiHelper ()
{
- //m_deviceFactory.SetTypeId ("ns3::L2RoutingNetDevice");
}
MeshWifiHelper::~MeshWifiHelper ()
{
}
-void
+ void
MeshWifiHelper::SetRemoteStationManager (std::string type,
std::string n0, const AttributeValue &v0,
std::string n1, const AttributeValue &v1,
@@ -71,16 +61,16 @@
m_stationManager.Set (n7, v7);
}
-void
+ void
MeshWifiHelper::SetMac (std::string type,
- std::string n0, const AttributeValue &v0,
- std::string n1, const AttributeValue &v1,
- std::string n2, const AttributeValue &v2,
- std::string n3, const AttributeValue &v3,
- std::string n4, const AttributeValue &v4,
- std::string n5, const AttributeValue &v5,
- std::string n6, const AttributeValue &v6,
- std::string n7, const AttributeValue &v7)
+ std::string n0, const AttributeValue &v0,
+ std::string n1, const AttributeValue &v1,
+ std::string n2, const AttributeValue &v2,
+ std::string n3, const AttributeValue &v3,
+ std::string n4, const AttributeValue &v4,
+ std::string n5, const AttributeValue &v5,
+ std::string n6, const AttributeValue &v6,
+ std::string n7, const AttributeValue &v7)
{
m_meshMac = ObjectFactory ();
m_meshMac.SetTypeId (type);
@@ -93,44 +83,18 @@
m_meshMac.Set (n6, v6);
m_meshMac.Set (n7, v7);
}
-
-void
-MeshWifiHelper::SetL2RoutingProtocol (std::string type,
- std::string n0, const AttributeValue &v0,
- std::string n1, const AttributeValue &v1,
- std::string n2, const AttributeValue &v2,
- std::string n3, const AttributeValue &v3,
- std::string n4, const AttributeValue &v4,
- std::string n5, const AttributeValue &v5,
- std::string n6, const AttributeValue &v6,
- std::string n7, const AttributeValue &v7,
- std::string n8, const AttributeValue &v8,
- std::string n9, const AttributeValue &v9)
-{
- m_routingProtocol = ObjectFactory ();
- m_routingProtocol.SetTypeId (type);
- m_routingProtocol.Set (n0, v0);
- m_routingProtocol.Set (n1, v1);
- m_routingProtocol.Set (n2, v2);
- m_routingProtocol.Set (n3, v3);
- m_routingProtocol.Set (n4, v4);
- m_routingProtocol.Set (n5, v5);
- m_routingProtocol.Set (n6, v6);
- m_routingProtocol.Set (n7, v7);
-}
-
-void
+ void
MeshWifiHelper::SetL2RoutingNetDevice (std::string type,
- std::string n0, const AttributeValue &v0,
- std::string n1, const AttributeValue &v1,
- std::string n2, const AttributeValue &v2,
- std::string n3, const AttributeValue &v3,
- std::string n4, const AttributeValue &v4,
- std::string n5, const AttributeValue &v5,
- std::string n6, const AttributeValue &v6,
- std::string n7, const AttributeValue &v7,
- std::string n8, const AttributeValue &v8,
- std::string n9, const AttributeValue &v9)
+ std::string n0, const AttributeValue &v0,
+ std::string n1, const AttributeValue &v1,
+ std::string n2, const AttributeValue &v2,
+ std::string n3, const AttributeValue &v3,
+ std::string n4, const AttributeValue &v4,
+ std::string n5, const AttributeValue &v5,
+ std::string n6, const AttributeValue &v6,
+ std::string n7, const AttributeValue &v7,
+ std::string n8, const AttributeValue &v8,
+ std::string n9, const AttributeValue &v9)
{
m_deviceFactory = ObjectFactory ();
m_deviceFactory.SetTypeId (type);
@@ -143,80 +107,38 @@
m_deviceFactory.Set (n6, v6);
m_deviceFactory.Set (n7, v7);
}
-
-void
-MeshWifiHelper::SetPeerLinkManager (std::string type,
- std::string n0, const AttributeValue &v0,
- std::string n1, const AttributeValue &v1,
- std::string n2, const AttributeValue &v2,
- std::string n3, const AttributeValue &v3,
- std::string n4, const AttributeValue &v4,
- std::string n5, const AttributeValue &v5,
- std::string n6, const AttributeValue &v6,
- std::string n7, const AttributeValue &v7,
- std::string n8, const AttributeValue &v8,
- std::string n9, const AttributeValue &v9)
+NetDeviceContainer
+MeshWifiHelper::Install (const WifiPhyHelper &phyHelper, NodeContainer c) const
{
- m_peerManager = ObjectFactory ();
- m_peerManager.SetTypeId (type);
- m_peerManager.Set (n0, v0);
- m_peerManager.Set (n1, v1);
- m_peerManager.Set (n2, v2);
- m_peerManager.Set (n3, v3);
- m_peerManager.Set (n4, v4);
- m_peerManager.Set (n5, v5);
- m_peerManager.Set (n6, v6);
- m_peerManager.Set (n7, v7);
- m_peerManager.Set (n8, v8);
- m_peerManager.Set (n9, v9);
+ NetDeviceContainer devices;
+ for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
+ {
+ Ptr<Node> node = *i;
+ Ptr<MeshPointDevice> mp = m_deviceFactory.Create<MeshPointDevice> ();
+ devices.Add (mp);
+ std::vector<Ptr<WifiNetDevice> > nodeDevices;
+ Ptr<WifiNetDevice> device = CreateObject<WifiNetDevice> ();
+ Ptr<MeshWifiInterfaceMac> mac = m_meshMac.Create<MeshWifiInterfaceMac> ();
+ Ptr<WifiRemoteStationManager> manager = m_stationManager.Create<WifiRemoteStationManager> ();
+ Ptr<WifiPhy> phy = phyHelper.Create (node, device);
+ mac->SetAddress (Mac48Address::Allocate ());
+ device->SetMac (mac);
+ device->SetPhy (phy);
+ device->SetRemoteStationManager (manager);
+ node->AddDevice (device);
+ nodeDevices.push_back (device);
+ node -> AddDevice (mp);
+ for (std::vector<Ptr<WifiNetDevice> > ::iterator iter=nodeDevices.begin ();iter != nodeDevices.end(); ++iter)
+ mp->AddInterface (*iter);
+ nodeDevices.clear ();
+ }
+ return devices;
}
NetDeviceContainer
-MeshWifiHelper::Install (const WifiPhyHelper &phyHelper, NodeContainer c, uint8_t numOfPorts) const
+MeshWifiHelper::Install (const WifiPhyHelper &phy, Ptr<Node> node) const
{
- NetDeviceContainer devices;
- for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
- {
- Ptr<Node> node = *i;
- Ptr<MeshPointDevice> mp = m_deviceFactory.Create<MeshPointDevice> ();
- Ptr<WifiPeerManager> pPeer = m_peerManager.Create<WifiPeerManager > ();
- devices.Add (mp);
- std::vector<Ptr<WifiNetDevice> > nodeDevices;
- for (uint8_t k = 0; k < numOfPorts; k++)
- {
- Ptr<WifiNetDevice> device = CreateObject<WifiNetDevice> ();
- Ptr<MeshWifiMac> mac = m_meshMac.Create<MeshWifiMac> ();
- Ptr<WifiRemoteStationManager> manager = m_stationManager.Create<WifiRemoteStationManager> ();
- Ptr<WifiPhy> phy = phyHelper.Create (node, device);
- mac->SetAddress (Mac48Address::Allocate ());
- device->SetMac (mac);
- device->SetPhy (phy);
- device->SetRemoteStationManager (manager);
- //create L2RoutingNetDevice and add WifiNetDevice to it
- node->AddDevice (device);
- nodeDevices.push_back (device);
- }
- node -> AddDevice (mp);
- for (std::vector<Ptr<WifiNetDevice> > ::iterator iter=nodeDevices.begin ();iter != nodeDevices.end(); ++iter)
- mp->AddInterface (*iter);
- // nodeDevice.pop_back ()
- pPeer->AttachPorts (nodeDevices);
-
- // Install routing protocol
- Ptr<MeshL2RoutingProtocol> routing = m_routingProtocol.Create <MeshL2RoutingProtocol> ();
- routing->SetMeshPoint (mp);
- mp->SetRoutingProtocol (routing);
-
- //hwmp->SetRoot (device->GetIfIndex(), Seconds(5));
- nodeDevices.clear ();
- }
- return devices;
-}
-
-NetDeviceContainer
-MeshWifiHelper::Install (const WifiPhyHelper &phy, Ptr<Node> node, uint8_t numOfPorts) const
-{
- return Install (phy, NodeContainer (node), numOfPorts);
+ return Install (phy, NodeContainer (node));
}
} //namespace ns3
--- a/src/devices/mesh/mesh-wifi-helper.h Thu Mar 19 11:49:23 2009 +0300
+++ b/src/devices/mesh/mesh-wifi-helper.h Thu Mar 19 12:46:56 2009 +0300
@@ -21,16 +21,10 @@
#ifndef _MESHWIFIHELPER_H
#define _MESHWIFIHELPER_H
-
-#include "ns3/wifi-net-device.h"
-#include "ns3/mesh-point-device.h"
-#include "ns3/mesh-wifi-mac.h"
-#include "ns3/wifi-channel.h"
-#include "ns3/mesh-wifi-peer-manager.h"
-#include "ns3/wifi-helper.h"
+#include "wifi-helper.h"
namespace ns3 {
-
+
class WifiChannel;
/**
@@ -39,88 +33,62 @@
*/
class MeshWifiHelper
{
-public:
- MeshWifiHelper ();
- virtual ~MeshWifiHelper ();
+ public:
+ MeshWifiHelper ();
+ virtual ~MeshWifiHelper ();
- /**
- * \param type the type of peer manager to use.
- * \param n0 the name of the attribute to set in the peer manager.
- * \param v0 the value of the attribute to set in the peer manager.
- * etc.
- *
- */
- void SetRemoteStationManager (std::string type,
- std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (),
- std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (),
- std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (),
- std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (),
- std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (),
- std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (),
- std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (),
- std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ());
-
- /**
- * \param type the type of ns3::WifiMac to create.
- * \param n0 the name of the attribute to set
- * \param v0 the value of the attribute to set
- *
- * All the attributes specified in this method should exist
- * in the requested mac.
- */
- void SetMac (std::string type,
- std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (),
- std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (),
- std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (),
- std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (),
- std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (),
- std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (),
- std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (),
- std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ());
+ /**
+ * \param type the type of peer manager to use.
+ * \param n0 the name of the attribute to set in the peer manager.
+ * \param v0 the value of the attribute to set in the peer manager.
+ * etc.
+ *
+ */
+ void SetRemoteStationManager (std::string type,
+ std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (),
+ std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (),
+ std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (),
+ std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (),
+ std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (),
+ std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (),
+ std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (),
+ std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()
+ );
- void SetPeerLinkManager (std::string type,
- std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (),
- std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (),
- std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (),
- std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (),
- std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (),
- std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (),
- std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (),
- std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue (),
- std::string n8 = "", const AttributeValue &v8 = EmptyAttributeValue (),
- std::string n9 = "", const AttributeValue &v9 = EmptyAttributeValue ());
- void SetL2RoutingProtocol (std::string type,
- std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (),
- std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (),
- std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (),
- std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (),
- std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (),
- std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (),
- std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (),
- std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue (),
- std::string n8 = "", const AttributeValue &v8 = EmptyAttributeValue (),
- std::string n9 = "", const AttributeValue &v9 = EmptyAttributeValue ());
-
- void SetL2RoutingNetDevice (std::string type,
- std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (),
- std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (),
- std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (),
- std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (),
- std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (),
- std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (),
- std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (),
- std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue (),
- std::string n8 = "", const AttributeValue &v8 = EmptyAttributeValue (),
- std::string n9 = "", const AttributeValue &v9 = EmptyAttributeValue ());
- NetDeviceContainer Install (const WifiPhyHelper &phyHelper, NodeContainer c, uint8_t numOfPorts) const;
- NetDeviceContainer Install (const WifiPhyHelper &phy, Ptr<Node> node, uint8_t numOfPorts) const;
-private:
- ObjectFactory m_stationManager;
- ObjectFactory m_meshMac;
- ObjectFactory m_peerManager;
- //L2routing:
- ObjectFactory m_deviceFactory;
- ObjectFactory m_routingProtocol;
+ /**
+ * \param type the type of ns3::WifiMac to create.
+ * \param n0 the name of the attribute to set
+ * \param v0 the value of the attribute to set
+ *
+ * All the attributes specified in this method should exist
+ * in the requested mac.
+ */
+ void SetMac (std::string type,
+ std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (),
+ std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (),
+ std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (),
+ std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (),
+ std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (),
+ std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (),
+ std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (),
+ std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()
+ );
+ void SetL2RoutingNetDevice (std::string type,
+ std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (),
+ std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (),
+ std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (),
+ std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (),
+ std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (),
+ std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (),
+ std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (),
+ std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue (),
+ );
+ NetDeviceContainer Install (const WifiPhyHelper &phyHelper, NodeContainer c) const;
+ NetDeviceContainer Install (const WifiPhyHelper &phy, Ptr<Node> node) const;
+ private:
+ ObjectFactory m_stationManager;
+ ObjectFactory m_meshMac;
+ ObjectFactory m_deviceFactory;
};
}//namespace ns3
#endif /* _MESHWIFIHELPER_H */
--- a/src/devices/mesh/mesh-wifi-interface-mac.cc Thu Mar 19 11:49:23 2009 +0300
+++ b/src/devices/mesh/mesh-wifi-interface-mac.cc Thu Mar 19 12:46:56 2009 +0300
@@ -401,6 +401,7 @@
Time
MeshWifiInterfaceMac::CalcSwDelay ()
{
+#if 0
UniformVariable coefficient (0.0, m_softwareDelay.GetSeconds());
// Be sure that frames don't change order due to different software delays
@@ -411,6 +412,8 @@
NS_ASSERT (delay.GetSeconds() >= 0);
return delay;
+#endif
+ return MicroSeconds(0);
}
void
@@ -439,6 +442,7 @@
Time randomStart = Seconds (coefficient.GetValue());
m_beaconSendEvent = Simulator::Schedule (randomStart, &MeshWifiInterfaceMac::SendBeacon, this);
+ m_tbtt = Simulator::Now() + randomStart;
}
else
// stop sending beacons
@@ -452,7 +456,7 @@
}
Time
-MeshWifiInterfaceMac::GetTBTT () const
+MeshWifiInterfaceMac::GetTbtt () const
{
return m_tbtt;
}
@@ -460,19 +464,19 @@
void MeshWifiInterfaceMac::ShiftTBTT (Time shift)
{
// User of ShiftTBTT () must take care don't shift it to the past
- NS_ASSERT (GetTBTT() + shift > Simulator::Now());
+ NS_ASSERT (GetTbtt() + shift > Simulator::Now());
m_tbtt += shift;
// Shift scheduled event
Simulator::Cancel (m_beaconSendEvent);
- m_beaconSendEvent = Simulator::Schedule (GetTBTT (), &MeshWifiInterfaceMac::SendBeacon, this);
+ m_beaconSendEvent = Simulator::Schedule (GetTbtt () - Simulator::Now(), &MeshWifiInterfaceMac::SendBeacon, this);
}
void
MeshWifiInterfaceMac::ScheduleNextBeacon ()
{
m_tbtt += GetBeaconInterval ();
- m_beaconSendEvent = Simulator::Schedule (GetTBTT (), &MeshWifiInterfaceMac::SendBeacon, this);
+ m_beaconSendEvent = Simulator::Schedule (GetBeaconInterval(), &MeshWifiInterfaceMac::SendBeacon, this);
}
void
@@ -482,7 +486,7 @@
NS_LOG_DEBUG (GetAddress() <<" is sending beacon");
NS_ASSERT (! m_beaconSendEvent.IsRunning());
- NS_ASSERT (Simulator::Now() == GetTBTT()); // assert that beacon is just on time
+ NS_ASSERT (Simulator::Now().GetMicroSeconds() == GetTbtt().GetMicroSeconds()); // assert that beacon is just on time
// Form & send beacon
MeshWifiBeacon beacon (GetSsid (), GetSupportedRates (), m_beaconInterval.GetMicroSeconds ());
@@ -507,7 +511,7 @@
packet->PeekHeader (beacon_hdr);
- NS_LOG_DEBUG ("Beacon received from "<<hdr->GetAddr2()<<
+ NS_LOG_UNCOND ("Beacon received from "<<hdr->GetAddr2()<<
" to "<<GetAddress ()<<
" at "<<Simulator::Now ().GetMicroSeconds ()<<
" microseconds");
--- a/src/devices/mesh/mesh-wifi-interface-mac.h Thu Mar 19 11:49:23 2009 +0300
+++ b/src/devices/mesh/mesh-wifi-interface-mac.h Thu Mar 19 12:46:56 2009 +0300
@@ -106,7 +106,7 @@
*
* This is supposed to be used by any entity managing beacon collision avoidance (e.g. Peer management protocol in 802.11s)
*/
- Time GetTBTT () const;
+ Time GetTbtt () const;
/**
* \brief Shift TBTT.
*