A Discrete-Event Network Simulator
API
tcp-variants-comparison.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2013 ResiliNets, ITTC, University of Kansas
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Authors: Justin P. Rohrer, Truc Anh N. Nguyen <annguyen@ittc.ku.edu>, Siddharth Gangadhar <siddharth@ittc.ku.edu>
19 *
20 * James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
21 * ResiliNets Research Group http://wiki.ittc.ku.edu/resilinets
22 * Information and Telecommunication Technology Center (ITTC)
23 * and Department of Electrical Engineering and Computer Science
24 * The University of Kansas Lawrence, KS USA.
25 *
26 * Work supported in part by NSF FIND (Future Internet Design) Program
27 * under grant CNS-0626918 (Postmodern Internet Architecture),
28 * NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimentation on GENI),
29 * US Department of Defense (DoD), and ITTC at The University of Kansas.
30 *
31 * “TCP Westwood(+) Protocol Implementation in ns-3”
32 * Siddharth Gangadhar, Trúc Anh Ngọc Nguyễn , Greeshma Umapathi, and James P.G. Sterbenz,
33 * ICST SIMUTools Workshop on ns-3 (WNS3), Cannes, France, March 2013
34 */
35
36#include <iostream>
37#include <fstream>
38#include <string>
39
40#include "ns3/core-module.h"
41#include "ns3/network-module.h"
42#include "ns3/internet-module.h"
43#include "ns3/point-to-point-module.h"
44#include "ns3/applications-module.h"
45#include "ns3/error-model.h"
46#include "ns3/tcp-header.h"
47#include "ns3/udp-header.h"
48#include "ns3/enum.h"
49#include "ns3/event-id.h"
50#include "ns3/flow-monitor-helper.h"
51#include "ns3/ipv4-global-routing-helper.h"
52#include "ns3/traffic-control-module.h"
53
54using namespace ns3;
55
56NS_LOG_COMPONENT_DEFINE ("TcpVariantsComparison");
57
58static std::map<uint32_t, bool> firstCwnd;
59static std::map<uint32_t, bool> firstSshThr;
60static std::map<uint32_t, bool> firstRtt;
61static std::map<uint32_t, bool> firstRto;
62static std::map<uint32_t, Ptr<OutputStreamWrapper>> cWndStream;
63static std::map<uint32_t, Ptr<OutputStreamWrapper>> ssThreshStream;
64static std::map<uint32_t, Ptr<OutputStreamWrapper>> rttStream;
65static std::map<uint32_t, Ptr<OutputStreamWrapper>> rtoStream;
66static std::map<uint32_t, Ptr<OutputStreamWrapper>> nextTxStream;
67static std::map<uint32_t, Ptr<OutputStreamWrapper>> nextRxStream;
68static std::map<uint32_t, Ptr<OutputStreamWrapper>> inFlightStream;
69static std::map<uint32_t, uint32_t> cWndValue;
70static std::map<uint32_t, uint32_t> ssThreshValue;
71
72static uint32_t
73GetNodeIdFromContext (std::string context)
74{
75 std::size_t const n1 = context.find_first_of ("/", 1);
76 std::size_t const n2 = context.find_first_of ("/", n1 + 1);
77 return std::stoul (context.substr (n1 + 1, n2 - n1 - 1));
78}
79
80static void
81CwndTracer (std::string context, uint32_t oldval, uint32_t newval)
82{
83 uint32_t nodeId = GetNodeIdFromContext (context);
84
85 if (firstCwnd[nodeId])
86 {
87 *cWndStream[nodeId]->GetStream () << "0.0 " << oldval << std::endl;
88 firstCwnd[nodeId] = false;
89 }
90 *cWndStream[nodeId]->GetStream () << Simulator::Now ().GetSeconds () << " " << newval << std::endl;
91 cWndValue[nodeId] = newval;
92
93 if (!firstSshThr[nodeId])
94 {
95 *ssThreshStream[nodeId]->GetStream ()
96 << Simulator::Now ().GetSeconds () << " " << ssThreshValue[nodeId] << std::endl;
97 }
98}
99
100static void
101SsThreshTracer (std::string context, uint32_t oldval, uint32_t newval)
102{
103 uint32_t nodeId = GetNodeIdFromContext (context);
104
105 if (firstSshThr[nodeId])
106 {
107 *ssThreshStream[nodeId]->GetStream () << "0.0 " << oldval << std::endl;
108 firstSshThr[nodeId] = false;
109 }
110 *ssThreshStream[nodeId]->GetStream () << Simulator::Now ().GetSeconds () << " " << newval << std::endl;
111 ssThreshValue[nodeId] = newval;
112
113 if (!firstCwnd[nodeId])
114 {
115 *cWndStream[nodeId]->GetStream () << Simulator::Now ().GetSeconds () << " " << cWndValue[nodeId] << std::endl;
116 }
117}
118
119static void
120RttTracer (std::string context, Time oldval, Time newval)
121{
122 uint32_t nodeId = GetNodeIdFromContext (context);
123
124 if (firstRtt[nodeId])
125 {
126 *rttStream[nodeId]->GetStream () << "0.0 " << oldval.GetSeconds () << std::endl;
127 firstRtt[nodeId] = false;
128 }
129 *rttStream[nodeId]->GetStream () << Simulator::Now ().GetSeconds () << " " << newval.GetSeconds () << std::endl;
130}
131
132static void
133RtoTracer (std::string context, Time oldval, Time newval)
134{
135 uint32_t nodeId = GetNodeIdFromContext (context);
136
137 if (firstRto[nodeId])
138 {
139 *rtoStream[nodeId]->GetStream () << "0.0 " << oldval.GetSeconds () << std::endl;
140 firstRto[nodeId] = false;
141 }
142 *rtoStream[nodeId]->GetStream () << Simulator::Now ().GetSeconds () << " " << newval.GetSeconds () << std::endl;
143}
144
145static void
146NextTxTracer (std::string context, [[maybe_unused]] SequenceNumber32 old, SequenceNumber32 nextTx)
147{
148 uint32_t nodeId = GetNodeIdFromContext (context);
149
150 *nextTxStream[nodeId]->GetStream () << Simulator::Now ().GetSeconds () << " " << nextTx << std::endl;
151}
152
153static void
154InFlightTracer (std::string context, [[maybe_unused]] uint32_t old, uint32_t inFlight)
155{
156 uint32_t nodeId = GetNodeIdFromContext (context);
157
158 *inFlightStream[nodeId]->GetStream () << Simulator::Now ().GetSeconds () << " " << inFlight << std::endl;
159}
160
161static void
162NextRxTracer (std::string context, [[maybe_unused]] SequenceNumber32 old, SequenceNumber32 nextRx)
163{
164 uint32_t nodeId = GetNodeIdFromContext (context);
165
166 *nextRxStream[nodeId]->GetStream () << Simulator::Now ().GetSeconds () << " " << nextRx << std::endl;
167}
168
169static void
170TraceCwnd (std::string cwnd_tr_file_name, uint32_t nodeId)
171{
172 AsciiTraceHelper ascii;
173 cWndStream[nodeId] = ascii.CreateFileStream (cwnd_tr_file_name.c_str ());
174 Config::Connect ("/NodeList/" + std::to_string (nodeId) + "/$ns3::TcpL4Protocol/SocketList/0/CongestionWindow",
176}
177
178static void
179TraceSsThresh (std::string ssthresh_tr_file_name, uint32_t nodeId)
180{
181 AsciiTraceHelper ascii;
182 ssThreshStream[nodeId] = ascii.CreateFileStream (ssthresh_tr_file_name.c_str ());
183 Config::Connect ("/NodeList/" + std::to_string (nodeId) + "/$ns3::TcpL4Protocol/SocketList/0/SlowStartThreshold",
185}
186
187static void
188TraceRtt (std::string rtt_tr_file_name, uint32_t nodeId)
189{
190 AsciiTraceHelper ascii;
191 rttStream[nodeId] = ascii.CreateFileStream (rtt_tr_file_name.c_str ());
192 Config::Connect ("/NodeList/" + std::to_string (nodeId) + "/$ns3::TcpL4Protocol/SocketList/0/RTT",
194}
195
196static void
197TraceRto (std::string rto_tr_file_name, uint32_t nodeId)
198{
199 AsciiTraceHelper ascii;
200 rtoStream[nodeId] = ascii.CreateFileStream (rto_tr_file_name.c_str ());
201 Config::Connect ("/NodeList/" + std::to_string (nodeId) + "/$ns3::TcpL4Protocol/SocketList/0/RTO",
203}
204
205static void
206TraceNextTx (std::string &next_tx_seq_file_name, uint32_t nodeId)
207{
208 AsciiTraceHelper ascii;
209 nextTxStream[nodeId] = ascii.CreateFileStream (next_tx_seq_file_name.c_str ());
210 Config::Connect ("/NodeList/" + std::to_string (nodeId) + "/$ns3::TcpL4Protocol/SocketList/0/NextTxSequence",
212}
213
214static void
215TraceInFlight (std::string &in_flight_file_name, uint32_t nodeId)
216{
217 AsciiTraceHelper ascii;
218 inFlightStream[nodeId] = ascii.CreateFileStream (in_flight_file_name.c_str ());
219 Config::Connect ("/NodeList/" + std::to_string (nodeId) + "/$ns3::TcpL4Protocol/SocketList/0/BytesInFlight",
221}
222
223static void
224TraceNextRx (std::string &next_rx_seq_file_name, uint32_t nodeId)
225{
226 AsciiTraceHelper ascii;
227 nextRxStream[nodeId] = ascii.CreateFileStream (next_rx_seq_file_name.c_str ());
228 Config::Connect ("/NodeList/" + std::to_string (nodeId) +
229 "/$ns3::TcpL4Protocol/SocketList/1/RxBuffer/NextRxSequence",
231}
232
233int main (int argc, char *argv[])
234{
235 std::string transport_prot = "TcpWestwood";
236 double error_p = 0.0;
237 std::string bandwidth = "2Mbps";
238 std::string delay = "0.01ms";
239 std::string access_bandwidth = "10Mbps";
240 std::string access_delay = "45ms";
241 bool tracing = false;
242 std::string prefix_file_name = "TcpVariantsComparison";
243 uint64_t data_mbytes = 0;
244 uint32_t mtu_bytes = 400;
245 uint16_t num_flows = 1;
246 double duration = 100.0;
247 uint32_t run = 0;
248 bool flow_monitor = false;
249 bool pcap = false;
250 bool sack = true;
251 std::string queue_disc_type = "ns3::PfifoFastQueueDisc";
252 std::string recovery = "ns3::TcpClassicRecovery";
253
254
255 CommandLine cmd (__FILE__);
256 cmd.AddValue ("transport_prot", "Transport protocol to use: TcpNewReno, TcpLinuxReno, "
257 "TcpHybla, TcpHighSpeed, TcpHtcp, TcpVegas, TcpScalable, TcpVeno, "
258 "TcpBic, TcpYeah, TcpIllinois, TcpWestwood, TcpWestwoodPlus, TcpLedbat, "
259 "TcpLp, TcpDctcp, TcpCubic, TcpBbr", transport_prot);
260 cmd.AddValue ("error_p", "Packet error rate", error_p);
261 cmd.AddValue ("bandwidth", "Bottleneck bandwidth", bandwidth);
262 cmd.AddValue ("delay", "Bottleneck delay", delay);
263 cmd.AddValue ("access_bandwidth", "Access link bandwidth", access_bandwidth);
264 cmd.AddValue ("access_delay", "Access link delay", access_delay);
265 cmd.AddValue ("tracing", "Flag to enable/disable tracing", tracing);
266 cmd.AddValue ("prefix_name", "Prefix of output trace file", prefix_file_name);
267 cmd.AddValue ("data", "Number of Megabytes of data to transmit", data_mbytes);
268 cmd.AddValue ("mtu", "Size of IP packets to send in bytes", mtu_bytes);
269 cmd.AddValue ("num_flows", "Number of flows", num_flows);
270 cmd.AddValue ("duration", "Time to allow flows to run in seconds", duration);
271 cmd.AddValue ("run", "Run index (for setting repeatable seeds)", run);
272 cmd.AddValue ("flow_monitor", "Enable flow monitor", flow_monitor);
273 cmd.AddValue ("pcap_tracing", "Enable or disable PCAP tracing", pcap);
274 cmd.AddValue ("queue_disc_type", "Queue disc type for gateway (e.g. ns3::CoDelQueueDisc)", queue_disc_type);
275 cmd.AddValue ("sack", "Enable or disable SACK option", sack);
276 cmd.AddValue ("recovery", "Recovery algorithm type to use (e.g., ns3::TcpPrrRecovery", recovery);
277 cmd.Parse (argc, argv);
278
279 transport_prot = std::string ("ns3::") + transport_prot;
280
281 SeedManager::SetSeed (1);
282 SeedManager::SetRun (run);
283
284 // User may find it convenient to enable logging
285 //LogComponentEnable("TcpVariantsComparison", LOG_LEVEL_ALL);
286 //LogComponentEnable("BulkSendApplication", LOG_LEVEL_INFO);
287 //LogComponentEnable("PfifoFastQueueDisc", LOG_LEVEL_ALL);
288
289 // Calculate the ADU size
290 Header* temp_header = new Ipv4Header ();
291 uint32_t ip_header = temp_header->GetSerializedSize ();
292 NS_LOG_LOGIC ("IP Header size is: " << ip_header);
293 delete temp_header;
294 temp_header = new TcpHeader ();
295 uint32_t tcp_header = temp_header->GetSerializedSize ();
296 NS_LOG_LOGIC ("TCP Header size is: " << tcp_header);
297 delete temp_header;
298 uint32_t tcp_adu_size = mtu_bytes - 20 - (ip_header + tcp_header);
299 NS_LOG_LOGIC ("TCP ADU size is: " << tcp_adu_size);
300
301 // Set the simulation start and stop time
302 double start_time = 0.1;
303 double stop_time = start_time + duration;
304
305 // 2 MB of TCP buffer
306 Config::SetDefault ("ns3::TcpSocket::RcvBufSize", UintegerValue (1 << 21));
307 Config::SetDefault ("ns3::TcpSocket::SndBufSize", UintegerValue (1 << 21));
308 Config::SetDefault ("ns3::TcpSocketBase::Sack", BooleanValue (sack));
309
310 Config::SetDefault ("ns3::TcpL4Protocol::RecoveryType",
311 TypeIdValue (TypeId::LookupByName (recovery)));
312 // Select TCP variant
313 if (transport_prot.compare ("ns3::TcpWestwoodPlus") == 0)
314 {
315 // TcpWestwoodPlus is not an actual TypeId name; we need TcpWestwood here
316 Config::SetDefault ("ns3::TcpL4Protocol::SocketType", TypeIdValue (TcpWestwood::GetTypeId ()));
317 // the default protocol type in ns3::TcpWestwood is WESTWOOD
318 Config::SetDefault ("ns3::TcpWestwood::ProtocolType", EnumValue (TcpWestwood::WESTWOODPLUS));
319 }
320 else
321 {
322 TypeId tcpTid;
323 NS_ABORT_MSG_UNLESS (TypeId::LookupByNameFailSafe (transport_prot, &tcpTid), "TypeId " << transport_prot << " not found");
324 Config::SetDefault ("ns3::TcpL4Protocol::SocketType", TypeIdValue (TypeId::LookupByName (transport_prot)));
325 }
326
327 // Create gateways, sources, and sinks
328 NodeContainer gateways;
329 gateways.Create (1);
330 NodeContainer sources;
331 sources.Create (num_flows);
332 NodeContainer sinks;
333 sinks.Create (num_flows);
334
335 // Configure the error model
336 // Here we use RateErrorModel with packet error rate
337 Ptr<UniformRandomVariable> uv = CreateObject<UniformRandomVariable> ();
338 uv->SetStream (50);
339 RateErrorModel error_model;
340 error_model.SetRandomVariable (uv);
341 error_model.SetUnit (RateErrorModel::ERROR_UNIT_PACKET);
342 error_model.SetRate (error_p);
343
344 PointToPointHelper UnReLink;
345 UnReLink.SetDeviceAttribute ("DataRate", StringValue (bandwidth));
346 UnReLink.SetChannelAttribute ("Delay", StringValue (delay));
347 UnReLink.SetDeviceAttribute ("ReceiveErrorModel", PointerValue (&error_model));
348
349
351 stack.InstallAll ();
352
353 TrafficControlHelper tchPfifo;
354 tchPfifo.SetRootQueueDisc ("ns3::PfifoFastQueueDisc");
355
356 TrafficControlHelper tchCoDel;
357 tchCoDel.SetRootQueueDisc ("ns3::CoDelQueueDisc");
358
360 address.SetBase ("10.0.0.0", "255.255.255.0");
361
362 // Configure the sources and sinks net devices
363 // and the channels between the sources/sinks and the gateways
364 PointToPointHelper LocalLink;
365 LocalLink.SetDeviceAttribute ("DataRate", StringValue (access_bandwidth));
366 LocalLink.SetChannelAttribute ("Delay", StringValue (access_delay));
367
368 Ipv4InterfaceContainer sink_interfaces;
369
370 DataRate access_b (access_bandwidth);
371 DataRate bottle_b (bandwidth);
372 Time access_d (access_delay);
373 Time bottle_d (delay);
374
375 uint32_t size = static_cast<uint32_t>((std::min (access_b, bottle_b).GetBitRate () / 8) *
376 ((access_d + bottle_d) * 2).GetSeconds ());
377
378 Config::SetDefault ("ns3::PfifoFastQueueDisc::MaxSize",
379 QueueSizeValue (QueueSize (QueueSizeUnit::PACKETS, size / mtu_bytes)));
380 Config::SetDefault ("ns3::CoDelQueueDisc::MaxSize",
382
383 for (uint32_t i = 0; i < num_flows; i++)
384 {
386 devices = LocalLink.Install (sources.Get (i), gateways.Get (0));
387 tchPfifo.Install (devices);
388 address.NewNetwork ();
390
391 devices = UnReLink.Install (gateways.Get (0), sinks.Get (i));
392 if (queue_disc_type.compare ("ns3::PfifoFastQueueDisc") == 0)
393 {
394 tchPfifo.Install (devices);
395 }
396 else if (queue_disc_type.compare ("ns3::CoDelQueueDisc") == 0)
397 {
398 tchCoDel.Install (devices);
399 }
400 else
401 {
402 NS_FATAL_ERROR ("Queue not recognized. Allowed values are ns3::CoDelQueueDisc or ns3::PfifoFastQueueDisc");
403 }
404 address.NewNetwork ();
405 interfaces = address.Assign (devices);
406 sink_interfaces.Add (interfaces.Get (1));
407 }
408
409 NS_LOG_INFO ("Initialize Global Routing.");
410 Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
411
412 uint16_t port = 50000;
413 Address sinkLocalAddress (InetSocketAddress (Ipv4Address::GetAny (), port));
414 PacketSinkHelper sinkHelper ("ns3::TcpSocketFactory", sinkLocalAddress);
415
416 for (uint16_t i = 0; i < sources.GetN (); i++)
417 {
418 AddressValue remoteAddress (InetSocketAddress (sink_interfaces.GetAddress (i, 0), port));
419 Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (tcp_adu_size));
420 BulkSendHelper ftp ("ns3::TcpSocketFactory", Address ());
421 ftp.SetAttribute ("Remote", remoteAddress);
422 ftp.SetAttribute ("SendSize", UintegerValue (tcp_adu_size));
423 ftp.SetAttribute ("MaxBytes", UintegerValue (data_mbytes * 1000000));
424
425 ApplicationContainer sourceApp = ftp.Install (sources.Get (i));
426 sourceApp.Start (Seconds (start_time * i));
427 sourceApp.Stop (Seconds (stop_time - 3));
428
429 sinkHelper.SetAttribute ("Protocol", TypeIdValue (TcpSocketFactory::GetTypeId ()));
430 ApplicationContainer sinkApp = sinkHelper.Install (sinks.Get (i));
431 sinkApp.Start (Seconds (start_time * i));
432 sinkApp.Stop (Seconds (stop_time));
433 }
434
435 // Set up tracing if enabled
436 if (tracing)
437 {
438 std::ofstream ascii;
439 Ptr<OutputStreamWrapper> ascii_wrap;
440 ascii.open ((prefix_file_name + "-ascii").c_str ());
441 ascii_wrap = new OutputStreamWrapper ((prefix_file_name + "-ascii").c_str (),
442 std::ios::out);
443 stack.EnableAsciiIpv4All (ascii_wrap);
444
445 for (uint16_t index = 0; index < num_flows; index++)
446 {
447 std::string flowString ("");
448 if (num_flows>1)
449 {
450 flowString = "-flow" + std::to_string (index);
451 }
452
453 firstCwnd[index+1] = true;
454 firstSshThr[index+1] = true;
455 firstRtt[index+1] = true;
456 firstRto[index+1] = true;
457
458 Simulator::Schedule (Seconds (start_time * index + 0.00001), &TraceCwnd,
459 prefix_file_name + flowString + "-cwnd.data", index+1);
460 Simulator::Schedule (Seconds (start_time * index + 0.00001), &TraceSsThresh,
461 prefix_file_name + flowString + "-ssth.data", index+1);
462 Simulator::Schedule (Seconds (start_time * index + 0.00001), &TraceRtt,
463 prefix_file_name + flowString + "-rtt.data", index+1);
464 Simulator::Schedule (Seconds (start_time * index + 0.00001), &TraceRto,
465 prefix_file_name + flowString + "-rto.data", index+1);
466 Simulator::Schedule (Seconds (start_time * index + 0.00001), &TraceNextTx,
467 prefix_file_name + flowString + "-next-tx.data", index+1);
468 Simulator::Schedule (Seconds (start_time * index + 0.00001), &TraceInFlight,
469 prefix_file_name + flowString + "-inflight.data", index+1);
470 Simulator::Schedule (Seconds (start_time * index + 0.1), &TraceNextRx,
471 prefix_file_name + flowString + "-next-rx.data", num_flows+index+1);
472 }
473 }
474
475 if (pcap)
476 {
477 UnReLink.EnablePcapAll (prefix_file_name, true);
478 LocalLink.EnablePcapAll (prefix_file_name, true);
479 }
480
481 // Flow monitor
482 FlowMonitorHelper flowHelper;
483 if (flow_monitor)
484 {
485 flowHelper.InstallAll ();
486 }
487
488 Simulator::Stop (Seconds (stop_time));
489 Simulator::Run ();
490
491 if (flow_monitor)
492 {
493 flowHelper.SerializeToXmlFile (prefix_file_name + ".flowmonitor", true, true);
494 }
495
496 Simulator::Destroy ();
497 return 0;
498}
#define min(a, b)
Definition: 80211b.c:42
a polymophic address class
Definition: address.h:91
AttributeValue implementation for Address.
holds a vector of ns3::Application pointers.
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter.
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter.
Manage ASCII trace files for device models.
Definition: trace-helper.h:163
Ptr< OutputStreamWrapper > CreateFileStream(std::string filename, std::ios::openmode filemode=std::ios::out)
Create and initialize an output stream object we'll use to write the traced bits.
AttributeValue implementation for Boolean.
Definition: boolean.h:37
A helper to make it easier to instantiate an ns3::BulkSendApplication on a set of nodes.
Parse command-line arguments.
Definition: command-line.h:229
Class for representing data rates.
Definition: data-rate.h:89
Hold variables of type enum.
Definition: enum.h:55
Helper to enable IP flow monitoring on a set of Nodes.
Ptr< FlowMonitor > InstallAll()
Enable flow monitoring on all nodes.
void SerializeToXmlFile(std::string fileName, bool enableHistograms, bool enableProbes)
Same as SerializeToXmlStream, but writes to a file instead.
Protocol header serialization and deserialization.
Definition: header.h:43
virtual uint32_t GetSerializedSize(void) const =0
an Inet address class
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Packet header for IPv4.
Definition: ipv4-header.h:34
holds a vector of std::pair of Ptr<Ipv4> and interface index.
void Add(const Ipv4InterfaceContainer &other)
Concatenate the entries in the other container with ours.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
uint32_t GetN(void) const
Get the number of Ptr<Node> stored in this container.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
A class encapsulating an output stream.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
void EnablePcapAll(std::string prefix, bool promiscuous=false)
Enable pcap output on each device (which is of the appropriate type) in the set of all nodes created ...
Build a set of PointToPointNetDevice objects.
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
NetDeviceContainer Install(NodeContainer c)
Hold objects of type Ptr<T>.
Definition: pointer.h:37
Class for representing queue sizes.
Definition: queue-size.h:95
AttributeValue implementation for QueueSize.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
Determine which packets are errored corresponding to an underlying distribution, rate,...
Definition: error-model.h:183
void SetRate(double rate)
Definition: error-model.cc:208
void SetUnit(enum ErrorUnit error_unit)
Definition: error-model.cc:194
void SetRandomVariable(Ptr< RandomVariableStream >)
Definition: error-model.cc:215
Hold variables of type string.
Definition: string.h:41
Header for the Transmission Control Protocol.
Definition: tcp-header.h:45
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:379
Build a set of QueueDisc objects.
QueueDiscContainer Install(NetDeviceContainer c)
uint16_t SetRootQueueDisc(const std::string &type, Args &&... args)
Helper function used to set a root queue disc of the given type and with the given attributes.
a unique identifier for an interface.
Definition: type-id.h:59
AttributeValue implementation for TypeId.
Definition: type-id.h:595
Hold an unsigned integer type.
Definition: uinteger.h:44
uint16_t port
Definition: dsdv-manet.cc:45
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:849
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:920
#define NS_ABORT_MSG_UNLESS(cond, msg)
Abnormal program termination if a condition is false, with a message.
Definition: abort.h:144
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:289
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:281
@ BYTES
Use number of bytes for queue size.
Definition: queue-size.h:45
@ PACKETS
Use number of packets for queue size.
Definition: queue-size.h:44
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:287
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1244
address
Definition: first.py:44
devices
Definition: first.py:39
stack
Definition: first.py:41
interfaces
Definition: first.py:48
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:1648
cmd
Definition: second.py:35
static void RttTracer(std::string context, Time oldval, Time newval)
static std::map< uint32_t, bool > firstCwnd
static std::map< uint32_t, uint32_t > cWndValue
static void TraceInFlight(std::string &in_flight_file_name, uint32_t nodeId)
static void NextRxTracer(std::string context, SequenceNumber32 old, SequenceNumber32 nextRx)
static std::map< uint32_t, Ptr< OutputStreamWrapper > > nextTxStream
static std::map< uint32_t, Ptr< OutputStreamWrapper > > inFlightStream
static std::map< uint32_t, bool > firstSshThr
static std::map< uint32_t, bool > firstRto
static std::map< uint32_t, Ptr< OutputStreamWrapper > > nextRxStream
static uint32_t GetNodeIdFromContext(std::string context)
static std::map< uint32_t, Ptr< OutputStreamWrapper > > rtoStream
static void InFlightTracer(std::string context, uint32_t old, uint32_t inFlight)
static void NextTxTracer(std::string context, SequenceNumber32 old, SequenceNumber32 nextTx)
static std::map< uint32_t, uint32_t > ssThreshValue
static void TraceRtt(std::string rtt_tr_file_name, uint32_t nodeId)
static void TraceSsThresh(std::string ssthresh_tr_file_name, uint32_t nodeId)
static std::map< uint32_t, bool > firstRtt
static void TraceNextTx(std::string &next_tx_seq_file_name, uint32_t nodeId)
static void CwndTracer(std::string context, uint32_t oldval, uint32_t newval)
static void SsThreshTracer(std::string context, uint32_t oldval, uint32_t newval)
static std::map< uint32_t, Ptr< OutputStreamWrapper > > ssThreshStream
static std::map< uint32_t, Ptr< OutputStreamWrapper > > rttStream
static void TraceCwnd(std::string cwnd_tr_file_name, uint32_t nodeId)
static void RtoTracer(std::string context, Time oldval, Time newval)
static void TraceNextRx(std::string &next_rx_seq_file_name, uint32_t nodeId)
static std::map< uint32_t, Ptr< OutputStreamWrapper > > cWndStream
static void TraceRto(std::string rto_tr_file_name, uint32_t nodeId)
bool tracing
Flag to enable/disable generation of tracing files.
Definition: wifi-bianchi.cc:88