Further alignment of simple-point-to-point.cc with ns-2/simple.tcl (add TCP)
authorTom Henderson <tomh@tomh.org>
Sun Feb 03 14:34:10 2008 -0800 (2008-02-03)
changeset 2309432ccd1339d4
parent 2308 7c34ef595e3e
child 2310 52e0cd1de091
Further alignment of simple-point-to-point.cc with ns-2/simple.tcl (add TCP)
examples/simple-point-to-point.cc
src/applications/onoff/onoff-application.cc
     1.1 --- a/examples/simple-point-to-point.cc	Sun Feb 03 19:09:35 2008 +0000
     1.2 +++ b/examples/simple-point-to-point.cc	Sun Feb 03 14:34:10 2008 -0800
     1.3 @@ -72,29 +72,7 @@
     1.4    // Users may find it convenient to turn on explicit debugging
     1.5    // for selected modules; the below lines suggest how to do this
     1.6  #if 0 
     1.7 -  LogComponentEnable ("SimplePointToPointExample", LOG_LEVEL_INFO);
     1.8 -
     1.9 -  LogComponentEnable("Object", LOG_LEVEL_ALL);
    1.10 -  LogComponentEnable("Queue", LOG_LEVEL_ALL);
    1.11 -  LogComponentEnable("DropTailQueue", LOG_LEVEL_ALL);
    1.12 -  LogComponentEnable("Channel", LOG_LEVEL_ALL);
    1.13 -  LogComponentEnable("CsmaChannel", LOG_LEVEL_ALL);
    1.14 -  LogComponentEnable("NetDevice", LOG_LEVEL_ALL);
    1.15 -  LogComponentEnable("CsmaNetDevice", LOG_LEVEL_ALL);
    1.16 -  LogComponentEnable("Ipv4L3Protocol", LOG_LEVEL_ALL);
    1.17 -  LogComponentEnable("PacketSocket", LOG_LEVEL_ALL);
    1.18 -  LogComponentEnable("Socket", LOG_LEVEL_ALL);
    1.19 -  LogComponentEnable("UdpSocket", LOG_LEVEL_ALL);
    1.20 -  LogComponentEnable("UdpL4Protocol", LOG_LEVEL_ALL);
    1.21 -  LogComponentEnable("Ipv4L3Protocol", LOG_LEVEL_ALL);
    1.22 -  LogComponentEnable("Ipv4StaticRouting", LOG_LEVEL_ALL);
    1.23 -  LogComponentEnable("Ipv4Interface", LOG_LEVEL_ALL);
    1.24 -  LogComponentEnable("ArpIpv4Interface", LOG_LEVEL_ALL);
    1.25 -  LogComponentEnable("Ipv4LoopbackInterface", LOG_LEVEL_ALL);
    1.26 -  LogComponentEnable("OnOffApplication", LOG_LEVEL_ALL);
    1.27 -  LogComponentEnable("PacketSinkApplication", LOG_LEVEL_ALL);
    1.28 -  LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_ALL);
    1.29 -  LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_ALL);
    1.30 +  LogComponentEnable ("SimplePointToPointExample", LOG_LEVEL_ALL);
    1.31  #endif
    1.32  
    1.33    // Set up some default values for the simulation.  Use the Bind()
    1.34 @@ -108,8 +86,6 @@
    1.35    DefaultValue::Bind ("OnOffApplicationPacketSize", "210");
    1.36    DefaultValue::Bind ("OnOffApplicationDataRate", "448kb/s");
    1.37  
    1.38 -  //DefaultValue::Bind ("DropTailQueue::m_maxPackets", 30);   
    1.39 -
    1.40    // Allow the user to override any of the defaults and the above
    1.41    // Bind()s at run-time, via command-line arguments
    1.42    CommandLine::Parse (argc, argv);
    1.43 @@ -170,8 +146,7 @@
    1.44      ConstantVariable(1), 
    1.45      ConstantVariable(0));
    1.46    // Start the application
    1.47 -  ooff->Start(Seconds(1.0));
    1.48 -  ooff->Stop (Seconds(10.0));
    1.49 +  ooff->Start (Seconds(1.0));
    1.50  
    1.51    // Create an optional packet sink to receive these packets
    1.52    Ptr<PacketSink> sink = CreateObject<PacketSink> (
    1.53 @@ -180,7 +155,6 @@
    1.54      "Udp");
    1.55    // Start the sink
    1.56    sink->Start (Seconds (1.0));
    1.57 -  sink->Stop (Seconds (10.0));
    1.58  
    1.59    // Create a similar flow from n3 to n1, starting at time 1.1 seconds
    1.60    ooff = CreateObject<OnOffApplication> (
    1.61 @@ -191,7 +165,6 @@
    1.62      ConstantVariable(0));
    1.63    // Start the application
    1.64    ooff->Start(Seconds(1.1));
    1.65 -  ooff->Stop (Seconds(10.0));
    1.66  
    1.67    // Create a packet sink to receive these packets
    1.68    sink = CreateObject<PacketSink> (
    1.69 @@ -200,7 +173,27 @@
    1.70      "Udp");
    1.71    // Start the sink
    1.72    sink->Start (Seconds (1.1));
    1.73 -  sink->Stop (Seconds (10.0));
    1.74 +
    1.75 +  // TCP
    1.76 +  // Create a file transfer from n0 to n3, starting at time 1.2
    1.77 +  uint16_t servPort = 500;
    1.78 +
    1.79 +  ooff = CreateObject<OnOffApplication> (
    1.80 +    n0, 
    1.81 +    InetSocketAddress ("10.1.3.2", servPort), 
    1.82 +    "Tcp",
    1.83 +    ConstantVariable(1), 
    1.84 +    ConstantVariable(0));
    1.85 +  // Start the application
    1.86 +  ooff->Start (Seconds(1.2));
    1.87 +  ooff->Stop (Seconds(1.35));
    1.88 +
    1.89 +  // Create a packet sink to receive these TCP packets
    1.90 +  sink = Create<PacketSink> (
    1.91 +    n3,
    1.92 +    InetSocketAddress (Ipv4Address::GetAny (), servPort),
    1.93 +    "Tcp");
    1.94 +  sink->Start (Seconds (1.2));
    1.95  
    1.96    // Here, finish off packet routing configuration
    1.97    // This will likely set by some global StaticRouting object in the future
    1.98 @@ -227,7 +220,7 @@
    1.99    pcaptrace.TraceAllIp ();
   1.100  
   1.101    NS_LOG_INFO ("Run Simulation.");
   1.102 -  Simulator::StopAt (Seconds (10));
   1.103 +  Simulator::StopAt (Seconds (3.0));
   1.104    Simulator::Run ();    
   1.105    Simulator::Destroy ();
   1.106    NS_LOG_INFO ("Done.");
     2.1 --- a/src/applications/onoff/onoff-application.cc	Sun Feb 03 19:09:35 2008 +0000
     2.2 +++ b/src/applications/onoff/onoff-application.cc	Sun Feb 03 14:34:10 2008 -0800
     2.3 @@ -195,6 +195,7 @@
     2.4    NS_LOG_FUNCTION;
     2.5  
     2.6    Simulator::Cancel(m_sendEvent);
     2.7 +  m_socket->Close ();
     2.8  }
     2.9  
    2.10  // Private helpers