From 6b5b86f34372778723a76721af0c42feeb67e887 Mon Sep 17 00:00:00 2001 From: Craig Dowell Date: Tue, 9 Oct 2007 18:02:32 -0700 Subject: [PATCH] tutorial topologies --- tutorial/tutorial-linear-dumbbell.cc | 62 +++++++++++++++++++++------- tutorial/tutorial-star-routing.cc | 6 +-- tutorial/tutorial-star.cc | 6 +-- 3 files changed, 54 insertions(+), 20 deletions(-) diff --git a/tutorial/tutorial-linear-dumbbell.cc b/tutorial/tutorial-linear-dumbbell.cc index e203ef9f3..c39abd963 100644 --- a/tutorial/tutorial-linear-dumbbell.cc +++ b/tutorial/tutorial-linear-dumbbell.cc @@ -51,10 +51,11 @@ int main (int argc, char *argv[]) { LogComponentEnable ("DumbbellSimulation", LOG_LEVEL_INFO); -// LogComponentEnableAll (LOG_LEVEL_ALL, LOG_DECORATE_ALL); NS_LOG_INFO ("Dumbbell Topology Simulation"); - +// +// Create the lan on the left side of the dumbbell. +// Ptr n0 = Create (); Ptr n1 = Create (); Ptr n2 = Create (); @@ -79,7 +80,9 @@ main (int argc, char *argv[]) CsmaIpv4Topology::AddIpv4Address (n1, nd1, "10.1.1.2", "255.255.255.0"); CsmaIpv4Topology::AddIpv4Address (n2, nd2, "10.1.1.3", "255.255.255.0"); CsmaIpv4Topology::AddIpv4Address (n3, nd3, "10.1.1.4", "255.255.255.0"); - +// +// Create the lan on the right side of the dumbbell. +// Ptr n4 = Create (); Ptr n5 = Create (); Ptr n6 = Create (); @@ -104,31 +107,62 @@ main (int argc, char *argv[]) CsmaIpv4Topology::AddIpv4Address (n5, nd5, "10.1.2.2", "255.255.255.0"); CsmaIpv4Topology::AddIpv4Address (n6, nd6, "10.1.2.3", "255.255.255.0"); CsmaIpv4Topology::AddIpv4Address (n7, nd7, "10.1.2.4", "255.255.255.0"); - +// +// Create the point-to-point link to connect the two lans. +// Ptr link = PointToPointTopology::AddPointToPointLink ( n3, n4, DataRate (38400), MilliSeconds (20)); PointToPointTopology::AddIpv4Addresses (link, n3, "10.1.3.1", n4, "10.1.3.2"); - +// +// Create data flows across the link: +// n0 ==> n4 ==> n0 +// n1 ==> n5 ==> n1 +// n2 ==> n6 ==> n2 +// n3 ==> n7 ==> n3 +// uint16_t port = 7; - Ptr client = Create (n0, "10.1.2.4", port, - 1, Seconds(1.), 1024); + Ptr client0 = Create (n0, "10.1.2.1", port, + 100, Seconds(.01), 1024); + Ptr client1 = Create (n1, "10.1.2.2", port, + 100, Seconds(.01), 1024); + Ptr client2 = Create (n2, "10.1.2.3", port, + 100, Seconds(.01), 1024); + Ptr client3 = Create (n3, "10.1.2.4", port, + 100, Seconds(.01), 1024); - Ptr server = Create (n7, port); + Ptr server4 = Create (n4, port); + Ptr server5 = Create (n5, port); + Ptr server6 = Create (n6, port); + Ptr server7 = Create (n7, port); - server->Start(Seconds(1.)); - client->Start(Seconds(2.)); + server4->Start(Seconds(1.)); + server5->Start(Seconds(1.)); + server6->Start(Seconds(1.)); + server7->Start(Seconds(1.)); - server->Stop (Seconds(10.)); - client->Stop (Seconds(10.)); + client0->Start(Seconds(2.)); + client1->Start(Seconds(2.1)); + client2->Start(Seconds(2.2)); + client3->Start(Seconds(2.3)); - AsciiTrace asciitrace ("tutorial-4.tr"); + server4->Stop (Seconds(10.)); + server5->Stop (Seconds(10.)); + server6->Stop (Seconds(10.)); + server7->Stop (Seconds(10.)); + + client0->Stop (Seconds(10.)); + client1->Stop (Seconds(10.)); + client2->Stop (Seconds(10.)); + client3->Stop (Seconds(10.)); + + AsciiTrace asciitrace ("tutorial.tr"); asciitrace.TraceAllQueues (); asciitrace.TraceAllNetDeviceRx (); - PcapTrace pcaptrace ("tutorial-4.pcap"); + PcapTrace pcaptrace ("tutorial.pcap"); pcaptrace.TraceAllIp (); GlobalRouteManager::PopulateRoutingTables (); diff --git a/tutorial/tutorial-star-routing.cc b/tutorial/tutorial-star-routing.cc index 765ac7728..a0db26180 100644 --- a/tutorial/tutorial-star-routing.cc +++ b/tutorial/tutorial-star-routing.cc @@ -29,7 +29,7 @@ #include "ns3/pcap-trace.h" #include "ns3/global-route-manager.h" -NS_LOG_COMPONENT_DEFINE ("PointToPointSimulation"); +NS_LOG_COMPONENT_DEFINE ("StarRoutingSimulation"); using namespace ns3; @@ -46,9 +46,9 @@ using namespace ns3; int main (int argc, char *argv[]) { - LogComponentEnable ("PointToPointSimulation", LOG_LEVEL_INFO); + LogComponentEnable ("StarRoutingSimulation", LOG_LEVEL_INFO); - NS_LOG_INFO ("Point to Point Topology Simulation"); + NS_LOG_INFO ("Star Topology with Routing Simulation"); Ptr n0 = Create (); Ptr n1 = Create (); diff --git a/tutorial/tutorial-star.cc b/tutorial/tutorial-star.cc index dafc5a82a..38ff6100e 100644 --- a/tutorial/tutorial-star.cc +++ b/tutorial/tutorial-star.cc @@ -29,7 +29,7 @@ #include "ns3/pcap-trace.h" #include "ns3/global-route-manager.h" -NS_LOG_COMPONENT_DEFINE ("PointToPointSimulation"); +NS_LOG_COMPONENT_DEFINE ("StarSimulation"); using namespace ns3; @@ -46,9 +46,9 @@ using namespace ns3; int main (int argc, char *argv[]) { - LogComponentEnable ("PointToPointSimulation", LOG_LEVEL_INFO); + LogComponentEnable ("StarSimulation", LOG_LEVEL_INFO); - NS_LOG_INFO ("Point to Point Topology Simulation"); + NS_LOG_INFO ("Star Topology Simulation"); Ptr n0 = Create (); Ptr n1 = Create ();