From 8d5cbfe8febb8d25594187796766cd48232eaf4b Mon Sep 17 00:00:00 2001 From: Tim Schubert Date: Wed, 26 Aug 2020 20:55:59 +0200 Subject: [PATCH] Cleanup --- examples/leo-delay-tracing-example.cc | 35 +++++++++++++------ examples/wscript | 2 +- helper/leo-channel-helper.cc | 13 ++++++++ helper/leo-orbit-helper.h | 48 --------------------------- model/leo-lat-long.cc | 10 +++--- model/leo-lat-long.h | 2 ++ model/mock-channel.cc | 16 --------- model/mock-net-device.cc | 16 --------- test/ground-node-helper-test-suite.cc | 7 ++-- 9 files changed, 50 insertions(+), 99 deletions(-) delete mode 100644 helper/leo-orbit-helper.h diff --git a/examples/leo-delay-tracing-example.cc b/examples/leo-delay-tracing-example.cc index bd624cc..d0c9f90 100644 --- a/examples/leo-delay-tracing-example.cc +++ b/examples/leo-delay-tracing-example.cc @@ -6,6 +6,7 @@ #include "ns3/network-module.h" #include "ns3/aodv-module.h" #include "ns3/udp-server.h" +#include "ns3/epidemic-routing-module.h" using namespace ns3; @@ -34,6 +35,7 @@ int main (int argc, char *argv[]) uint64_t numGws; double interval; double duration; + std::string routingProto = "aodv"; cmd.AddValue("orbitFile", "CSV file with orbit parameters", orbitFile); cmd.AddValue("traceFile", "CSV file to store mobility trace in", traceFile); cmd.AddValue("precision", "ns3::LeoCircularOrbitMobilityModel::Precision"); @@ -44,6 +46,7 @@ int main (int argc, char *argv[]) cmd.AddValue("islRate", "Throughput of the ISL link", islRate); cmd.AddValue("constellation", "LEO constellation link settings name", constellation); cmd.AddValue("interval", "Echo interval", interval); + cmd.AddValue("routing", "Routing protocol", routingProto); cmd.AddValue("ttlThresh", "ns3::aodv::RoutingProtocol::TtlThreshold"); cmd.AddValue("routeTimeout", "ns3::aodv::RoutingProtocol::ActiveRouteTimeout"); cmd.Parse (argc, argv); @@ -80,18 +83,28 @@ int main (int argc, char *argv[]) utCh.SetConstellation (constellation); utNet = utCh.Install (satellites, stations); - //if (proto == "aodv") - // Install internet stack on nodes - AodvHelper aodv; - // This disabled is far better for performance (huge network) - aodv.Set ("EnableHello", BooleanValue (false)); - //aodv.Set ("TtlThreshold", UintegerValue (ttlThresh)); - aodv.Set ("RreqRateLimit", UintegerValue (1)); - aodv.Set ("RerrRateLimit", UintegerValue (1)); - //aodv.Set ("ActiveRouteTimeout", TimeValue (Seconds (routeTimeout))); - InternetStackHelper stack; - stack.SetRoutingHelper (aodv); + if (routingProto == "epidemic") + { + EpidemicHelper epidemic; + epidemic.Set ("HopCount", UintegerValue (50)); + //epidemic.Set ("QueueLength", UintegerValue (50)); + //epidemic.Set ("QueueEntryExpireTime", TimeValue (Seconds (100))); + //epidemic.Set ("BeaconInterval", TimeValue (Seconds (1))); + + stack.SetRoutingHelper (epidemic); + } + else + { + // Install internet stack on nodes + AodvHelper aodv; + aodv.Set ("EnableHello", BooleanValue (false)); + aodv.Set ("RreqRateLimit", UintegerValue (1)); + aodv.Set ("RerrRateLimit", UintegerValue (1)); + + stack.SetRoutingHelper (aodv); + } + stack.Install (satellites); stack.Install (stations); diff --git a/examples/wscript b/examples/wscript index 9dd00c3..4cb4aca 100644 --- a/examples/wscript +++ b/examples/wscript @@ -9,7 +9,7 @@ def build(bld): obj.source = 'leo-circular-orbit-tracing-example.cc' obj = bld.create_ns3_program('leo-delay', - ['core', 'leo', 'mobility', 'aodv']) + ['core', 'leo', 'mobility', 'aodv', 'epidemic-routing']) obj.source = 'leo-delay-tracing-example.cc' obj = bld.create_ns3_program('leo-bulk-send', diff --git a/helper/leo-channel-helper.cc b/helper/leo-channel-helper.cc index 4ce023a..41a2c27 100644 --- a/helper/leo-channel-helper.cc +++ b/helper/leo-channel-helper.cc @@ -9,6 +9,7 @@ #include "ns3/assert.h" #include "ns3/string.h" #include "ns3/data-rate.h" +#include "ns3/net-device-queue-interface.h" #include "../model/leo-mock-channel.h" #include "../model/leo-mock-net-device.h" @@ -347,6 +348,12 @@ LeoChannelHelper::Install (std::vector > &satellites, std::vectorAddDevice (dev); Ptr > queue = m_satQueueFactory.Create > (); dev->SetQueue (queue); + + // Aggregate NetDeviceQueueInterface objects + Ptr ndqi = CreateObject (); + ndqi->GetTxQueue (0)->ConnectQueueTraces (queue); + dev->AggregateObject (ndqi); + dev->Attach (channel); container.Add (dev); @@ -360,6 +367,12 @@ LeoChannelHelper::Install (std::vector > &satellites, std::vectorAddDevice (dev); Ptr > queue = m_gndQueueFactory.Create > (); dev->SetQueue (queue); + + // Aggregate NetDeviceQueueInterface objects + Ptr ndqi = CreateObject (); + ndqi->GetTxQueue (0)->ConnectQueueTraces (queue); + dev->AggregateObject (ndqi); + dev->Attach (channel); container.Add (dev); diff --git a/helper/leo-orbit-helper.h b/helper/leo-orbit-helper.h deleted file mode 100644 index 6a44225..0000000 --- a/helper/leo-orbit-helper.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ - -#ifndef LEO_ORBIT_NODE_HELPER_H -#define LEO_ORBIT_NODE_HELPER_H - -#include - -#include "ns3/object-factory.h" -#include "ns3/node-container.h" -#include "ns3/constant-position-mobility-model.h" - -/** - * \brief Builds a node container of nodes with constant positions - * - * Adds waypoints from file for each node. - */ - -namespace ns3 -{ - -class LeoGndNodeHelper -{ -public: - LeoGndNodeHelper (); - virtual ~LeoGndNodeHelper (); - - /** - * - * \param wpFile path to waypoint file - * \returns a node container containing nodes using the specified attributes - */ - NodeContainer Install (const std::string &wpFile); - - /** - * Set an attribute for each node - * - * \param name name of the attribute - * \param value value of the attribute - */ - void SetAttribute (std::string name, const AttributeValue &value); - -private: - ObjectFactory m_gndNodeFactory; -}; - -}; // namespace ns3 - -#endif diff --git a/model/leo-lat-long.cc b/model/leo-lat-long.cc index 6c2eb4a..278744e 100644 --- a/model/leo-lat-long.cc +++ b/model/leo-lat-long.cc @@ -6,15 +6,16 @@ namespace ns3 { std::ostream &operator << (std::ostream &os, const LeoLatLong &l) { - os << l.latitude << ":" << l.longitude; + os << l.label << "," << l.latitude << "," << l.longitude; return os; } std::istream &operator >> (std::istream &is, LeoLatLong &l) { - char c1; - is >> l.latitude >> c1 >> l.longitude; - if (c1 != ':') + char c1, c2; + is >> l.label >> c1 >> l.latitude >> c2 >> l.longitude; + if (c1 != ',' || + c2 != ',') { is.setstate (std::ios_base::failbit); } @@ -23,6 +24,7 @@ std::istream &operator >> (std::istream &is, LeoLatLong &l) LeoLatLong::LeoLatLong () : latitude (0), longitude (0) {} LeoLatLong::LeoLatLong (double la, double lo) : latitude (la), longitude (lo) {} +LeoLatLong::LeoLatLong (std::string label, double la, double lo) : latitude (la), longitude (lo) {} LeoLatLong::~LeoLatLong () {} }; diff --git a/model/leo-lat-long.h b/model/leo-lat-long.h index 3684432..936dbbc 100644 --- a/model/leo-lat-long.h +++ b/model/leo-lat-long.h @@ -12,8 +12,10 @@ class LeoLatLong public: LeoLatLong (); LeoLatLong (double latitude, double longitude); + LeoLatLong (std::string label, double latitude, double longitude); virtual ~LeoLatLong(); + std::string label; double latitude; double longitude; }; diff --git a/model/mock-channel.cc b/model/mock-channel.cc index 3e8845a..0a03f08 100644 --- a/model/mock-channel.cc +++ b/model/mock-channel.cc @@ -1,20 +1,4 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2007, 2008 University of Washington - * - * 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 diff --git a/model/mock-net-device.cc b/model/mock-net-device.cc index 050f9af..3767093 100644 --- a/model/mock-net-device.cc +++ b/model/mock-net-device.cc @@ -1,20 +1,4 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2007, 2008 University of Washington - * - * 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/log.h" #include "ns3/queue.h" diff --git a/test/ground-node-helper-test-suite.cc b/test/ground-node-helper-test-suite.cc index 201b6a9..8bfd570 100644 --- a/test/ground-node-helper-test-suite.cc +++ b/test/ground-node-helper-test-suite.cc @@ -38,7 +38,7 @@ EmptyGndNodeHelperTestCase::DoRun (void) std::vector gndWps = {}; LeoGndNodeHelper gndHelper; - NodeContainer nodes = gndHelper.Install ("contrib/leo/data/test/empty"); + NodeContainer nodes = gndHelper.Install ("hsksjhskjhs"); NS_ASSERT_MSG (nodes.GetN () == 0, "Empty position file produces non-empty node container"); } @@ -68,9 +68,10 @@ void SomeGndNodeHelperTestCase::DoRun (void) { LeoGndNodeHelper gndHelper; - NodeContainer nodes = gndHelper.Install ("contrib/leo/data/test/ground-stations.txt"); + NodeContainer nodes = gndHelper.Install (LeoLatLong ("station1", 50.1, 10.0), + LeoLatLong ("station2", -70.1, -21.0)); - NS_ASSERT_MSG (nodes.GetN () > 1, "No ground stations"); + NS_ASSERT_MSG (nodes.GetN () == 2, "No ground stations"); Ptr mob = nodes.Get (0)->GetObject (); NS_ASSERT_MSG (mob != Ptr (), "Mobility model is valid");