From d406a5b87dcb2ac1d4f84d3b21ee64fd2e516937 Mon Sep 17 00:00:00 2001 From: John Abraham Date: Tue, 26 Apr 2011 15:18:32 -0700 Subject: [PATCH] Bug 1105 Move topology helpers into separate per-device modules --- examples/matrix-topology/wscript | 2 +- examples/naming/object-names.cc | 1 + examples/realtime/realtime-udp-echo.cc | 1 + examples/routing/mixed-global-routing.cc | 2 +- examples/socket/wscript | 4 +- examples/tcp/star.cc | 2 +- examples/tcp/tcp-nsc-zoo.cc | 2 +- examples/tcp/wscript | 2 +- examples/tutorial/third.cc | 2 +- .../udp-client-server/udp-client-server.cc | 1 + .../udp-trace-client-server.cc | 1 + examples/udp/udp-echo.cc | 1 + examples/wireless/mixed-wireless.cc | 2 +- examples/wireless/wifi-wired-bridging.cc | 1 + src/bridge/examples/csma-bridge-one-hop.cc | 2 +- src/bridge/examples/csma-bridge.cc | 1 + src/csma-layout/examples/csma-star.cc | 195 ++++++++++++++++++ src/csma-layout/examples/waf | 1 + src/csma-layout/examples/wscript | 5 + src/csma-layout/model/csma-star-helper.cc | 109 ++++++++++ src/csma-layout/model/csma-star-helper.h | 123 +++++++++++ src/csma-layout/waf | 1 + src/csma-layout/wscript | 18 ++ src/csma/examples/csma-broadcast.cc | 1 + src/csma/examples/csma-multicast.cc | 3 +- src/csma/examples/csma-one-subnet.cc | 1 + src/csma/examples/csma-ping.cc | 1 + src/csma/examples/csma-raw-ip-socket.cc | 1 + src/csma/examples/wscript | 3 - src/csma/wscript | 4 +- src/netanim/examples/dumbbell-animation.cc | 2 +- src/netanim/examples/grid-animation.cc | 2 +- src/netanim/examples/star-animation.cc | 2 +- src/netanim/examples/wscript | 6 +- src/netanim/model/animation-interface.cc | 2 - src/netanim/wscript | 9 +- src/olsr/examples/olsr-hna.cc | 4 +- .../model/point-to-point-dumbbell.cc} | 2 +- .../model/point-to-point-dumbbell.h} | 0 .../model/point-to-point-grid.cc} | 2 +- .../model/point-to-point-grid.h} | 0 .../model/point-to-point-star.cc} | 2 +- .../model/point-to-point-star.h} | 0 src/point-to-point-layout/waf | 1 + src/point-to-point-layout/wscript | 23 +++ src/wimax/examples/wimax-multicast.cc | 7 +- src/wscript | 2 + 47 files changed, 514 insertions(+), 45 deletions(-) create mode 100644 src/csma-layout/examples/csma-star.cc create mode 100644 src/csma-layout/examples/waf create mode 100644 src/csma-layout/examples/wscript create mode 100644 src/csma-layout/model/csma-star-helper.cc create mode 100644 src/csma-layout/model/csma-star-helper.h create mode 100644 src/csma-layout/waf create mode 100644 src/csma-layout/wscript rename src/{netanim/helper/point-to-point-dumbbell-helper.cc => point-to-point-layout/model/point-to-point-dumbbell.cc} (99%) rename src/{netanim/helper/point-to-point-dumbbell-helper.h => point-to-point-layout/model/point-to-point-dumbbell.h} (100%) rename src/{netanim/helper/point-to-point-grid-helper.cc => point-to-point-layout/model/point-to-point-grid.cc} (99%) rename src/{netanim/helper/point-to-point-grid-helper.h => point-to-point-layout/model/point-to-point-grid.h} (100%) rename src/{netanim/helper/point-to-point-star-helper.cc => point-to-point-layout/model/point-to-point-star.cc} (98%) rename src/{netanim/helper/point-to-point-star-helper.h => point-to-point-layout/model/point-to-point-star.h} (100%) create mode 100644 src/point-to-point-layout/waf create mode 100644 src/point-to-point-layout/wscript diff --git a/examples/matrix-topology/wscript b/examples/matrix-topology/wscript index a063499aa..595d6d561 100644 --- a/examples/matrix-topology/wscript +++ b/examples/matrix-topology/wscript @@ -2,5 +2,5 @@ def build(bld): obj = bld.create_ns3_program('matrix-topology', - ['network', 'internet', 'netanim', 'mobility', 'applications']) + ['network', 'internet', 'netanim', 'point-to-point', 'mobility', 'applications']) obj.source = 'matrix-topology.cc' diff --git a/examples/naming/object-names.cc b/examples/naming/object-names.cc index f39c3fc45..d4e8bd03f 100644 --- a/examples/naming/object-names.cc +++ b/examples/naming/object-names.cc @@ -25,6 +25,7 @@ #include "ns3/core-module.h" #include "ns3/csma-module.h" #include "ns3/applications-module.h" +#include "ns3/internet-module.h" using namespace ns3; diff --git a/examples/realtime/realtime-udp-echo.cc b/examples/realtime/realtime-udp-echo.cc index 512287191..d47aeab91 100644 --- a/examples/realtime/realtime-udp-echo.cc +++ b/examples/realtime/realtime-udp-echo.cc @@ -29,6 +29,7 @@ #include "ns3/core-module.h" #include "ns3/csma-module.h" #include "ns3/applications-module.h" +#include "ns3/internet-module.h" using namespace ns3; diff --git a/examples/routing/mixed-global-routing.cc b/examples/routing/mixed-global-routing.cc index ca9cf9368..02f7bb50f 100644 --- a/examples/routing/mixed-global-routing.cc +++ b/examples/routing/mixed-global-routing.cc @@ -41,7 +41,7 @@ #include "ns3/point-to-point-module.h" #include "ns3/csma-module.h" #include "ns3/applications-module.h" -#include "ns3/ipv4-global-routing-helper.h" +#include "ns3/internet-module.h" using namespace ns3; diff --git a/examples/socket/wscript b/examples/socket/wscript index c029aea84..2f8ecc21a 100644 --- a/examples/socket/wscript +++ b/examples/socket/wscript @@ -1,8 +1,8 @@ ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- def build(bld): - obj = bld.create_ns3_program('socket-bound-static-routing', ['network', 'csma', 'internet']) + obj = bld.create_ns3_program('socket-bound-static-routing', ['network', 'csma', 'point-to-point', 'internet']) obj.source = 'socket-bound-static-routing.cc' - obj = bld.create_ns3_program('socket-bound-tcp-static-routing', ['network', 'csma', 'internet']) + obj = bld.create_ns3_program('socket-bound-tcp-static-routing', ['network', 'csma', 'point-to-point', 'internet']) obj.source = 'socket-bound-tcp-static-routing.cc' diff --git a/examples/tcp/star.cc b/examples/tcp/star.cc index 56adc831a..a167e0de3 100644 --- a/examples/tcp/star.cc +++ b/examples/tcp/star.cc @@ -21,7 +21,7 @@ #include "ns3/internet-module.h" #include "ns3/point-to-point-module.h" #include "ns3/applications-module.h" -#include "ns3/ipv4-global-routing-helper.h" +#include "ns3/point-to-point-layout-module.h" // Network topology (default) // diff --git a/examples/tcp/tcp-nsc-zoo.cc b/examples/tcp/tcp-nsc-zoo.cc index da5d10dfe..b9d4cb35a 100644 --- a/examples/tcp/tcp-nsc-zoo.cc +++ b/examples/tcp/tcp-nsc-zoo.cc @@ -34,7 +34,7 @@ #include "ns3/applications-module.h" #include "ns3/network-module.h" #include "ns3/csma-module.h" -#include "ns3/ipv4-global-routing-helper.h" +#include "ns3/internet-module.h" using namespace ns3; diff --git a/examples/tcp/wscript b/examples/tcp/wscript index 816708ecb..f70ee1fd4 100644 --- a/examples/tcp/wscript +++ b/examples/tcp/wscript @@ -18,7 +18,7 @@ def build(bld): obj.source = 'tcp-star-server.cc' obj = bld.create_ns3_program('star', - ['netanim', 'point-to-point', 'applications', 'internet']) + ['netanim', 'point-to-point', 'point-to-point-layout', 'applications', 'internet']) obj.source = 'star.cc' obj = bld.create_ns3_program('tcp-bulk-send', diff --git a/examples/tutorial/third.cc b/examples/tutorial/third.cc index 1129b4588..c63da3327 100644 --- a/examples/tutorial/third.cc +++ b/examples/tutorial/third.cc @@ -21,7 +21,7 @@ #include "ns3/wifi-module.h" #include "ns3/mobility-module.h" #include "ns3/csma-module.h" -#include "ns3/ipv4-global-routing-helper.h" +#include "ns3/internet-module.h" // Default Network Topology // diff --git a/examples/udp-client-server/udp-client-server.cc b/examples/udp-client-server/udp-client-server.cc index ec7359296..3ab40991c 100644 --- a/examples/udp-client-server/udp-client-server.cc +++ b/examples/udp-client-server/udp-client-server.cc @@ -28,6 +28,7 @@ #include "ns3/core-module.h" #include "ns3/csma-module.h" #include "ns3/applications-module.h" +#include "ns3/internet-module.h" using namespace ns3; diff --git a/examples/udp-client-server/udp-trace-client-server.cc b/examples/udp-client-server/udp-trace-client-server.cc index 087bafe65..bbb9222a4 100644 --- a/examples/udp-client-server/udp-trace-client-server.cc +++ b/examples/udp-client-server/udp-trace-client-server.cc @@ -27,6 +27,7 @@ #include "ns3/core-module.h" #include "ns3/csma-module.h" #include "ns3/applications-module.h" +#include "ns3/internet-module.h" using namespace ns3; diff --git a/examples/udp/udp-echo.cc b/examples/udp/udp-echo.cc index bbab90be9..fd6b07837 100644 --- a/examples/udp/udp-echo.cc +++ b/examples/udp/udp-echo.cc @@ -29,6 +29,7 @@ #include "ns3/core-module.h" #include "ns3/csma-module.h" #include "ns3/applications-module.h" +#include "ns3/internet-module.h" using namespace ns3; diff --git a/examples/wireless/mixed-wireless.cc b/examples/wireless/mixed-wireless.cc index d4fe6c133..87b417503 100644 --- a/examples/wireless/mixed-wireless.cc +++ b/examples/wireless/mixed-wireless.cc @@ -68,7 +68,7 @@ #include "ns3/wifi-module.h" #include "ns3/csma-module.h" #include "ns3/olsr-helper.h" -#include "ns3/ipv4-global-routing-helper.h" +#include "ns3/internet-module.h" using namespace ns3; diff --git a/examples/wireless/wifi-wired-bridging.cc b/examples/wireless/wifi-wired-bridging.cc index c574feda6..b6981cda2 100644 --- a/examples/wireless/wifi-wired-bridging.cc +++ b/examples/wireless/wifi-wired-bridging.cc @@ -49,6 +49,7 @@ #include "ns3/wifi-module.h" #include "ns3/network-module.h" #include "ns3/csma-module.h" +#include "ns3/internet-module.h" #include "ns3/bridge-helper.h" #include #include diff --git a/src/bridge/examples/csma-bridge-one-hop.cc b/src/bridge/examples/csma-bridge-one-hop.cc index 56d232ab8..c4cb1a70a 100644 --- a/src/bridge/examples/csma-bridge-one-hop.cc +++ b/src/bridge/examples/csma-bridge-one-hop.cc @@ -74,7 +74,7 @@ #include "ns3/applications-module.h" #include "ns3/bridge-module.h" #include "ns3/csma-module.h" -#include "ns3/ipv4-global-routing-helper.h" +#include "ns3/internet-module.h" using namespace ns3; diff --git a/src/bridge/examples/csma-bridge.cc b/src/bridge/examples/csma-bridge.cc index 7babdcb4a..f779f1ecf 100644 --- a/src/bridge/examples/csma-bridge.cc +++ b/src/bridge/examples/csma-bridge.cc @@ -37,6 +37,7 @@ #include "ns3/applications-module.h" #include "ns3/bridge-module.h" #include "ns3/csma-module.h" +#include "ns3/internet-module.h" using namespace ns3; diff --git a/src/csma-layout/examples/csma-star.cc b/src/csma-layout/examples/csma-star.cc new file mode 100644 index 000000000..d2788645a --- /dev/null +++ b/src/csma-layout/examples/csma-star.cc @@ -0,0 +1,195 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * 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 + * + */ + +#include "ns3/core-module.h" +#include "ns3/network-module.h" +#include "ns3/csma-module.h" +#include "ns3/csma-star-helper.h" +#include "ns3/applications-module.h" +#include "ns3/csma-module.h" +#include "ns3/internet-module.h" + +// Network topology (default) +// +// n2 + + n3 . +// | ... |\ /| ... | . +// ======= \ / ======= . +// CSMA \ / CSMA . +// \ / . +// n1 +--- n0 ---+ n4 . +// | ... | / \ | ... | . +// ======= / \ ======= . +// CSMA / \ CSMA . +// / \ . +// n6 + + n5 . +// | ... | | ... | . +// ======= ======= . +// CSMA CSMA . +// + +using namespace ns3; + +NS_LOG_COMPONENT_DEFINE ("CsmaStar"); + +int +main (int argc, char *argv[]) +{ + + // + // Set up some default values for the simulation. + // + Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (137)); + + // ??? try and stick 15kb/s into the data rate + Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue ("14kb/s")); + + // + // Default number of nodes in the star. Overridable by command line argument. + // + uint32_t nSpokes = 7; + + CommandLine cmd; + cmd.AddValue("nSpokes", "Number of spoke nodes to place in the star", nSpokes); + cmd.Parse (argc, argv); + + NS_LOG_INFO ("Build star topology."); + CsmaHelper csma; + csma.SetChannelAttribute ("DataRate", StringValue ("100Mbps")); + csma.SetChannelAttribute ("Delay", StringValue ("1ms")); + CsmaStarHelper star (nSpokes, csma); + + NodeContainer fillNodes; + + // + // Just to be nasy, hang some more nodes off of the CSMA channel for each + // spoke, so that there are a total of 16 nodes on each channel. Stash + // all of these new devices into a container. + // + NetDeviceContainer fillDevices; + + uint32_t nFill = 14; + for (uint32_t i = 0; i < star.GetSpokeDevices ().GetN (); ++i) + { + Ptr channel = star.GetSpokeDevices ().Get (i)->GetChannel (); + Ptr csmaChannel = channel->GetObject (); + NodeContainer newNodes; + newNodes.Create (nFill); + fillNodes.Add (newNodes); + fillDevices.Add (csma.Install (newNodes, csmaChannel)); + } + + NS_LOG_INFO ("Install internet stack on all nodes."); + InternetStackHelper internet; + star.InstallStack (internet); + internet.Install (fillNodes); + + NS_LOG_INFO ("Assign IP Addresses."); + star.AssignIpv4Addresses (Ipv4AddressHelper ("10.1.0.0", "255.255.255.0")); + + // + // We assigned addresses to the logical hub and the first "drop" of the + // CSMA network that acts as the spoke, but we also have a number of fill + // devices (nFill) also hanging off the CSMA network. We have got to + // assign addresses to them as well. We put all of the fill devices into + // a single device container, so the first nFill devices are associated + // with the channel connected to spokeDevices.Get (0), the second nFill + // devices afe associated with the channel connected to spokeDevices.Get (1) + // etc. + // + Ipv4AddressHelper address; + for(uint32_t i = 0; i < star.SpokeCount (); ++i) + { + std::ostringstream subnet; + subnet << "10.1." << i << ".0"; + NS_LOG_INFO ("Assign IP Addresses for CSMA subnet " << subnet.str ()); + address.SetBase (subnet.str ().c_str (), "255.255.255.0", "0.0.0.3"); + + for (uint32_t j = 0; j < nFill; ++j) + { + address.Assign (fillDevices.Get (i * nFill + j)); + } + } + + NS_LOG_INFO ("Create applications."); + // + // Create a packet sink on the star "hub" to receive packets. + // + uint16_t port = 50000; + Address hubLocalAddress (InetSocketAddress (Ipv4Address::GetAny (), port)); + PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", hubLocalAddress); + ApplicationContainer hubApp = packetSinkHelper.Install (star.GetHub ()); + hubApp.Start (Seconds (1.0)); + hubApp.Stop (Seconds (10.0)); + + // + // Create OnOff applications to send TCP to the hub, one on each spoke node. + // + OnOffHelper onOffHelper ("ns3::TcpSocketFactory", Address ()); + onOffHelper.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1))); + onOffHelper.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0))); + + ApplicationContainer spokeApps; + + for (uint32_t i = 0; i < star.SpokeCount (); ++i) + { + AddressValue remoteAddress (InetSocketAddress (star.GetHubIpv4Address (i), port)); + onOffHelper.SetAttribute ("Remote", remoteAddress); + spokeApps.Add (onOffHelper.Install (star.GetSpokeNode (i))); + } + + spokeApps.Start (Seconds (1.0)); + spokeApps.Stop (Seconds (10.0)); + + // + // Because we are evil, we also add OnOff applications to send TCP to the hub + // from the fill devices on each CSMA link. The first nFill nodes in the + // fillNodes container are on the CSMA network talking to the zeroth device + // on the hub node. The next nFill nodes are on the CSMA network talking to + // the first device on the hub node, etc. So the ith fillNode is associated + // with the hub address found on the (i / nFill)th device on the hub node. + // + ApplicationContainer fillApps; + + for (uint32_t i = 0; i < fillNodes.GetN (); ++i) + { + AddressValue remoteAddress (InetSocketAddress (star.GetHubIpv4Address (i / nFill), port)); + onOffHelper.SetAttribute ("Remote", remoteAddress); + fillApps.Add (onOffHelper.Install (fillNodes.Get (i))); + } + + fillApps.Start (Seconds (1.0)); + fillApps.Stop (Seconds (10.0)); + + NS_LOG_INFO ("Enable static global routing."); + // + // Turn on global static routing so we can actually be routed across the star. + // + Ipv4GlobalRoutingHelper::PopulateRoutingTables (); + + NS_LOG_INFO ("Enable pcap tracing."); + // + // Do pcap tracing on all devices on all nodes. + // + csma.EnablePcapAll ("csma-star", false); + + NS_LOG_INFO ("Run Simulation."); + Simulator::Run (); + Simulator::Destroy (); + NS_LOG_INFO ("Done."); + + return 0; +} diff --git a/src/csma-layout/examples/waf b/src/csma-layout/examples/waf new file mode 100644 index 000000000..941d56b43 --- /dev/null +++ b/src/csma-layout/examples/waf @@ -0,0 +1 @@ +exec "`dirname "$0"`"/../../waf "$@" diff --git a/src/csma-layout/examples/wscript b/src/csma-layout/examples/wscript new file mode 100644 index 000000000..85810e86c --- /dev/null +++ b/src/csma-layout/examples/wscript @@ -0,0 +1,5 @@ +## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- + +def build(bld): + obj = bld.create_ns3_program('csma-star', ['csma', 'csma-layout', 'internet', 'applications']) + obj.source = 'csma-star.cc' diff --git a/src/csma-layout/model/csma-star-helper.cc b/src/csma-layout/model/csma-star-helper.cc new file mode 100644 index 000000000..723dbb9e6 --- /dev/null +++ b/src/csma-layout/model/csma-star-helper.cc @@ -0,0 +1,109 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * 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 + */ + +#include +#include + +// ns3 includes +#include "ns3/animation-interface.h" +#include "ns3/csma-star-helper.h" +#include "ns3/node-list.h" +#include "ns3/point-to-point-net-device.h" +#include "ns3/vector.h" + +NS_LOG_COMPONENT_DEFINE("CsmaStarHelper"); + +namespace ns3 { + +CsmaStarHelper::CsmaStarHelper (uint32_t numSpokes, + CsmaHelper csmaHelper) +{ + m_hub.Create (1); + m_spokes.Create (numSpokes); + + for (uint32_t i = 0; i < m_spokes.GetN (); ++i) + { + NodeContainer nodes (m_hub.Get (0), m_spokes.Get (i)); + NetDeviceContainer nd = csmaHelper.Install (nodes); + m_hubDevices.Add (nd.Get (0)); + m_spokeDevices.Add (nd.Get (1)); + } +} + +CsmaStarHelper::~CsmaStarHelper () +{} + +Ptr +CsmaStarHelper::GetHub () const +{ + return m_hub.Get (0); +} + +Ptr +CsmaStarHelper::GetSpokeNode (uint32_t i) const +{ + return m_spokes.Get (i); +} + +NetDeviceContainer +CsmaStarHelper::GetHubDevices () const +{ + return m_spokeDevices; +} + +NetDeviceContainer +CsmaStarHelper::GetSpokeDevices () const +{ + return m_spokeDevices; +} + +Ipv4Address +CsmaStarHelper::GetHubIpv4Address (uint32_t i) const +{ + return m_hubInterfaces.GetAddress (i); +} + +Ipv4Address +CsmaStarHelper::GetSpokeIpv4Address (uint32_t i) const +{ + return m_spokeInterfaces.GetAddress (i); +} + +uint32_t +CsmaStarHelper::SpokeCount () const +{ + return m_spokes.GetN (); +} + +void +CsmaStarHelper::InstallStack (InternetStackHelper stack) +{ + stack.Install (m_hub); + stack.Install (m_spokes); +} + +void +CsmaStarHelper::AssignIpv4Addresses (Ipv4AddressHelper address) +{ + for (uint32_t i = 0; i < m_spokes.GetN (); ++i) + { + m_hubInterfaces.Add (address.Assign (m_hubDevices.Get (i))); + m_spokeInterfaces.Add (address.Assign (m_spokeDevices.Get (i))); + address.NewNetwork (); + } +} + +} // namespace ns3 diff --git a/src/csma-layout/model/csma-star-helper.h b/src/csma-layout/model/csma-star-helper.h new file mode 100644 index 000000000..dd07d0fb1 --- /dev/null +++ b/src/csma-layout/model/csma-star-helper.h @@ -0,0 +1,123 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * 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 + */ + +// Define an object to create a dumbbell topology. + +#ifndef CSMA_STAR_HELPER_H +#define CSMA_STAR_HELPER_H + +#include + +#include "csma-helper.h" +#include "ipv4-address-helper.h" +#include "internet-stack-helper.h" +#include "ipv4-interface-container.h" + +namespace ns3 { + +/** + * \brief A helper to make it easier to create a star topology + * with Csma links + */ +class CsmaStarHelper +{ +public: + /** + * Create a CsmaStarHelper in order to easily create + * star topologies using Csma links + * + * \param numSpokes the number of links attached to + * the hub node, creating a total of + * numSpokes + 1 nodes + * + * \param csmaHelper the link helper for Csma links, + * used to link nodes together + */ + CsmaStarHelper (uint32_t numSpokes, + CsmaHelper csmaHelper); + + ~CsmaStarHelper (); + +public: + /** + * \returns a node pointer to the hub node in the + * star, i.e., the center node + */ + Ptr GetHub () const; + + /** + * \param i an index into the spokes of the star + * + * \returns a node pointer to the node at the indexed spoke + */ + Ptr GetSpokeNode (uint32_t i) const; + + /** + * \returns the net-device container which contains all of + * the devices on the hub node + */ + NetDeviceContainer GetHubDevices () const; + + /** + * \returns the net-device container which contains all of + * the spoke node devices + */ + NetDeviceContainer GetSpokeDevices () const; + + /** + * \param i index into the hub interfaces + * + * \returns Ipv4Address according to indexed hub interface + */ + Ipv4Address GetHubIpv4Address (uint32_t i) const; + + /** + * \param i index into the spoke interfaces + * + * \returns Ipv4Address according to indexed spoke interface + */ + Ipv4Address GetSpokeIpv4Address (uint32_t i) const; + + /** + * \returns the total number of spokes in the star + */ + uint32_t SpokeCount () const; + + /** + * \param stack an InternetStackHelper which is used to install + * on every node in the star + */ + void InstallStack (InternetStackHelper stack); + + /** + * \param address an Ipv4AddressHelper which is used to install + * Ipv4 addresses on all the node interfaces in + * the star + */ + void AssignIpv4Addresses (Ipv4AddressHelper address); + +private: + NodeContainer m_hub; + NetDeviceContainer m_hubDevices; + NodeContainer m_spokes; + NetDeviceContainer m_spokeDevices; + Ipv4InterfaceContainer m_hubInterfaces; + Ipv4InterfaceContainer m_spokeInterfaces; +}; + +} // namespace ns3 + +#endif /* CSMA_STAR_HELPER_H */ diff --git a/src/csma-layout/waf b/src/csma-layout/waf new file mode 100644 index 000000000..3dcf598bc --- /dev/null +++ b/src/csma-layout/waf @@ -0,0 +1 @@ +exec "`dirname "$0"`"/../../waf "$@" \ No newline at end of file diff --git a/src/csma-layout/wscript b/src/csma-layout/wscript new file mode 100644 index 000000000..edf316e9d --- /dev/null +++ b/src/csma-layout/wscript @@ -0,0 +1,18 @@ +## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- + +def build(bld): + obj = bld.create_ns3_module('csma-layout', ['csma', 'network', 'applications']) + obj.source = [ + 'model/csma-star-helper.cc', + ] + headers = bld.new_task_gen('ns3header') + headers.module = 'csma-layout' + headers.source = [ + 'model/csma-star-helper.h', + ] + + if bld.env['ENABLE_EXAMPLES']: + bld.add_subdirs('examples') + + #bld.ns3_python_bindings() + diff --git a/src/csma/examples/csma-broadcast.cc b/src/csma/examples/csma-broadcast.cc index 5b2e11db3..1534bd2dc 100644 --- a/src/csma/examples/csma-broadcast.cc +++ b/src/csma/examples/csma-broadcast.cc @@ -36,6 +36,7 @@ #include "ns3/network-module.h" #include "ns3/csma-module.h" #include "ns3/applications-module.h" +#include "ns3/internet-module.h" using namespace ns3; diff --git a/src/csma/examples/csma-multicast.cc b/src/csma/examples/csma-multicast.cc index 7ebbfa5ed..cca50c2a3 100644 --- a/src/csma/examples/csma-multicast.cc +++ b/src/csma/examples/csma-multicast.cc @@ -36,8 +36,7 @@ #include "ns3/network-module.h" #include "ns3/csma-module.h" #include "ns3/applications-module.h" -#include "ns3/ipv4-static-routing-helper.h" -#include "ns3/ipv4-list-routing-helper.h" +#include "ns3/internet-module.h" using namespace ns3; diff --git a/src/csma/examples/csma-one-subnet.cc b/src/csma/examples/csma-one-subnet.cc index 5bf447e4f..9afeea3a4 100644 --- a/src/csma/examples/csma-one-subnet.cc +++ b/src/csma/examples/csma-one-subnet.cc @@ -32,6 +32,7 @@ #include "ns3/network-module.h" #include "ns3/csma-module.h" #include "ns3/applications-module.h" +#include "ns3/internet-module.h" using namespace ns3; diff --git a/src/csma/examples/csma-ping.cc b/src/csma/examples/csma-ping.cc index 8b4b9f267..e6fc626e4 100644 --- a/src/csma/examples/csma-ping.cc +++ b/src/csma/examples/csma-ping.cc @@ -32,6 +32,7 @@ #include "ns3/network-module.h" #include "ns3/csma-module.h" #include "ns3/applications-module.h" +#include "ns3/internet-module.h" using namespace ns3; diff --git a/src/csma/examples/csma-raw-ip-socket.cc b/src/csma/examples/csma-raw-ip-socket.cc index 9fba6e81d..6b708aec6 100644 --- a/src/csma/examples/csma-raw-ip-socket.cc +++ b/src/csma/examples/csma-raw-ip-socket.cc @@ -35,6 +35,7 @@ #include "ns3/network-module.h" #include "ns3/csma-module.h" #include "ns3/applications-module.h" +#include "ns3/internet-module.h" using namespace ns3; diff --git a/src/csma/examples/wscript b/src/csma/examples/wscript index 6f2afa7a5..d9dab7c01 100644 --- a/src/csma/examples/wscript +++ b/src/csma/examples/wscript @@ -13,9 +13,6 @@ def build(bld): obj = bld.create_ns3_program('csma-multicast', ['csma', 'internet']) obj.source = 'csma-multicast.cc' - obj = bld.create_ns3_program('csma-star', ['csma', 'internet']) - obj.source = 'csma-star.cc' - obj = bld.create_ns3_program('csma-raw-ip-socket', ['csma', 'internet']) obj.source = 'csma-raw-ip-socket.cc' diff --git a/src/csma/wscript b/src/csma/wscript index 4faeeda27..c5d10af5a 100644 --- a/src/csma/wscript +++ b/src/csma/wscript @@ -1,13 +1,12 @@ ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- def build(bld): - obj = bld.create_ns3_module('csma', ['network', 'point-to-point', 'applications', 'netanim']) + obj = bld.create_ns3_module('csma', ['network', 'applications']) obj.source = [ 'model/backoff.cc', 'model/csma-net-device.cc', 'model/csma-channel.cc', 'helper/csma-helper.cc', - 'helper/csma-star-helper.cc', ] headers = bld.new_task_gen('ns3header') headers.module = 'csma' @@ -16,7 +15,6 @@ def build(bld): 'model/csma-net-device.h', 'model/csma-channel.h', 'helper/csma-helper.h', - 'helper/csma-star-helper.h', ] if bld.env['ENABLE_EXAMPLES']: diff --git a/src/netanim/examples/dumbbell-animation.cc b/src/netanim/examples/dumbbell-animation.cc index ac26072cf..79f9d2f48 100644 --- a/src/netanim/examples/dumbbell-animation.cc +++ b/src/netanim/examples/dumbbell-animation.cc @@ -24,7 +24,7 @@ #include "ns3/point-to-point-module.h" #include "ns3/netanim-module.h" #include "ns3/applications-module.h" -#include "ns3/ipv4-global-routing-helper.h" +#include "ns3/point-to-point-layout-module.h" using namespace ns3; diff --git a/src/netanim/examples/grid-animation.cc b/src/netanim/examples/grid-animation.cc index 56f861a59..13b173ef8 100644 --- a/src/netanim/examples/grid-animation.cc +++ b/src/netanim/examples/grid-animation.cc @@ -24,7 +24,7 @@ #include "ns3/point-to-point-module.h" #include "ns3/netanim-module.h" #include "ns3/applications-module.h" -#include "ns3/ipv4-global-routing-helper.h" +#include "ns3/point-to-point-layout-module.h" using namespace ns3; diff --git a/src/netanim/examples/star-animation.cc b/src/netanim/examples/star-animation.cc index 335b32307..ac2b6d467 100644 --- a/src/netanim/examples/star-animation.cc +++ b/src/netanim/examples/star-animation.cc @@ -21,7 +21,7 @@ #include "ns3/internet-module.h" #include "ns3/point-to-point-module.h" #include "ns3/applications-module.h" -#include "ns3/ipv4-global-routing-helper.h" +#include "ns3/point-to-point-layout-module.h" // Network topology (default) // diff --git a/src/netanim/examples/wscript b/src/netanim/examples/wscript index d876812e1..271ae33bc 100644 --- a/src/netanim/examples/wscript +++ b/src/netanim/examples/wscript @@ -2,13 +2,13 @@ def build(bld): obj = bld.create_ns3_program('dumbbell-animation', - ['netanim', 'applications']) + ['netanim', 'applications', 'point-to-point-layout']) obj.source = 'dumbbell-animation.cc' obj = bld.create_ns3_program('grid-animation', - ['netanim', 'applications']) + ['netanim', 'applications', 'point-to-point-layout']) obj.source = 'grid-animation.cc' obj = bld.create_ns3_program('star-animation', - ['netanim', 'applications']) + ['netanim', 'applications', 'point-to-point-layout']) obj.source = 'star-animation.cc' diff --git a/src/netanim/model/animation-interface.cc b/src/netanim/model/animation-interface.cc index d0d1e6965..997953c70 100644 --- a/src/netanim/model/animation-interface.cc +++ b/src/netanim/model/animation-interface.cc @@ -21,8 +21,6 @@ #include #include -#include "ns3/netanim-config.h" - // Socket related includes #if defined(HAVE_SYS_SOCKET_H) && defined(HAVE_NETINET_IN_H) #include diff --git a/src/netanim/wscript b/src/netanim/wscript index ceed72466..d9360f1fc 100644 --- a/src/netanim/wscript +++ b/src/netanim/wscript @@ -1,22 +1,16 @@ ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- def build(bld): - module = bld.create_ns3_module('netanim', ['internet', 'point-to-point', 'mobility']) + module = bld.create_ns3_module('netanim', ['internet', 'mobility']) module.includes = '.' module.source = [ 'model/animation-interface.cc', - 'helper/point-to-point-dumbbell-helper.cc', - 'helper/point-to-point-grid-helper.cc', - 'helper/point-to-point-star-helper.cc', ] headers = bld.new_task_gen('ns3header') headers.module = 'netanim' headers.source = [ 'model/animation-interface.h', - 'helper/point-to-point-dumbbell-helper.h', - 'helper/point-to-point-grid-helper.h', - 'helper/point-to-point-star-helper.h', ] if (bld.env['ENABLE_EXAMPLES']): @@ -28,5 +22,4 @@ def build(bld): def configure(conf): conf.check(header_name='sys/socket.h', define_name='HAVE_SYS_SOCKET_H') conf.check(header_name='netinet/in.h', define_name='HAVE_NETINET_IN_H') - conf.write_config_header('ns3/netanim-config.h', top=True) diff --git a/src/olsr/examples/olsr-hna.cc b/src/olsr/examples/olsr-hna.cc index 9da857b1e..b6c53ef27 100644 --- a/src/olsr/examples/olsr-hna.cc +++ b/src/olsr/examples/olsr-hna.cc @@ -56,11 +56,9 @@ #include "ns3/config-store-module.h" #include "ns3/wifi-module.h" #include "ns3/csma-module.h" -#include "ns3/ipv4-list-routing.h" +#include "ns3/internet-module.h" #include "ns3/olsr-routing-protocol.h" #include "ns3/olsr-helper.h" -#include "ns3/ipv4-static-routing-helper.h" -#include "ns3/ipv4-list-routing-helper.h" #include #include diff --git a/src/netanim/helper/point-to-point-dumbbell-helper.cc b/src/point-to-point-layout/model/point-to-point-dumbbell.cc similarity index 99% rename from src/netanim/helper/point-to-point-dumbbell-helper.cc rename to src/point-to-point-layout/model/point-to-point-dumbbell.cc index 90217fbe3..1fcfacf1d 100644 --- a/src/netanim/helper/point-to-point-dumbbell-helper.cc +++ b/src/point-to-point-layout/model/point-to-point-dumbbell.cc @@ -23,7 +23,7 @@ // ns3 includes #include "ns3/animation-interface.h" -#include "ns3/point-to-point-dumbbell-helper.h" +#include "ns3/point-to-point-dumbbell.h" #include "ns3/constant-position-mobility-model.h" #include "ns3/node-list.h" diff --git a/src/netanim/helper/point-to-point-dumbbell-helper.h b/src/point-to-point-layout/model/point-to-point-dumbbell.h similarity index 100% rename from src/netanim/helper/point-to-point-dumbbell-helper.h rename to src/point-to-point-layout/model/point-to-point-dumbbell.h diff --git a/src/netanim/helper/point-to-point-grid-helper.cc b/src/point-to-point-layout/model/point-to-point-grid.cc similarity index 99% rename from src/netanim/helper/point-to-point-grid-helper.cc rename to src/point-to-point-layout/model/point-to-point-grid.cc index 51827081a..1e24bd28c 100644 --- a/src/netanim/helper/point-to-point-grid-helper.cc +++ b/src/point-to-point-layout/model/point-to-point-grid.cc @@ -16,7 +16,7 @@ * Author: Josh Pelkey */ -#include "ns3/point-to-point-grid-helper.h" +#include "ns3/point-to-point-grid.h" #include "ns3/animation-interface.h" #include "ns3/internet-stack-helper.h" #include "ns3/point-to-point-helper.h" diff --git a/src/netanim/helper/point-to-point-grid-helper.h b/src/point-to-point-layout/model/point-to-point-grid.h similarity index 100% rename from src/netanim/helper/point-to-point-grid-helper.h rename to src/point-to-point-layout/model/point-to-point-grid.h diff --git a/src/netanim/helper/point-to-point-star-helper.cc b/src/point-to-point-layout/model/point-to-point-star.cc similarity index 98% rename from src/netanim/helper/point-to-point-star-helper.cc rename to src/point-to-point-layout/model/point-to-point-star.cc index 48e4ee740..4a74b1857 100644 --- a/src/netanim/helper/point-to-point-star-helper.cc +++ b/src/point-to-point-layout/model/point-to-point-star.cc @@ -19,7 +19,7 @@ // ns3 includes #include "ns3/animation-interface.h" -#include "ns3/point-to-point-star-helper.h" +#include "ns3/point-to-point-star.h" #include "ns3/constant-position-mobility-model.h" #include "ns3/node-list.h" diff --git a/src/netanim/helper/point-to-point-star-helper.h b/src/point-to-point-layout/model/point-to-point-star.h similarity index 100% rename from src/netanim/helper/point-to-point-star-helper.h rename to src/point-to-point-layout/model/point-to-point-star.h diff --git a/src/point-to-point-layout/waf b/src/point-to-point-layout/waf new file mode 100644 index 000000000..3dcf598bc --- /dev/null +++ b/src/point-to-point-layout/waf @@ -0,0 +1 @@ +exec "`dirname "$0"`"/../../waf "$@" \ No newline at end of file diff --git a/src/point-to-point-layout/wscript b/src/point-to-point-layout/wscript new file mode 100644 index 000000000..a5639e452 --- /dev/null +++ b/src/point-to-point-layout/wscript @@ -0,0 +1,23 @@ +## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- + +def build(bld): + module = bld.create_ns3_module('point-to-point-layout', ['internet', 'point-to-point', 'mobility']) + module.includes = '.' + module.source = [ + 'model/point-to-point-dumbbell.cc', + 'model/point-to-point-grid.cc', + 'model/point-to-point-star.cc', + ] + + headers = bld.new_task_gen('ns3header') + headers.module = 'point-to-point-layout' + headers.source = [ + 'model/point-to-point-dumbbell.h', + 'model/point-to-point-grid.h', + 'model/point-to-point-star.h', + ] + + bld.ns3_python_bindings() + + + diff --git a/src/wimax/examples/wimax-multicast.cc b/src/wimax/examples/wimax-multicast.cc index ff0632df9..f9458a6ed 100644 --- a/src/wimax/examples/wimax-multicast.cc +++ b/src/wimax/examples/wimax-multicast.cc @@ -59,11 +59,8 @@ #include "ns3/csma-module.h" #include #include "ns3/global-route-manager.h" -#include "ns3/constant-position-mobility-model.h" -#include "ns3/random-waypoint-mobility-model.h" -#include "ns3/ipv4-static-routing-helper.h" -#include "ns3/ipv4-list-routing-helper.h" - +#include "ns3/mobility-module.h" +#include "ns3/internet-module.h" #include "ns3/vector.h" NS_LOG_COMPONENT_DEFINE ("WimaxMulticastSimulation"); diff --git a/src/wscript b/src/wscript index 3ca4d4adc..2d2898c58 100644 --- a/src/wscript +++ b/src/wscript @@ -57,6 +57,8 @@ all_modules = ( 'energy', 'tools', 'visualizer', + 'point-to-point-layout', + 'csma-layout', ) def set_options(opt):