From c72b06f934d40ac3bfbc3ef9ee6a2de6630015b3 Mon Sep 17 00:00:00 2001 From: John Abraham Date: Fri, 13 May 2011 16:15:13 -0700 Subject: [PATCH] Bug 1143 CsmaStarHelper::GetHubDevices) returns spoke devices, not hub devices --- src/csma-layout/model/csma-star-helper.cc | 2 +- src/csma/helper/csma-star-helper.cc | 111 ------------------- src/csma/helper/csma-star-helper.h | 123 ---------------------- src/csma/test/examples-to-run.py | 1 - 4 files changed, 1 insertion(+), 236 deletions(-) delete mode 100644 src/csma/helper/csma-star-helper.cc delete mode 100644 src/csma/helper/csma-star-helper.h diff --git a/src/csma-layout/model/csma-star-helper.cc b/src/csma-layout/model/csma-star-helper.cc index 8aa977230..b4089f3a1 100644 --- a/src/csma-layout/model/csma-star-helper.cc +++ b/src/csma-layout/model/csma-star-helper.cc @@ -62,7 +62,7 @@ CsmaStarHelper::GetSpokeNode (uint32_t i) const NetDeviceContainer CsmaStarHelper::GetHubDevices () const { - return m_spokeDevices; + return m_hubDevices; } NetDeviceContainer diff --git a/src/csma/helper/csma-star-helper.cc b/src/csma/helper/csma-star-helper.cc deleted file mode 100644 index e489eab86..000000000 --- a/src/csma/helper/csma-star-helper.cc +++ /dev/null @@ -1,111 +0,0 @@ -/* -*- 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/helper/csma-star-helper.h b/src/csma/helper/csma-star-helper.h deleted file mode 100644 index 89217538a..000000000 --- a/src/csma/helper/csma-star-helper.h +++ /dev/null @@ -1,123 +0,0 @@ -/* -*- 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/test/examples-to-run.py b/src/csma/test/examples-to-run.py index 2984380da..909251f3c 100644 --- a/src/csma/test/examples-to-run.py +++ b/src/csma/test/examples-to-run.py @@ -14,7 +14,6 @@ cpp_examples = [ ("csma-packet-socket", "True", "True"), ("csma-ping", "True", "True"), ("csma-raw-ip-socket", "True", "True"), - ("csma-star", "True", "True"), ] # A list of Python examples to run in order to ensure that they remain