20 #include "ns3/abort.h"
22 #include "ns3/pcap-file.h"
23 #include "ns3/config.h"
24 #include "ns3/string.h"
25 #include "ns3/uinteger.h"
26 #include "ns3/data-rate.h"
27 #include "ns3/inet-socket-address.h"
28 #include "ns3/point-to-point-helper.h"
29 #include "ns3/csma-helper.h"
30 #include "ns3/internet-stack-helper.h"
31 #include "ns3/ipv4-global-routing-helper.h"
32 #include "ns3/ipv4-address-helper.h"
33 #include "ns3/packet-sink-helper.h"
34 #include "ns3/tcp-socket-factory.h"
35 #include "ns3/node-container.h"
36 #include "ns3/simulator.h"
55 virtual void DoRun (
void);
65 :
TestCase (
"Check that ns-3 TCP successfully transfers an application data write of various sizes (point-to-point)"),
66 m_writeResults (false)
79 uint16_t sinkPort = 50000;
80 double sinkStopTime = 40;
81 double writerStopTime = 30;
82 double simStopTime = 60;
83 Time sinkStopTimeObj = Seconds (sinkStopTime);
84 Time writerStopTimeObj = Seconds (writerStopTime);
85 Time simStopTimeObj= Seconds (simStopTime);
91 pointToPoint.SetDeviceAttribute (
"DataRate",
StringValue (
"5Mbps"));
92 pointToPoint.SetChannelAttribute (
"Delay",
StringValue (
"2ms"));
95 devices = pointToPoint.Install (n0, n1);
101 address.
SetBase (
"10.1.1.0",
"255.255.255.252");
106 socketWriter->
Setup (n0, sinkAddress);
115 apps.
Start (Seconds (0.0));
116 apps.
Stop (sinkStopTimeObj);
123 Simulator::Schedule (Seconds (10), &SocketWriter::Write, socketWriter, 1);
125 Simulator::Schedule (Seconds (12), &SocketWriter::Write, socketWriter, 10);
127 Simulator::Schedule (Seconds (14), &SocketWriter::Write, socketWriter, 100);
129 Simulator::Schedule (Seconds (16), &SocketWriter::Write, socketWriter, 1000);
132 Simulator::Schedule (writerStopTimeObj, &SocketWriter::Close, socketWriter);
136 pointToPoint.EnablePcapAll (
"tcp-socket-test-case-1");
139 Simulator::Stop (simStopTimeObj);
141 Simulator::Destroy ();
160 virtual void DoRun (
void);
170 :
TestCase (
"Check to see that ns-3 TCP successfully transfers an application data write of various sizes (CSMA)"),
171 m_writeResults (false)
184 uint16_t sinkPort = 50000;
185 double sinkStopTime = 40;
186 double writerStopTime = 30;
187 double simStopTime = 60;
188 Time sinkStopTimeObj = Seconds (sinkStopTime);
189 Time writerStopTimeObj = Seconds (writerStopTime);
190 Time simStopTimeObj= Seconds (simStopTime);
204 devices = csma.
Install (nodes);
210 address.
SetBase (
"10.1.1.0",
"255.255.255.252");
215 socketWriter->
Setup (n0, sinkAddress);
224 apps.
Start (Seconds (0.0));
225 apps.
Stop (sinkStopTimeObj);
233 Simulator::Schedule (Seconds (10), &SocketWriter::Write, socketWriter, 1);
235 Simulator::Schedule (Seconds (12), &SocketWriter::Write, socketWriter, 10);
237 Simulator::Schedule (Seconds (14), &SocketWriter::Write, socketWriter, 100);
239 Simulator::Schedule (Seconds (16), &SocketWriter::Write, socketWriter, 1000);
242 Simulator::Schedule (Seconds (16), &SocketWriter::Write, socketWriter, 1001);
245 Simulator::Schedule (writerStopTimeObj, &SocketWriter::Close, socketWriter);
251 Simulator::Stop (simStopTimeObj);
253 Simulator::Destroy ();