From 7265a5f3c024ed178b03dc10873b95ed2cbb1de7 Mon Sep 17 00:00:00 2001 From: Tom Henderson Date: Sun, 9 Sep 2007 23:24:31 -0700 Subject: [PATCH] adapt some example scripts to use the new PacketSink --- examples/simple-global-routing.cc | 22 ++++++++++++++++++++++ examples/simple-point-to-point.cc | 20 ++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/examples/simple-global-routing.cc b/examples/simple-global-routing.cc index 75879be23..882e94e53 100644 --- a/examples/simple-global-routing.cc +++ b/examples/simple-global-routing.cc @@ -65,6 +65,7 @@ #include "ns3/ipv4-route.h" #include "ns3/point-to-point-topology.h" #include "ns3/onoff-application.h" +#include "ns3/packet-sink.h" #include "ns3/global-route-manager.h" using namespace ns3; @@ -151,6 +152,17 @@ int main (int argc, char *argv[]) ooff->Start (Seconds (1.0)); ooff->Stop (Seconds (10.0)); + // Create a packet sink to receive these packets + // The last argument "true" disables output from the Receive callback + Ptr sink = Create ( + n3, + InetSocketAddress (Ipv4Address::GetAny (), 80), + "Udp", + true); + // Start the sink + sink->Start (Seconds (1.0)); + sink->Stop (Seconds (10.0)); + // Create a similar flow from n3 to n1, starting at time 1.1 seconds ooff = Create ( n3, @@ -162,6 +174,16 @@ int main (int argc, char *argv[]) ooff->Start (Seconds (1.1)); ooff->Stop (Seconds (10.0)); + // Create a packet sink to receive these packets + sink = Create ( + n1, + InetSocketAddress (Ipv4Address::GetAny (), 80), + "Udp", + true); + // Start the sink + sink->Start (Seconds (1.1)); + sink->Stop (Seconds (10.0)); + // Configure tracing of all enqueue, dequeue, and NetDevice receive events // Trace output will be sent to the simple-global-routing.tr file AsciiTrace asciitrace ("simple-global-routing.tr"); diff --git a/examples/simple-point-to-point.cc b/examples/simple-point-to-point.cc index 4e7657cdb..4e92ad460 100644 --- a/examples/simple-point-to-point.cc +++ b/examples/simple-point-to-point.cc @@ -64,6 +64,7 @@ #include "ns3/ipv4-route.h" #include "ns3/point-to-point-topology.h" #include "ns3/onoff-application.h" +#include "ns3/packet-sink.h" using namespace ns3; @@ -153,6 +154,15 @@ int main (int argc, char *argv[]) ooff->Start(Seconds(1.0)); ooff->Stop (Seconds(10.0)); + // Create an optional packet sink to receive these packets + Ptr sink = Create ( + n3, + InetSocketAddress (Ipv4Address::GetAny (), 80), + "Udp"); + // Start the sink + sink->Start (Seconds (1.0)); + sink->Stop (Seconds (10.0)); + // Create a similar flow from n3 to n1, starting at time 1.1 seconds ooff = Create ( n3, @@ -164,6 +174,16 @@ int main (int argc, char *argv[]) ooff->Start(Seconds(1.1)); ooff->Stop (Seconds(10.0)); + // Create a packet sink to receive these packets + sink = Create ( + n1, + InetSocketAddress (Ipv4Address::GetAny (), 80), + "Udp"); + // Start the sink + sink->Start (Seconds (1.1)); + sink->Stop (Seconds (10.0)); + sink->SetQuiet (); // disable output from the Receive callback + // Here, finish off packet routing configuration // This will likely set by some global StaticRouting object in the future Ptr ipv4;