diff --git a/src/devices/wifi/wscript b/src/devices/wifi/wscript index 7c4d085af..182260407 100644 --- a/src/devices/wifi/wscript +++ b/src/devices/wifi/wscript @@ -36,10 +36,10 @@ def build(bld): 'onoe-wifi-manager.cc', 'rraa-wifi-manager.cc', 'constant-rate-wifi-manager.cc', - 'wifi-helper.cc', ] headers = bld.create_obj('ns3header') headers.source = [ + 'propagation-delay-model.h', 'propagation-loss-model.h', 'wifi-net-device.h', 'wifi-channel.h', @@ -62,5 +62,4 @@ def build(bld): 'nqsta-wifi-mac.h', 'nqap-wifi-mac.h', 'wifi-phy.h', - 'wifi-helper.h', ] diff --git a/src/devices/csma/csma-helper.cc b/src/helper/csma-helper.cc similarity index 59% rename from src/devices/csma/csma-helper.cc rename to src/helper/csma-helper.cc index 66aea8ba7..bd4723b26 100644 --- a/src/devices/csma/csma-helper.cc +++ b/src/helper/csma-helper.cc @@ -1,12 +1,17 @@ #include "csma-helper.h" +#include "ns3/object-factory.h" +#include "ns3/queue.h" +#include "ns3/csma-net-device.h" +#include "ns3/csma-channel.h" +#include namespace ns3 { CsmaHelper::CsmaHelper () { - m_queueFactory.SetTypeId ("DropTailQueue"); - m_deviceFactory.SetTypeId ("CsmaNetDevice"); - m_deviceChannel.SetTypeId ("CsmaChannel"); + m_queueFactory.SetTypeId ("ns3::DropTailQueue"); + m_deviceFactory.SetTypeId ("ns3::CsmaNetDevice"); + m_channelFactory.SetTypeId ("ns3::CsmaChannel"); } void @@ -23,10 +28,6 @@ CsmaHelper::SetQueue (std::string type, m_queueFactory.Set (n4, v4); } - /** - * Set these parameters on each PointToPointNetDevice created - * by this helper. - */ void CsmaHelper::SetDeviceParameter (std::string n1, Attribute v1) { @@ -36,7 +37,7 @@ CsmaHelper::SetDeviceParameter (std::string n1, Attribute v1) void CsmaHelper::SetChannelParameter (std::string n1, Attribute v1) { - m_csmaFactory.Set (n1, v1); + m_channelFactory.Set (n1, v1); } NetDeviceContainer @@ -49,10 +50,18 @@ CsmaHelper::Build (const NodeContainer &c) NetDeviceContainer CsmaHelper::Build (const NodeContainer &c, Ptr channel) { + NetDeviceContainer container; for (NodeContainer::Iterator i = c.Begin (); i != c.End (); i++) { - + Ptr node = *i; + Ptr device = m_deviceFactory.Create (); + node->AddDevice (device); + Ptr queue = m_queueFactory.Create (); + device->AddQueue (queue); + device->Attach (channel); + container.Add (device); } + return container; } diff --git a/src/devices/csma/csma-helper.h b/src/helper/csma-helper.h similarity index 82% rename from src/devices/csma/csma-helper.h rename to src/helper/csma-helper.h index 267ca0170..e553d5a15 100644 --- a/src/devices/csma/csma-helper.h +++ b/src/helper/csma-helper.h @@ -1,6 +1,13 @@ #ifndef CSMA_HELPER_H #define CSMA_HELPER_H +#include +#include "ns3/attribute.h" +#include "ns3/object-factory.h" +#include "ns3/net-device-container.h" +#include "ns3/node-container.h" +#include "ns3/csma-channel.h" + namespace ns3 { class CsmaHelper diff --git a/src/mobility/mobility-helper.cc b/src/helper/mobility-helper.cc similarity index 95% rename from src/mobility/mobility-helper.cc rename to src/helper/mobility-helper.cc index 32667c82d..323d85ddc 100644 --- a/src/mobility/mobility-helper.cc +++ b/src/helper/mobility-helper.cc @@ -1,8 +1,8 @@ -#include "mobility-helper.h" -#include "mobility-model.h" -#include "mobility-model-notifier.h" -#include "position-allocator.h" -#include "hierarchical-mobility-model.h" +#include "ns3/mobility-helper.h" +#include "ns3/mobility-model.h" +#include "ns3/mobility-model-notifier.h" +#include "ns3/position-allocator.h" +#include "ns3/hierarchical-mobility-model.h" #include "ns3/log.h" namespace ns3 { diff --git a/src/mobility/mobility-helper.h b/src/helper/mobility-helper.h similarity index 100% rename from src/mobility/mobility-helper.h rename to src/helper/mobility-helper.h diff --git a/src/node/net-device-container.cc b/src/helper/net-device-container.cc similarity index 100% rename from src/node/net-device-container.cc rename to src/helper/net-device-container.cc diff --git a/src/node/net-device-container.h b/src/helper/net-device-container.h similarity index 95% rename from src/node/net-device-container.h rename to src/helper/net-device-container.h index e90192067..11297c4da 100644 --- a/src/node/net-device-container.h +++ b/src/helper/net-device-container.h @@ -3,7 +3,7 @@ #include #include -#include "net-device.h" +#include "ns3/net-device.h" namespace ns3 { diff --git a/src/node/node-container.cc b/src/helper/node-container.cc similarity index 100% rename from src/node/node-container.cc rename to src/helper/node-container.cc diff --git a/src/node/node-container.h b/src/helper/node-container.h similarity index 96% rename from src/node/node-container.h rename to src/helper/node-container.h index 35f14fcc3..6ab334c13 100644 --- a/src/node/node-container.h +++ b/src/helper/node-container.h @@ -3,7 +3,7 @@ #include #include -#include "node.h" +#include "ns3/node.h" namespace ns3 { diff --git a/src/routing/olsr/olsr-helper.cc b/src/helper/olsr-helper.cc similarity index 97% rename from src/routing/olsr/olsr-helper.cc rename to src/helper/olsr-helper.cc index 952b1ae59..f7b475362 100644 --- a/src/routing/olsr/olsr-helper.cc +++ b/src/helper/olsr-helper.cc @@ -1,5 +1,5 @@ #include "olsr-helper.h" -#include "olsr-agent.h" +#include "ns3/olsr-agent.h" #include "ns3/node-list.h" namespace ns3 { diff --git a/src/routing/olsr/olsr-helper.h b/src/helper/olsr-helper.h similarity index 100% rename from src/routing/olsr/olsr-helper.h rename to src/helper/olsr-helper.h diff --git a/src/devices/point-to-point/point-to-point-helper.cc b/src/helper/point-to-point-helper.cc similarity index 69% rename from src/devices/point-to-point/point-to-point-helper.cc rename to src/helper/point-to-point-helper.cc index 71283d949..33f34979d 100644 --- a/src/devices/point-to-point/point-to-point-helper.cc +++ b/src/helper/point-to-point-helper.cc @@ -1,6 +1,6 @@ #include "point-to-point-helper.h" -#include "point-to-point-net-device.h" -#include "point-to-point-channel.h" +#include "ns3/point-to-point-net-device.h" +#include "ns3/point-to-point-channel.h" #include "ns3/queue.h" namespace ns3 { @@ -23,6 +23,19 @@ PointToPointHelper::SetQueue (std::string type, m_queueFactory.Set (n4, v4); } +void +PointToPointHelper::SetDeviceParameter (std::string n1, Attribute v1) +{ + m_deviceFactory.Set (n1, v1); +} + +void +PointToPointHelper::SetChannelParameter (std::string n1, Attribute v1) +{ + m_channelFactory.Set (n1, v1); +} + + NetDeviceContainer PointToPointHelper::Build (NodeContainer c) { @@ -34,11 +47,13 @@ PointToPointHelper::Build (Ptr a, Ptr b) { NetDeviceContainer container; - Ptr devA = CreateObject (a); - Ptr queueA = m_queueFactory.Create ()->GetObject (); + Ptr devA = CreateObject (); + a->AddDevice (devA); + Ptr queueA = m_queueFactory.Create (); devA->AddQueue (queueA); - Ptr devB = CreateObject (b); - Ptr queueB = m_queueFactory.Create ()->GetObject (); + Ptr devB = CreateObject (); + b->AddDevice (devB); + Ptr queueB = m_queueFactory.Create (); devB->AddQueue (queueB); Ptr channel = CreateObject (); devA->Attach (channel); diff --git a/src/devices/point-to-point/point-to-point-helper.h b/src/helper/point-to-point-helper.h similarity index 70% rename from src/devices/point-to-point/point-to-point-helper.h rename to src/helper/point-to-point-helper.h index 0d935c3f5..25e7e23c8 100644 --- a/src/devices/point-to-point/point-to-point-helper.h +++ b/src/helper/point-to-point-helper.h @@ -20,20 +20,16 @@ public: std::string n3 = "", Attribute v3 = Attribute (), std::string n4 = "", Attribute v4 = Attribute ()); - /** - * Set these parameters on each PointToPointNetDevice created - * by this helper. - */ - void SetDeviceParameters (std::string n1, Attribute v1, - std::string n2 = "", Attribute v2 = Attribute (), - std::string n3 = "", Attribute v3 = Attribute (), - std::string n4 = "", Attribute v4 = Attribute ()); + void SetDeviceParameter (std::string name, Attribute value); + void SetChannelParameter (std::string name, Attribute value); NetDeviceContainer Build (NodeContainer c); NetDeviceContainer Build (Ptr a, Ptr b); private: ObjectFactory m_queueFactory; + ObjectFactory m_channelFactory; + ObjectFactory m_deviceFactory; }; diff --git a/src/devices/wifi/wifi-helper.cc b/src/helper/wifi-helper.cc similarity index 93% rename from src/devices/wifi/wifi-helper.cc rename to src/helper/wifi-helper.cc index 4a0d5a616..d9b990574 100644 --- a/src/devices/wifi/wifi-helper.cc +++ b/src/helper/wifi-helper.cc @@ -1,11 +1,11 @@ #include "wifi-helper.h" -#include "wifi-net-device.h" -#include "wifi-mac.h" -#include "wifi-phy.h" -#include "wifi-remote-station-manager.h" -#include "wifi-channel.h" -#include "propagation-delay-model.h" -#include "propagation-loss-model.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/propagation-delay-model.h" +#include "ns3/propagation-loss-model.h" #include "ns3/mobility-model.h" #include "ns3/log.h" diff --git a/src/devices/wifi/wifi-helper.h b/src/helper/wifi-helper.h similarity index 100% rename from src/devices/wifi/wifi-helper.h rename to src/helper/wifi-helper.h diff --git a/src/helper/wscript b/src/helper/wscript new file mode 100644 index 000000000..4e5b2a73e --- /dev/null +++ b/src/helper/wscript @@ -0,0 +1,24 @@ +## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- + +def build(bld): + helper = bld.create_ns3_module('helper', ['internet-node', 'wifi', 'point-to-point', 'csma', 'olsr', 'global-routing', 'onoff', 'packet-sink', 'udp-echo']) + helper.source = [ + 'node-container.cc', + 'net-device-container.cc', + 'wifi-helper.cc', + 'olsr-helper.cc', + 'point-to-point-helper.cc', + 'csma-helper.cc', + 'mobility-helper.cc', + ] + + headers = bld.create_obj('ns3header') + headers.source = [ + 'node-container.h', + 'net-device-container.h', + 'wifi-helper.h', + 'olsr-helper.h', + 'point-to-point-helper.h', + 'csma-helper.h', + 'mobility-helper.h', + ] diff --git a/src/mobility/wscript b/src/mobility/wscript index 9b216ba2a..b66f8777c 100644 --- a/src/mobility/wscript +++ b/src/mobility/wscript @@ -16,7 +16,6 @@ def build(bld): 'random-walk-2d-mobility-model.cc', 'random-direction-2d-mobility-model.cc', 'ns2-mobility-helper.cc', - 'mobility-helper.cc', ] headers = bld.create_obj('ns3header') @@ -34,5 +33,4 @@ def build(bld): 'random-walk-2d-mobility-model.h', 'random-direction-2d-mobility-model.h', 'ns2-mobility-helper.h', - 'mobility-helper.h', ] diff --git a/src/node/wscript b/src/node/wscript index ea91bd1b6..893659fb9 100644 --- a/src/node/wscript +++ b/src/node/wscript @@ -28,8 +28,6 @@ def build(bld): 'tcp.cc', 'ipv4.cc', 'application.cc', - 'node-container.cc', - 'net-device-container.cc', ] headers = bld.create_obj('ns3header') @@ -58,6 +56,4 @@ def build(bld): 'tcp.h', 'ipv4.h', 'application.h', - 'node-container.h', - 'net-device-container.h', ] diff --git a/src/routing/olsr/wscript b/src/routing/olsr/wscript index 30515ce48..735801952 100644 --- a/src/routing/olsr/wscript +++ b/src/routing/olsr/wscript @@ -9,13 +9,11 @@ def build(bld): 'routing-table.cc', 'olsr-agent.cc', 'olsr-agent-impl.cc', - 'olsr-helper.cc', ] headers = bld.create_obj('ns3header') headers.source = [ 'olsr-agent.h', 'olsr-header.h', - 'olsr-helper.h', ] diff --git a/src/wscript b/src/wscript index a6150792f..0b41d7d6c 100644 --- a/src/wscript +++ b/src/wscript @@ -26,6 +26,7 @@ all_modules = ( 'routing/global-routing', 'mobility', 'devices/wifi', + 'helper', ) def set_options(opt):