--- a/examples/mesh.cc Wed Apr 01 16:14:05 2009 +0400
+++ b/examples/mesh.cc Wed Apr 01 18:05:36 2009 +0400
@@ -38,43 +38,36 @@
int
main (int argc, char *argv[])
{
- // Creating square topology with nNodes x nNodes grid:
- int xSize =6;
+ // Creating square topology with nNodes x nNodes grid
+ int xSize = 6;
int ySize = 6;
double step = 100.0; //Grid with one-hop edge
- double randomStart = 0.1; //One beacon interval
- NodeContainer nodes;
- CommandLine cmd;
- MobilityHelper mobility;
- MeshWifiHelper wifi;
- NetDeviceContainer meshDevices;
- // Defining a size of our network:
+ double randomStart = 0.1; //One beacon interval
+
+ // Defining a size of our network
+ CommandLine cmd;
cmd.AddValue ("x-size", "Number of nodes in a row grid", xSize);
cmd.AddValue ("y-size", "Number of rows in a grid", ySize);
cmd.AddValue ("step", "Size of edge in our grid", step);
cmd.AddValue ("start", "Random start parameter", randomStart);
cmd.Parse (argc, argv);
- NS_LOG_DEBUG ("Grid:"<<xSize<<"*"<<ySize);
- // Creating nodes:
+ NS_LOG_DEBUG ("Grid:" << xSize << "*" << ySize);
+
+ // Creating nodes
+ NodeContainer nodes;
nodes.Create (ySize*xSize);
- // Setting channel:
+ // Setting channel
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
wifiPhy.SetChannel (wifiChannel.Create ());
- // Setting Wifi:
- //wifi.SetPhy ("ns3::WifiPhy");
- wifi.SetRemoteStationManager ("ns3::AarfWifiManager");
- Ssid ssid = Ssid ("MyMeSH");
- wifi.SetMac ("ns3::MeshWifiInterfaceMac",
- "Ssid", SsidValue (ssid),
- "RandomStart", TimeValue (Seconds (randomStart))
- );
- wifi.SetRouting("ns3::dot11s::HwmpProtocol");
- wifi.SetPeerManager("ns3::dot11s::PeerManagementProtocol");
- wifi.SetL2RoutingNetDevice ("ns3::MeshPointDevice");
- meshDevices = wifi.Install (wifiPhy,nodes);
- // Installing Mobility.
+
+ // Install mesh point devices & protocols
+ MeshWifiHelper mesh;
+ NetDeviceContainer meshDevices = mesh.Install (wifiPhy, nodes);
+
+ // Setup mobility
+ MobilityHelper mobility;
mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
"MinX", DoubleValue (0.0),
"MinY", DoubleValue (0.0),
@@ -84,13 +77,17 @@
"LayoutType", StringValue ("RowFirst"));
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.Install (nodes);
+
NS_LOG_UNCOND("start");
- // Setting Internet Stack:
+
+ // Install internet stack
InternetStackHelper stack;
stack.Install (nodes);
Ipv4AddressHelper address;
address.SetBase ("10.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer interfaces = address.Assign (meshDevices);
+
+ // Install applications
UdpEchoServerHelper echoServer (9);
ApplicationContainer serverApps = echoServer.Install (nodes.Get (0));
serverApps.Start (Seconds (1.0));
@@ -102,7 +99,8 @@
ApplicationContainer clientApps = echoClient.Install (nodes.Get (1));
clientApps.Start (Seconds (2.0));
clientApps.Stop (Seconds (10.0));
- //end
+
+ // Happy end
Simulator::Stop (Seconds (10.0));
Simulator::Run ();
Simulator::Destroy ();
--- a/src/devices/mesh/dot11s/dot11s-helper.cc Wed Apr 01 16:14:05 2009 +0400
+++ b/src/devices/mesh/dot11s/dot11s-helper.cc Wed Apr 01 18:05:36 2009 +0400
@@ -28,172 +28,87 @@
#include "ns3/wifi-channel.h"
#include "ns3/wifi-remote-station-manager.h"
#include "ns3/mesh-wifi-interface-mac.h"
+#include "ns3/aarf-wifi-manager.h"
namespace ns3 {
namespace dot11s {
-MeshWifiHelper::MeshWifiHelper ()
+MeshWifiHelper::MeshWifiHelper () : m_ssid("Mesh"), m_randomStartDelay (Seconds (0))
{
}
-
-MeshWifiHelper::~MeshWifiHelper ()
+
+void MeshWifiHelper::SetSsid (Ssid const & s)
{
+ m_ssid = s;
}
- void
-MeshWifiHelper::SetRemoteStationManager (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)
+void MeshWifiHelper::SetRandomStartDelay (Time t)
{
- m_stationManager = ObjectFactory ();
- m_stationManager.SetTypeId (type);
- m_stationManager.Set (n0, v0);
- m_stationManager.Set (n1, v1);
- m_stationManager.Set (n2, v2);
- m_stationManager.Set (n3, v3);
- m_stationManager.Set (n4, v4);
- m_stationManager.Set (n5, v5);
- m_stationManager.Set (n6, v6);
- m_stationManager.Set (n7, v7);
+ m_randomStartDelay = t;
}
- 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)
+Ptr<WifiNetDevice> MeshWifiHelper::CreateInterface (const WifiPhyHelper &phyHelper, Ptr<Node> node) const
{
- m_meshMac = ObjectFactory ();
- m_meshMac.SetTypeId (type);
- m_meshMac.Set (n0, v0);
- m_meshMac.Set (n1, v1);
- m_meshMac.Set (n2, v2);
- m_meshMac.Set (n3, v3);
- m_meshMac.Set (n4, v4);
- m_meshMac.Set (n5, v5);
- m_meshMac.Set (n6, v6);
- m_meshMac.Set (n7, v7);
-}
-void
-MeshWifiHelper::SetPeerManager (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)
-{
- m_peerMan = ObjectFactory ();
- m_peerMan.SetTypeId (type);
- m_peerMan.Set (n0, v0);
- m_peerMan.Set (n1, v1);
- m_peerMan.Set (n2, v2);
- m_peerMan.Set (n3, v3);
- m_peerMan.Set (n4, v4);
- m_peerMan.Set (n5, v5);
- m_peerMan.Set (n6, v6);
- m_peerMan.Set (n7, v7);
+ Ptr<WifiNetDevice> device = CreateObject<WifiNetDevice> ();
+
+ // Creating MAC for this interface
+ Ptr<MeshWifiInterfaceMac> mac = CreateObject<MeshWifiInterfaceMac> ();
+ mac->SetSsid (m_ssid);
+ if (m_randomStartDelay > Seconds (0))
+ mac->SetRandomStartDelay (m_randomStartDelay);
+ Ptr<WifiRemoteStationManager> manager = CreateObject<AarfWifiManager> ();
+ Ptr<WifiPhy> phy = phyHelper.Create (node, device);
+ mac->SetAddress (Mac48Address::Allocate ());
+ device->SetMac (mac);
+ device->SetPhy (phy);
+ device->SetRemoteStationManager (manager);
+
+ return device;
}
-void
-MeshWifiHelper::SetRouting (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)
-{
- m_routing = ObjectFactory ();
- m_routing.SetTypeId (type);
- m_routing.Set (n0, v0);
- m_routing.Set (n1, v1);
- m_routing.Set (n2, v2);
- m_routing.Set (n3, v3);
- m_routing.Set (n4, v4);
- m_routing.Set (n5, v5);
- m_routing.Set (n6, v6);
- m_routing.Set (n7, v7);
-}
-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
- )
-{
- m_deviceFactory = ObjectFactory ();
- m_deviceFactory.SetTypeId (type);
- m_deviceFactory.Set (n0, v0);
- m_deviceFactory.Set (n1, v1);
- m_deviceFactory.Set (n2, v2);
- m_deviceFactory.Set (n3, v3);
- m_deviceFactory.Set (n4, v4);
- m_deviceFactory.Set (n5, v5);
- m_deviceFactory.Set (n6, v6);
- m_deviceFactory.Set (n7, v7);
-}
+
NetDeviceContainer
-MeshWifiHelper::Install (const WifiPhyHelper &phyHelper, NodeContainer c) const
+MeshWifiHelper::Install (const WifiPhyHelper &phyHelper, NodeContainer c, uint32_t nInterfaces) const
{
NetDeviceContainer devices;
+
for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
{
Ptr<Node> node = *i;
- // Create a mesh point device:
- Ptr<MeshPointDevice> mp = m_deviceFactory.Create<MeshPointDevice> ();
- std::vector<Ptr<NetDevice> > mpInterfacess;
- // Creating interface:
- {
- Ptr<WifiNetDevice> device = CreateObject<WifiNetDevice> ();
- //Creating MAC for this interface
- 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);
- mpInterfacess.push_back (device);
- }
- node -> AddDevice (mp);
- for (std::vector<Ptr<NetDevice> > ::iterator iter=mpInterfacess.begin ();iter != mpInterfacess.end(); ++iter)
- mp->AddInterface (*iter);
- mpInterfacess.clear ();
- //Install protocols:
- Ptr<PeerManagementProtocol> peer = m_peerMan.Create<PeerManagementProtocol> ();
- NS_ASSERT(peer->Install(mp));
- Ptr<HwmpProtocol> hwmp = m_routing.Create<HwmpProtocol> ();
- peer->SetPeerLinkStatusCallback(MakeCallback(&HwmpProtocol::PeerLinkStatus, hwmp));
- hwmp->SetNeighboursCallback(MakeCallback(&PeerManagementProtocol::GetActiveLinks, peer));
- NS_ASSERT(hwmp->Install(mp));
+
+ // Create a mesh point device
+ Ptr<MeshPointDevice> mp = CreateObject<MeshPointDevice> ();
+ node->AddDevice (mp);
+
+ // Create wifi interfaces (single interface by default)
+ for (uint32_t i = 0; i < nInterfaces; ++i)
+ {
+ Ptr<WifiNetDevice> iface = CreateInterface (phyHelper, node);
+
+ node->AddDevice (iface);
+ mp->AddInterface (iface);
+ }
+
+ // Install 802.11s protocols
+ Ptr<PeerManagementProtocol> pmp = CreateObject<PeerManagementProtocol> ();
+ bool pmp_ok = pmp->Install (mp);
+ NS_ASSERT (pmp_ok);
+
+ Ptr<HwmpProtocol> hwmp = CreateObject<HwmpProtocol> ();
+ bool hwmp_ok = hwmp->Install (mp);
+ NS_ASSERT (hwmp_ok);
+
+ pmp->SetPeerLinkStatusCallback(MakeCallback(&HwmpProtocol::PeerLinkStatus, hwmp));
+ hwmp->SetNeighboursCallback(MakeCallback(&PeerManagementProtocol::GetActiveLinks, pmp));
+
+ mp->SetRoutingProtocol (hwmp);
+
devices.Add (mp);
}
return devices;
}
NetDeviceContainer
-MeshWifiHelper::Install (const WifiPhyHelper &phy, Ptr<Node> node) const
+MeshWifiHelper::Install (const WifiPhyHelper &phy, Ptr<Node> node, uint32_t nInterfaces) const
{
return Install (phy, NodeContainer (node));
}
--- a/src/devices/mesh/dot11s/dot11s-helper.h Wed Apr 01 16:14:05 2009 +0400
+++ b/src/devices/mesh/dot11s/dot11s-helper.h Wed Apr 01 18:05:36 2009 +0400
@@ -16,12 +16,16 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Kirill Andreev <andreev@iitp.ru>
+ * Pavel Boyko <boyko@iitp.ru>
*/
#ifndef _MESHWIFIHELPER_H
#define _MESHWIFIHELPER_H
+
#include "ns3/wifi-helper.h"
+#include "ns3/ssid.h"
+#include "ns3/nstime.h"
#include "ns3/peer-management-protocol.h"
#include "ns3/hwmp-protocol.h"
@@ -33,89 +37,44 @@
/**
* \ingroup dot11s
*
+ * \brief Helper to create IEEE 802.11s mesh networks
*/
class 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 ()
- );
- void SetPeerManager (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 SetRouting (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_peerMan;
- ObjectFactory m_routing;
- ObjectFactory m_deviceFactory;
+public:
+ MeshWifiHelper ();
+ /// Set mesh SSID
+ void SetSsid (const Ssid &);
+ /// Set maximum random start delay
+ void SetRandomStartDelay (Time delay);
+ /**
+ * \brief Install 802.11s mesh device & protocols on given node
+ *
+ * \param phy Wifi PHY helper
+ * \param nodes List of nodes to install
+ * \param nInterfaces Number of mesh point radio interfaces (= WiFi NICs)
+ *
+ * \return list of created mesh point devices, see MeshPointDevice
+ */
+ NetDeviceContainer Install (const WifiPhyHelper &phyHelper, NodeContainer c, uint32_t nInterfaces = 1) const;
+ /**
+ * \brief Install 802.11s mesh device & protocols on given node
+ *
+ * \param phy Wifi PHY helper
+ * \param node Node to install
+ * \param nInterfaces Number of mesh point radio interfaces (= WiFi NICs)
+ *
+ * \return list of created mesh point devices, see MeshPointDevice
+ */
+ NetDeviceContainer Install (const WifiPhyHelper &phy, Ptr<Node> node, uint32_t nInterfaces = 1) const;
+
+private:
+ Ssid m_ssid;
+ Time m_randomStartDelay;
+
+ /// Create single mesh interface NIC
+ Ptr<WifiNetDevice> CreateInterface (const WifiPhyHelper &phyHelper, Ptr<Node> node) const;
+
};
} // namespace dot11s
} //namespace ns3
--- a/src/devices/mesh/mesh-wifi-interface-mac.cc Wed Apr 01 16:14:05 2009 +0400
+++ b/src/devices/mesh/mesh-wifi-interface-mac.cc Wed Apr 01 18:05:36 2009 +0400
@@ -401,6 +401,13 @@
//-----------------------------------------------------------------------------
// Beacons
//-----------------------------------------------------------------------------
+void
+MeshWifiInterfaceMac::SetRandomStartDelay (Time interval)
+{
+ NS_LOG_FUNCTION (this << interval);
+ m_randomStart = interval;
+}
+
void
MeshWifiInterfaceMac::SetBeaconInterval (Time interval)
{
--- a/src/devices/mesh/mesh-wifi-interface-mac.h Wed Apr 01 16:14:05 2009 +0400
+++ b/src/devices/mesh/mesh-wifi-interface-mac.h Wed Apr 01 18:05:36 2009 +0400
@@ -94,6 +94,8 @@
///\name Beacons
//\{
+ /// Set maximum initial random delay before first beacon
+ void SetRandomStartDelay (Time interval);
/// Set interval between two successive beacons
void SetBeaconInterval (Time interval);
/// \return interval between two beacons