From 29f19e164e6b807d1b0c58f56cfdedd92afd858a Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Mon, 24 Mar 2008 10:14:35 -0700 Subject: [PATCH 01/12] doxygen. --- src/helper/net-device-container.cc | 14 ++++++------- src/helper/net-device-container.h | 32 +++++++++++++++++++++++++++--- 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/src/helper/net-device-container.cc b/src/helper/net-device-container.cc index 9bde8226c..65509960c 100644 --- a/src/helper/net-device-container.cc +++ b/src/helper/net-device-container.cc @@ -5,36 +5,36 @@ namespace ns3 { NetDeviceContainer::Iterator NetDeviceContainer::Begin (void) const { - return m_nodes.begin (); + return m_devices.begin (); } NetDeviceContainer::Iterator NetDeviceContainer::End (void) const { - return m_nodes.end (); + return m_devices.end (); } uint32_t NetDeviceContainer::GetN (void) const { - return m_nodes.size (); + return m_devices.size (); } Ptr NetDeviceContainer::Get (uint32_t i) const { - return m_nodes[i]; + return m_devices[i]; } void NetDeviceContainer::Add (NetDeviceContainer other) { for (Iterator i = other.Begin (); i != other.End (); i++) { - m_nodes.push_back (*i); + m_devices.push_back (*i); } } void -NetDeviceContainer::Add (Ptr node) +NetDeviceContainer::Add (Ptr device) { - m_nodes.push_back (node); + m_devices.push_back (device); } } // namespace ns3 diff --git a/src/helper/net-device-container.h b/src/helper/net-device-container.h index 11297c4da..cf9a690aa 100644 --- a/src/helper/net-device-container.h +++ b/src/helper/net-device-container.h @@ -7,23 +7,49 @@ namespace ns3 { +/** + * \brief holds a vector of ns3::NetDevice pointers + * + */ class NetDeviceContainer { public: typedef std::vector >::const_iterator Iterator; + /** + * \returns an iterator which points to the start of the array of pointers. + */ Iterator Begin (void) const; + /** + * \returns an iterator which points to the end of the array of pointers. + */ Iterator End (void) const; + /** + * \returns the number of netdevice pointers stored in this container. + */ uint32_t GetN (void) const; + /** + * \param i the index of the requested netdevice pointer. + * \returns the requested netdevice pointer. + */ Ptr Get (uint32_t i) const; - void Create (uint32_t n); + /** + * \param other another netdevice container + * + * Append to the end of this container the other input container. + */ void Add (NetDeviceContainer other); - void Add (Ptr node); + /** + * \param device another netdevice pointer. + * + * Append to the end of this container the input netdevice pointer. + */ + void Add (Ptr device); private: - std::vector > m_nodes; + std::vector > m_devices; }; } // namespace ns3 From 4e5eab77e2eb3d62fcef17b699990f9d5bd7993e Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Mon, 24 Mar 2008 10:41:44 -0700 Subject: [PATCH 02/12] add NodeContainer::GetGlobal --- src/helper/node-container.cc | 12 ++++++++++++ src/helper/node-container.h | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/src/helper/node-container.cc b/src/helper/node-container.cc index a4b8237bc..2d9722016 100644 --- a/src/helper/node-container.cc +++ b/src/helper/node-container.cc @@ -1,4 +1,5 @@ #include "node-container.h" +#include "ns3/node-list.h" namespace ns3 { @@ -58,4 +59,15 @@ NodeContainer::Add (Ptr node) m_nodes.push_back (node); } +NodeContainer +NodeContainer::GetGlobal (void) +{ + NodeContainer c; + for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i) + { + c.Add (*i); + } + return c; +} + } // namespace ns3 diff --git a/src/helper/node-container.h b/src/helper/node-container.h index 677c2095e..1c99fe55d 100644 --- a/src/helper/node-container.h +++ b/src/helper/node-container.h @@ -74,6 +74,13 @@ public: */ void Add (Ptr node); + /** + * \returns a container which contains a list of _all_ nodes + * created through NodeContainer::Create and stored + * in ns3::NodeList. + */ + static NodeContainer GetGlobal (void); + private: std::vector > m_nodes; }; From 35d9ec1c8e137b4f83a8bcfc1d8d71a5460d1168 Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Mon, 24 Mar 2008 10:42:18 -0700 Subject: [PATCH 03/12] change signature of MobilityHelper::Layout and MobilityHelper::LayoutAll. --- examples/wifi-adhoc.cc | 2 +- examples/wifi-ap.cc | 4 ++-- samples/main-grid-topology.cc | 15 ++++++--------- samples/main-random-topology.cc | 9 +++------ samples/main-random-walk.cc | 8 +++----- src/helper/mobility-helper.cc | 10 ++++++++-- src/helper/mobility-helper.h | 28 +++++++--------------------- 7 files changed, 30 insertions(+), 46 deletions(-) diff --git a/examples/wifi-adhoc.cc b/examples/wifi-adhoc.cc index dcfd026ce..987757cad 100644 --- a/examples/wifi-adhoc.cc +++ b/examples/wifi-adhoc.cc @@ -142,7 +142,7 @@ Experiment::Run (const WifiHelper &wifi) mobility.SetPositionAllocator (positionAlloc); mobility.SetMobilityModel ("ns3::StaticMobilityModel"); - mobility.Layout (c.Begin (), c.End ()); + mobility.Layout (c); PacketSocketAddress destination = PacketSocketAddress (); destination.SetProtocol (1); diff --git a/examples/wifi-ap.cc b/examples/wifi-ap.cc index 9c3bcbade..4634cc6df 100644 --- a/examples/wifi-ap.cc +++ b/examples/wifi-ap.cc @@ -161,8 +161,8 @@ int main (int argc, char *argv[]) wifi.Build (ap, channel); // mobility. - mobility.Layout (stas.Begin (), stas.End ()); - mobility.Layout (ap.Begin (), ap.End ()); + mobility.Layout (stas); + mobility.Layout (ap); Simulator::Schedule (Seconds (1.0), &AdvancePosition, ap.Get (0)); diff --git a/samples/main-grid-topology.cc b/samples/main-grid-topology.cc index 88406210c..ba2d24b97 100644 --- a/samples/main-grid-topology.cc +++ b/samples/main-grid-topology.cc @@ -16,13 +16,10 @@ int main (int argc, char *argv[]) CommandLine cmd; cmd.Parse (argc, argv); - std::vector > nodes; + NodeContainer nodes; // create an array of empty nodes for testing purposes - for (uint32_t i = 0; i < 120; i++) - { - nodes.push_back (CreateObject ()); - } + nodes.Create (120); MobilityHelper mobility; // setup the grid itself: objects are layed out @@ -44,13 +41,13 @@ int main (int argc, char *argv[]) // finalize the setup by attaching to each object // in the input array a position and initializing // this position with the calculated coordinates. - mobility.Layout (nodes.begin (), nodes.end ()); + mobility.Layout (nodes); // iterate our nodes and print their position. - for (std::vector >::const_iterator j = nodes.begin (); - j != nodes.end (); j++) + for (NodeContainer::Iterator j = nodes.Begin (); + j != nodes.End (); ++j) { - Ptr object = *j; + Ptr object = *j; Ptr position = object->GetObject (); NS_ASSERT (position != 0); Vector pos = position->GetPosition (); diff --git a/samples/main-random-topology.cc b/samples/main-random-topology.cc index 1bdbcbc81..a17834f21 100644 --- a/samples/main-random-topology.cc +++ b/samples/main-random-topology.cc @@ -29,11 +29,8 @@ int main (int argc, char *argv[]) cmd.Parse (argc, argv); - std::vector > objects; - for (uint32_t i = 0; i < 10000; i++) - { - objects.push_back (CreateObject ()); - } + NodeContainer c; + c.Create (10000); MobilityHelper mobility; mobility.EnableNotifier (); @@ -42,7 +39,7 @@ int main (int argc, char *argv[]) "Y", String ("100.0"), "Rho", String ("Uniform:0:30")); mobility.SetMobilityModel ("ns3::StaticMobilityModel"); - mobility.Layout (objects.begin (), objects.end ()); + mobility.Layout (c); Config::Connect ("/NodeList/*/$ns3::MobilityModelNotifier/CourseChange", MakeCallback (&CourseChange)); diff --git a/samples/main-random-walk.cc b/samples/main-random-walk.cc index 213480949..e8b6fe8a7 100644 --- a/samples/main-random-walk.cc +++ b/samples/main-random-walk.cc @@ -36,10 +36,8 @@ int main (int argc, char *argv[]) CommandLine cmd; cmd.Parse (argc, argv); - for (uint32_t i = 0; i < 100; i++) - { - Ptr node = CreateObject (); - } + NodeContainer c; + c.Create (100); MobilityHelper mobility; mobility.EnableNotifier (); @@ -52,7 +50,7 @@ int main (int argc, char *argv[]) "Time", String ("2s"), "Speed", String ("Constant:1.0"), "Bounds", String ("0:200:0:100")); - mobility.Layout (NodeList::Begin (), NodeList::End ()); + mobility.LayoutAll (); Config::Connect ("/NodeList/*/$ns3::MobilityModelNotifier/CourseChange", MakeCallback (&CourseChange)); diff --git a/src/helper/mobility-helper.cc b/src/helper/mobility-helper.cc index 323d85ddc..221d92d0f 100644 --- a/src/helper/mobility-helper.cc +++ b/src/helper/mobility-helper.cc @@ -101,9 +101,9 @@ MobilityHelper::GetMobilityModelType (void) const } void -MobilityHelper::Layout (const std::vector > &objects) +MobilityHelper::Layout (NodeContainer c) { - for (std::vector >::const_iterator i = objects.begin (); i != objects.end (); i++) + for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i) { Ptr object = *i; Ptr model = object->GetObject (); @@ -145,4 +145,10 @@ MobilityHelper::Layout (const std::vector > &objects) } } +void +MobilityHelper::LayoutAll (void) +{ + Layout (NodeContainer::GetGlobal ()); +} + } // namespace ns3 diff --git a/src/helper/mobility-helper.h b/src/helper/mobility-helper.h index 29c7d8b2a..ea1140bc3 100644 --- a/src/helper/mobility-helper.h +++ b/src/helper/mobility-helper.h @@ -4,13 +4,17 @@ #include #include "ns3/object-factory.h" #include "ns3/attribute.h" -#include "position-allocator.h" +#include "ns3/position-allocator.h" +#include "node-container.h" namespace ns3 { class PositionAllocator; class MobilityModel; +/** + * \brief assign positions and mobility models to nodes. + */ class MobilityHelper { public: @@ -48,10 +52,9 @@ public: std::string GetMobilityModelType (void) const; - template - void Layout (T begin, T end); + void Layout (NodeContainer container); + void LayoutAll (void); private: - void Layout (const std::vector > &objects); std::vector > m_mobilityStack; bool m_notifierEnabled; @@ -61,21 +64,4 @@ private: } // namespace ns3 -namespace ns3 { - -template -void -MobilityHelper::Layout (T begin, T end) -{ - std::vector > objects; - for (T i = begin; i != end; i++) - { - Ptr object = *i; - objects.push_back (object); - } - Layout (objects); -} - -} // namespace ns3 - #endif /* MOBILITY_HELPER_H */ From 0ccf783437613f1001d1fc19781482acd24cb0dc Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Mon, 24 Mar 2008 11:14:05 -0700 Subject: [PATCH 04/12] doxygen --- src/helper/mobility-helper.h | 106 +++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) diff --git a/src/helper/mobility-helper.h b/src/helper/mobility-helper.h index ea1140bc3..b0242c8f8 100644 --- a/src/helper/mobility-helper.h +++ b/src/helper/mobility-helper.h @@ -14,17 +14,57 @@ class MobilityModel; /** * \brief assign positions and mobility models to nodes. + * + * MobilityHelper::Layout is the most important method here. */ class MobilityHelper { public: MobilityHelper (); + /** + * After this method is called, every call to MobilityHelper::Layout + * will also attach to the new ns3::MobilityModel an ns3::MobilityModelNotifier + * which can be used to listen to CourseChange events. + */ void EnableNotifier (void); + /** + * After this method is called, no ns3::MobilityModelNotifier object will + * be associated to any new ns3::MobilityModel created by MobilityHelper::Layout. + * This will make it impossible to listen to "CourseChange" events from these + * new ns3::MobilityModel instances. + */ void DisableNotifier (void); + /** + * \param allocator allocate initial node positions + * + * Set the position allocator which will be used to allocate + * the initial position of every node in MobilityModel::Layout. + */ void SetPositionAllocator (Ptr allocator); + /** + * \param type the type of mobility model to use. + * \param n1 the name of the attribute to set in the mobility model. + * \param v1 the value of the attribute to set in the mobility model. + * \param n2 the name of the attribute to set in the mobility model. + * \param v2 the value of the attribute to set in the mobility model. + * \param n3 the name of the attribute to set in the mobility model. + * \param v3 the value of the attribute to set in the mobility model. + * \param n4 the name of the attribute to set in the mobility model. + * \param v4 the value of the attribute to set in the mobility model. + * \param n5 the name of the attribute to set in the mobility model. + * \param v5 the value of the attribute to set in the mobility model. + * \param n6 the name of the attribute to set in the mobility model. + * \param v6 the value of the attribute to set in the mobility model. + * \param n7 the name of the attribute to set in the mobility model. + * \param v7 the value of the attribute to set in the mobility model. + * \param n8 the name of the attribute to set in the mobility model. + * \param v8 the value of the attribute to set in the mobility model. + * \param n9 the name of the attribute to set in the mobility model. + * \param v9 the value of the attribute to set in the mobility model. + */ void SetPositionAllocator (std::string type, std::string n1 = "", Attribute v1 = Attribute (), std::string n2 = "", Attribute v2 = Attribute (), @@ -36,6 +76,30 @@ public: std::string n8 = "", Attribute v8 = Attribute (), std::string n9 = "", Attribute v9 = Attribute ()); + /** + * \param type the type of mobility model to use. + * \param n1 the name of the attribute to set in the mobility model. + * \param v1 the value of the attribute to set in the mobility model. + * \param n2 the name of the attribute to set in the mobility model. + * \param v2 the value of the attribute to set in the mobility model. + * \param n3 the name of the attribute to set in the mobility model. + * \param v3 the value of the attribute to set in the mobility model. + * \param n4 the name of the attribute to set in the mobility model. + * \param v4 the value of the attribute to set in the mobility model. + * \param n5 the name of the attribute to set in the mobility model. + * \param v5 the value of the attribute to set in the mobility model. + * \param n6 the name of the attribute to set in the mobility model. + * \param v6 the value of the attribute to set in the mobility model. + * \param n7 the name of the attribute to set in the mobility model. + * \param v7 the value of the attribute to set in the mobility model. + * \param n8 the name of the attribute to set in the mobility model. + * \param v8 the value of the attribute to set in the mobility model. + * \param n9 the name of the attribute to set in the mobility model. + * \param v9 the value of the attribute to set in the mobility model. + * + * Calls to MobilityHelper::Layout will create an instance of a matching + * mobility model for each node. + */ void SetMobilityModel (std::string type, std::string n1 = "", Attribute v1 = Attribute (), std::string n2 = "", Attribute v2 = Attribute (), @@ -47,12 +111,54 @@ public: std::string n8 = "", Attribute v8 = Attribute (), std::string n9 = "", Attribute v9 = Attribute ()); + /** + * \param reference item to push. + * + * Push an item on the top of the stack of "reference mobility models". + * The input item should be a node instance to which a mobility model + * has already been aggregated (usually by a call to Layout). + * + * If this this stack is not empty when MobilityHelper::Layout + * is called, the model from the top of the stack is used + * to create a ns3::HierarchicalMobilityModel to make the + * newly-created models define their positions relative to that + * of the parent mobility model. + * + * This method is typically used to create hierarchical mobility + * patterns and positions by starting with the large-scale mobility + * features, and, then, defining the smaller-scale movements relative + * to a few reference points in the large-scale model. + */ void PushReferenceMobilityModel (Ptr reference); + /** + * Remove the top item from the top of the stack of + * "reference mobility models". + */ void PopReferenceMobilityModel (void); + /** + * \returns a string which contains the TypeId of the currently-selected + * mobility model. + */ std::string GetMobilityModelType (void) const; + /** + * \param container the set of nodes to layout. + * + * For each input node, this method creates an instance of a ns3::MobilityModel + * subclass (the type of which was set with MobilityHelper::SetMobilityModel), + * aggregates it to the mode, and sets an initial position based on the current + * position allocator (set through MobilityHelper::SetPositionAllocator). + * Optionally, this method will also create and aggregate a + * ns3::MobilityModelNotifier to generate 'CourseChange' events based on the + * boolean flag set by MobilityHelper::EnableNotifier and MobilityHelper::DisableNotifier. + */ void Layout (NodeContainer container); + + /** + * Perform the work of MobilityHelper::Layout on _all_ nodes which + * exist in the simulation. + */ void LayoutAll (void); private: From 80fec1898ee6f72edd6c903909317d31f152fff5 Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Mon, 24 Mar 2008 11:28:42 -0700 Subject: [PATCH 05/12] do not use templates. --- src/helper/olsr-helper.cc | 8 ++++++-- src/helper/olsr-helper.h | 18 ------------------ 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/src/helper/olsr-helper.cc b/src/helper/olsr-helper.cc index f7b475362..f27cb08c7 100644 --- a/src/helper/olsr-helper.cc +++ b/src/helper/olsr-helper.cc @@ -34,7 +34,11 @@ OlsrHelper::SetAgent (std::string tid, void OlsrHelper::Enable (NodeContainer container) { - Enable (container.Begin (), container.End ()); + for (NodeContainer::Iterator i = container.Begin (); i != container.End (); ++i) + { + Ptr node = *i; + Enable (node); + } } void OlsrHelper::Enable (Ptr node) @@ -47,7 +51,7 @@ OlsrHelper::Enable (Ptr node) void OlsrHelper::EnableAll (void) { - Enable (NodeList::Begin (), NodeList::End ()); + Enable (NodeContainer::GetGlobal ()); } } // namespace ns3 diff --git a/src/helper/olsr-helper.h b/src/helper/olsr-helper.h index 462766cde..80df120af 100644 --- a/src/helper/olsr-helper.h +++ b/src/helper/olsr-helper.h @@ -22,8 +22,6 @@ public: std::string n6 = "", Attribute v6 = Attribute (), std::string n7 = "", Attribute v7 = Attribute ()); - template - void Enable (InputIterator begin, InputIterator end); void Enable (NodeContainer container); void Enable (Ptr node); void EnableAll (void); @@ -33,20 +31,4 @@ private: } // namespace ns3 -namespace ns3 { - -template -void -OlsrHelper::Enable (T begin, T end) -{ - for (T i = begin; i != end; i++) - { - Ptr obj = (*i); - Ptr node = obj->GetObject (); - Enable (node); - } -} - -} // namespace ns3 - #endif /* OLSR_HELPER_H */ From 41bbee50af977a28deb12de178abc920c872b67a Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Mon, 24 Mar 2008 11:43:49 -0700 Subject: [PATCH 06/12] doxygen --- src/helper/csma-helper.h | 46 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/src/helper/csma-helper.h b/src/helper/csma-helper.h index e553d5a15..1d64d0ac6 100644 --- a/src/helper/csma-helper.h +++ b/src/helper/csma-helper.h @@ -10,11 +10,28 @@ namespace ns3 { +/** + * \brief build a set of CsmaNetDevice objects + */ class CsmaHelper { public: CsmaHelper (); + /** + * \param type the type of queue + * \param n1 the name of the attribute to set on the queue + * \param v1 the value of the attribute to set on the queue + * \param n2 the name of the attribute to set on the queue + * \param v2 the value of the attribute to set on the queue + * \param n3 the name of the attribute to set on the queue + * \param v3 the value of the attribute to set on the queue + * \param n4 the name of the attribute to set on the queue + * \param v4 the value of the attribute to set on the queue + * + * Set the type of queue to create and associated to each + * CsmaNetDevice created through CsmaHelper::Build. + */ void SetQueue (std::string type, std::string n1 = "", Attribute v1 = Attribute (), std::string n2 = "", Attribute v2 = Attribute (), @@ -22,15 +39,40 @@ public: std::string n4 = "", Attribute v4 = Attribute ()); /** - * Set these parameters on each PointToPointNetDevice created - * by this helper. + * \param n1 the name of the attribute to set + * \param v1 the value of the attribute to set + * + * Set these parameters on each CsmaNetDevice created + * by CsmaHelper::Build */ void SetDeviceParameter (std::string n1, Attribute v1); + /** + * \param n1 the name of the attribute to set + * \param v1 the value of the attribute to set + * + * Set these parameters on each CsmaChannel created + * by CsmaHelper::Build + */ void SetChannelParameter (std::string n1, Attribute v1); + /** + * \param c a set of nodes + * + * This method creates a simple ns3::CsmaChannel with the + * attributes configured by CsmaHelper::SetChannelParameter and + * then calls CsmaHelper::Build. + */ NetDeviceContainer Build (const NodeContainer &c); + /** + * \param c a set of nodes + * \param channel the channel to use as a backbone. + * + * For each node in the input container, we create a ns::CsmaNetDevice with + * the requested parameters, a queue for this NetDevice, and associate + * the resulting ns3::NetDevice with the ns3::Node and ns3::CsmaChannel. + */ NetDeviceContainer Build (const NodeContainer &c, Ptr channel); private: From 47775d87dace47cdca5a966be53e90262f08512a Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Mon, 24 Mar 2008 11:49:58 -0700 Subject: [PATCH 07/12] doxygen. --- src/helper/csma-helper.h | 6 ++-- src/helper/point-to-point-helper.h | 47 ++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/src/helper/csma-helper.h b/src/helper/csma-helper.h index 1d64d0ac6..87645b161 100644 --- a/src/helper/csma-helper.h +++ b/src/helper/csma-helper.h @@ -42,7 +42,7 @@ public: * \param n1 the name of the attribute to set * \param v1 the value of the attribute to set * - * Set these parameters on each CsmaNetDevice created + * Set these parameters on each ns3::CsmaNetDevice created * by CsmaHelper::Build */ void SetDeviceParameter (std::string n1, Attribute v1); @@ -51,7 +51,7 @@ public: * \param n1 the name of the attribute to set * \param v1 the value of the attribute to set * - * Set these parameters on each CsmaChannel created + * Set these parameters on each ns3::CsmaChannel created * by CsmaHelper::Build */ void SetChannelParameter (std::string n1, Attribute v1); @@ -69,7 +69,7 @@ public: * \param c a set of nodes * \param channel the channel to use as a backbone. * - * For each node in the input container, we create a ns::CsmaNetDevice with + * For each node in the input container, we create a ns3::CsmaNetDevice with * the requested parameters, a queue for this NetDevice, and associate * the resulting ns3::NetDevice with the ns3::Node and ns3::CsmaChannel. */ diff --git a/src/helper/point-to-point-helper.h b/src/helper/point-to-point-helper.h index 25e7e23c8..ffb4156ba 100644 --- a/src/helper/point-to-point-helper.h +++ b/src/helper/point-to-point-helper.h @@ -8,22 +8,69 @@ namespace ns3 { +/** + * \brief build a set of PointToPointNetDevice objects + */ class PointToPointHelper { public: // by default, create queues of type DropTailQueue. PointToPointHelper (); + /** + * \param type the type of queue + * \param n1 the name of the attribute to set on the queue + * \param v1 the value of the attribute to set on the queue + * \param n2 the name of the attribute to set on the queue + * \param v2 the value of the attribute to set on the queue + * \param n3 the name of the attribute to set on the queue + * \param v3 the value of the attribute to set on the queue + * \param n4 the name of the attribute to set on the queue + * \param v4 the value of the attribute to set on the queue + * + * Set the type of queue to create and associated to each + * PointToPointNetDevice created through PointToPointHelper::Build. + */ void SetQueue (std::string type, std::string n1 = "", Attribute v1 = Attribute (), std::string n2 = "", Attribute v2 = Attribute (), std::string n3 = "", Attribute v3 = Attribute (), std::string n4 = "", Attribute v4 = Attribute ()); + /** + * \param n1 the name of the attribute to set + * \param v1 the value of the attribute to set + * + * Set these parameters on each ns3::PointToPointNetDevice created + * by PointToPointHelper::Build + */ void SetDeviceParameter (std::string name, Attribute value); + /** + * \param n1 the name of the attribute to set + * \param v1 the value of the attribute to set + * + * Set these parameters on each ns3::PointToPointChannel created + * by PointToPointHelper::Build + */ void SetChannelParameter (std::string name, Attribute value); + /** + * \param c a set of nodes + * + * This method creates a ns3::PointToPointChannel with the + * attributes configured by PointToPointHelper::SetChannelParameter, + * then, for each node in the input container, we create a + * ns3::PointToPointNetDevice with the requested parameters, + * a queue for this ns3::NetDevice, and associate the resulting + * ns3::NetDevice with the ns3::Node and ns3::PointToPointChannel. + */ NetDeviceContainer Build (NodeContainer c); + /** + * \param a first node + * \param b second node + * + * Saves you from having to construct a temporary NodeContainer. + */ NetDeviceContainer Build (Ptr a, Ptr b); private: From 9ad409452bd9f6d1fdb6979878de7ea2c7c380dc Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Mon, 24 Mar 2008 11:50:58 -0700 Subject: [PATCH 08/12] fix dox warnings. --- src/helper/point-to-point-helper.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/helper/point-to-point-helper.h b/src/helper/point-to-point-helper.h index ffb4156ba..0b48c683f 100644 --- a/src/helper/point-to-point-helper.h +++ b/src/helper/point-to-point-helper.h @@ -38,16 +38,16 @@ public: std::string n4 = "", Attribute v4 = Attribute ()); /** - * \param n1 the name of the attribute to set - * \param v1 the value of the attribute to set + * \param name the name of the attribute to set + * \param value the value of the attribute to set * * Set these parameters on each ns3::PointToPointNetDevice created * by PointToPointHelper::Build */ void SetDeviceParameter (std::string name, Attribute value); /** - * \param n1 the name of the attribute to set - * \param v1 the value of the attribute to set + * \param name the name of the attribute to set + * \param value the value of the attribute to set * * Set these parameters on each ns3::PointToPointChannel created * by PointToPointHelper::Build From 3a19364b1bc26ffe663aef66514816f59d50d866 Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Mon, 24 Mar 2008 11:56:50 -0700 Subject: [PATCH 09/12] introduce AddInternetStack --- src/internet-node/internet-node.cc | 67 ++----------------------- src/internet-node/internet-node.h | 7 --- src/internet-node/internet-stack.cc | 78 +++++++++++++++++++++++++++++ src/internet-node/internet-stack.h | 34 +++++++++++++ src/internet-node/wscript | 2 + 5 files changed, 117 insertions(+), 71 deletions(-) create mode 100644 src/internet-node/internet-stack.cc create mode 100644 src/internet-node/internet-stack.h diff --git a/src/internet-node/internet-node.cc b/src/internet-node/internet-node.cc index d91504336..02b296065 100644 --- a/src/internet-node/internet-node.cc +++ b/src/internet-node/internet-node.cc @@ -23,77 +23,16 @@ #include "ns3/net-device.h" #include "ns3/callback.h" - -#include "ipv4-l4-demux.h" #include "internet-node.h" -#include "udp-l4-protocol.h" -#include "tcp-l4-protocol.h" -#include "ipv4-l3-protocol.h" -#include "arp-l3-protocol.h" -#include "udp-impl.h" -#include "tcp-impl.h" -#include "ipv4-impl.h" +#include "internet-stack.h" + namespace ns3 { InternetNode::InternetNode() { - Construct (); + AddInternetStack (this); } -InternetNode::InternetNode(uint32_t systemId) -{ - Construct (); -} - -InternetNode::~InternetNode () -{} - -void -InternetNode::Construct (void) -{ - Ptr ipv4 = CreateObject (); - Ptr arp = CreateObject (); - ipv4->SetNode (this); - arp->SetNode (this); - // XXX remove the PeekPointer below. - RegisterProtocolHandler (MakeCallback (&Ipv4L3Protocol::Receive, PeekPointer (ipv4)), - Ipv4L3Protocol::PROT_NUMBER, 0); - RegisterProtocolHandler (MakeCallback (&ArpL3Protocol::Receive, PeekPointer (arp)), - ArpL3Protocol::PROT_NUMBER, 0); - - - Ptr ipv4L4Demux = CreateObject (); - Ptr udp = CreateObject (); - Ptr tcp = CreateObject (); - - ipv4L4Demux->SetNode (this); - udp->SetNode (this); - tcp->SetNode (this); - - ipv4L4Demux->Insert (udp); - ipv4L4Demux->Insert (tcp); - - Ptr udpImpl = CreateObject (); - Ptr tcpImpl = CreateObject (); - Ptr ipv4Impl = CreateObject (); - - udpImpl->SetUdp (udp); - tcpImpl->SetTcp (tcp); - ipv4Impl->SetIpv4 (ipv4); - - Object::AggregateObject (ipv4); - Object::AggregateObject (arp); - Object::AggregateObject (ipv4Impl); - Object::AggregateObject (udpImpl); - Object::AggregateObject (tcpImpl); - Object::AggregateObject (ipv4L4Demux); -} - -void -InternetNode::DoDispose() -{ - Node::DoDispose (); -} }//namespace ns3 diff --git a/src/internet-node/internet-node.h b/src/internet-node/internet-node.h index 20f743543..85ca02a84 100644 --- a/src/internet-node/internet-node.h +++ b/src/internet-node/internet-node.h @@ -58,13 +58,6 @@ class InternetNode : public Node { public: InternetNode(); - InternetNode(uint32_t systemId); - virtual ~InternetNode (); - -protected: - virtual void DoDispose(void); -private: - void Construct (void); }; }//namespace ns3 diff --git a/src/internet-node/internet-stack.cc b/src/internet-node/internet-stack.cc new file mode 100644 index 000000000..b427243dd --- /dev/null +++ b/src/internet-node/internet-stack.cc @@ -0,0 +1,78 @@ +// -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- +// +// Copyright (c) 2006 Georgia Tech Research Corporation +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// Author: George F. Riley +// + +#include "ns3/net-device.h" +#include "ns3/callback.h" + +#include "ipv4-l4-demux.h" +#include "internet-node.h" +#include "udp-l4-protocol.h" +#include "tcp-l4-protocol.h" +#include "ipv4-l3-protocol.h" +#include "arp-l3-protocol.h" +#include "udp-impl.h" +#include "tcp-impl.h" +#include "ipv4-impl.h" + +namespace ns3 { + +void +AddInternetStack (Ptr node) +{ + Ptr ipv4 = CreateObject (); + Ptr arp = CreateObject (); + ipv4->SetNode (node); + arp->SetNode (node); + // XXX remove the PeekPointer below. + node->RegisterProtocolHandler (MakeCallback (&Ipv4L3Protocol::Receive, PeekPointer (ipv4)), + Ipv4L3Protocol::PROT_NUMBER, 0); + node->RegisterProtocolHandler (MakeCallback (&ArpL3Protocol::Receive, PeekPointer (arp)), + ArpL3Protocol::PROT_NUMBER, 0); + + + Ptr ipv4L4Demux = CreateObject (); + Ptr udp = CreateObject (); + Ptr tcp = CreateObject (); + + ipv4L4Demux->SetNode (node); + udp->SetNode (node); + tcp->SetNode (node); + + ipv4L4Demux->Insert (udp); + ipv4L4Demux->Insert (tcp); + + Ptr udpImpl = CreateObject (); + Ptr tcpImpl = CreateObject (); + Ptr ipv4Impl = CreateObject (); + + udpImpl->SetUdp (udp); + tcpImpl->SetTcp (tcp); + ipv4Impl->SetIpv4 (ipv4); + + node->AggregateObject (ipv4); + node->AggregateObject (arp); + node->AggregateObject (ipv4Impl); + node->AggregateObject (udpImpl); + node->AggregateObject (tcpImpl); + node->AggregateObject (ipv4L4Demux); +} + +}//namespace ns3 diff --git a/src/internet-node/internet-stack.h b/src/internet-node/internet-stack.h new file mode 100644 index 000000000..e5d8c9191 --- /dev/null +++ b/src/internet-node/internet-stack.h @@ -0,0 +1,34 @@ +// -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- +// +// Copyright (c) 2006 Georgia Tech Research Corporation +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// Author: George F. Riley + +#ifndef INTERNET_STACK_H +#define INTERNET_STACK_H + +#include "ns3/ptr.h" + +namespace ns3 { + +class Node; + +void AddInternetStack (Ptr node); + +}//namespace ns3 + +#endif /* INTERNET_STACK_H */ diff --git a/src/internet-node/wscript b/src/internet-node/wscript index 15b0336a8..c48d3910d 100644 --- a/src/internet-node/wscript +++ b/src/internet-node/wscript @@ -5,6 +5,7 @@ def build(bld): obj = bld.create_ns3_module('internet-node', ['node']) obj.source = [ 'internet-node.cc', + 'internet-stack.cc', 'ipv4-l4-demux.cc', 'ipv4-l4-protocol.cc', 'ipv4-header.cc', @@ -39,6 +40,7 @@ def build(bld): headers.module = 'internet-node' headers.source = [ 'internet-node.h', + 'internet-stack.h', 'ascii-trace.h', 'pcap-trace.h', 'ipv4-header.h', From 44d0c5668046ce528862c066ced4b5d669a7bc0e Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Mon, 24 Mar 2008 19:00:18 +0000 Subject: [PATCH 10/12] Fix swapped comments in wifi-ap.cc. --- examples/wifi-ap.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/wifi-ap.cc b/examples/wifi-ap.cc index 4634cc6df..98b117574 100644 --- a/examples/wifi-ap.cc +++ b/examples/wifi-ap.cc @@ -150,11 +150,11 @@ int main (int argc, char *argv[]) Ssid ssid = Ssid ("wifi-default"); wifi.SetPhy ("ns3::WifiPhy"); wifi.SetRemoteStationManager ("ns3::ArfWifiManager"); - // setup ap. + // setup stas. wifi.SetMac ("ns3::NqstaWifiMac", "Ssid", ssid, "ActiveProbing", Boolean (false)); staDevs = wifi.Build (stas, channel); - // setup stas. + // setup ap. wifi.SetMac ("ns3::NqapWifiMac", "Ssid", ssid, "BeaconGeneration", Boolean (true), "BeaconInterval", Seconds (2.5)); From 14690d8553bf416774970b601c2c0f83946393fb Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Mon, 24 Mar 2008 12:11:30 -0700 Subject: [PATCH 11/12] InternetStackHelper. --- src/helper/internet-stack-helper.cc | 17 +++++++++++++++++ src/helper/internet-stack-helper.h | 19 +++++++++++++++++++ src/helper/wscript | 2 ++ 3 files changed, 38 insertions(+) create mode 100644 src/helper/internet-stack-helper.cc create mode 100644 src/helper/internet-stack-helper.h diff --git a/src/helper/internet-stack-helper.cc b/src/helper/internet-stack-helper.cc new file mode 100644 index 000000000..a7f663ee2 --- /dev/null +++ b/src/helper/internet-stack-helper.cc @@ -0,0 +1,17 @@ +#include "internet-stack-helper.h" +#include "ns3/internet-stack.h" + +namespace ns3 { + +void +InternetStackHelper::Build (NodeContainer c) +{ + for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i) + { + Ptr node = *i; + AddInternetStack (node); + } +} + + +} // namespace ns3 diff --git a/src/helper/internet-stack-helper.h b/src/helper/internet-stack-helper.h new file mode 100644 index 000000000..ced65384e --- /dev/null +++ b/src/helper/internet-stack-helper.h @@ -0,0 +1,19 @@ +#ifndef INTERNET_STACK_HELPER_H +#define INTERNET_STACK_HELPER_H + +#include "node-container.h" + +namespace ns3 { + +/** + * \brief aggregate ip/tcp/udp functionality to existing Nodes. + */ +class InternetStackHelper +{ +public: + void Build (NodeContainer c); +}; + +} // namespace ns3 + +#endif /* INTERNET_STACK_HELPER_H */ diff --git a/src/helper/wscript b/src/helper/wscript index c8a825d0e..6e175758b 100644 --- a/src/helper/wscript +++ b/src/helper/wscript @@ -11,6 +11,7 @@ def build(bld): 'csma-helper.cc', 'mobility-helper.cc', 'ns2-mobility-helper.cc', + 'internet-stack-helper.cc', ] headers = bld.create_obj('ns3header') @@ -24,4 +25,5 @@ def build(bld): 'csma-helper.h', 'mobility-helper.h', 'ns2-mobility-helper.h', + 'internet-stack-helper.h', ] From f44690e9af4c4deb73ebfe06051031a1c5cd51e9 Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Mon, 24 Mar 2008 12:12:22 -0700 Subject: [PATCH 12/12] doxygen --- src/helper/internet-stack-helper.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/helper/internet-stack-helper.h b/src/helper/internet-stack-helper.h index ced65384e..f5a16b72e 100644 --- a/src/helper/internet-stack-helper.h +++ b/src/helper/internet-stack-helper.h @@ -11,6 +11,12 @@ namespace ns3 { class InternetStackHelper { public: + /** + * \param c the set of nodes + * + * For each node in the input container, aggregate implementations + * of the ns3::Ipv4, ns3::Udp, and, ns3::Tcp classes. + */ void Build (NodeContainer c); };