A Discrete-Event Network Simulator
API
tcp-variants-comparison.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 ResiliNets, ITTC, University of Kansas
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Authors: Justin P. Rohrer, Truc Anh N. Nguyen <annguyen@ittc.ku.edu>, Siddharth Gangadhar
18  * <siddharth@ittc.ku.edu>
19  *
20  * James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
21  * ResiliNets Research Group https://resilinets.org/
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 "ns3/applications-module.h"
37 #include "ns3/core-module.h"
38 #include "ns3/enum.h"
39 #include "ns3/error-model.h"
40 #include "ns3/event-id.h"
41 #include "ns3/flow-monitor-helper.h"
42 #include "ns3/internet-module.h"
43 #include "ns3/ipv4-global-routing-helper.h"
44 #include "ns3/network-module.h"
45 #include "ns3/point-to-point-module.h"
46 #include "ns3/tcp-header.h"
47 #include "ns3/traffic-control-module.h"
48 #include "ns3/udp-header.h"
49 
50 #include <fstream>
51 #include <iostream>
52 #include <string>
53 
54 using namespace ns3;
55 
56 NS_LOG_COMPONENT_DEFINE("TcpVariantsComparison");
57 
58 static std::map<uint32_t, bool> firstCwnd;
59 static std::map<uint32_t, bool> firstSshThr;
60 static std::map<uint32_t, bool> firstRtt;
61 static std::map<uint32_t, bool> firstRto;
62 static std::map<uint32_t, Ptr<OutputStreamWrapper>> cWndStream;
63 static std::map<uint32_t, Ptr<OutputStreamWrapper>>
65 static std::map<uint32_t, Ptr<OutputStreamWrapper>> rttStream;
66 static std::map<uint32_t, Ptr<OutputStreamWrapper>> rtoStream;
67 static std::map<uint32_t, Ptr<OutputStreamWrapper>> nextTxStream;
68 static std::map<uint32_t, Ptr<OutputStreamWrapper>> nextRxStream;
69 static std::map<uint32_t, Ptr<OutputStreamWrapper>> inFlightStream;
70 static std::map<uint32_t, uint32_t> cWndValue;
71 static std::map<uint32_t, uint32_t> ssThreshValue;
72 
79 static uint32_t
80 GetNodeIdFromContext(std::string context)
81 {
82  const std::size_t n1 = context.find_first_of('/', 1);
83  const std::size_t n2 = context.find_first_of('/', n1 + 1);
84  return std::stoul(context.substr(n1 + 1, n2 - n1 - 1));
85 }
86 
94 static void
95 CwndTracer(std::string context, uint32_t oldval, uint32_t newval)
96 {
97  uint32_t nodeId = GetNodeIdFromContext(context);
98 
99  if (firstCwnd[nodeId])
100  {
101  *cWndStream[nodeId]->GetStream() << "0.0 " << oldval << std::endl;
102  firstCwnd[nodeId] = false;
103  }
104  *cWndStream[nodeId]->GetStream() << Simulator::Now().GetSeconds() << " " << newval << std::endl;
105  cWndValue[nodeId] = newval;
106 
107  if (!firstSshThr[nodeId])
108  {
109  *ssThreshStream[nodeId]->GetStream()
110  << Simulator::Now().GetSeconds() << " " << ssThreshValue[nodeId] << std::endl;
111  }
112 }
113 
121 static void
122 SsThreshTracer(std::string context, uint32_t oldval, uint32_t newval)
123 {
124  uint32_t nodeId = GetNodeIdFromContext(context);
125 
126  if (firstSshThr[nodeId])
127  {
128  *ssThreshStream[nodeId]->GetStream() << "0.0 " << oldval << std::endl;
129  firstSshThr[nodeId] = false;
130  }
131  *ssThreshStream[nodeId]->GetStream()
132  << Simulator::Now().GetSeconds() << " " << newval << std::endl;
133  ssThreshValue[nodeId] = newval;
134 
135  if (!firstCwnd[nodeId])
136  {
137  *cWndStream[nodeId]->GetStream()
138  << Simulator::Now().GetSeconds() << " " << cWndValue[nodeId] << std::endl;
139  }
140 }
141 
149 static void
150 RttTracer(std::string context, Time oldval, Time newval)
151 {
152  uint32_t nodeId = GetNodeIdFromContext(context);
153 
154  if (firstRtt[nodeId])
155  {
156  *rttStream[nodeId]->GetStream() << "0.0 " << oldval.GetSeconds() << std::endl;
157  firstRtt[nodeId] = false;
158  }
159  *rttStream[nodeId]->GetStream()
160  << Simulator::Now().GetSeconds() << " " << newval.GetSeconds() << std::endl;
161 }
162 
170 static void
171 RtoTracer(std::string context, Time oldval, Time newval)
172 {
173  uint32_t nodeId = GetNodeIdFromContext(context);
174 
175  if (firstRto[nodeId])
176  {
177  *rtoStream[nodeId]->GetStream() << "0.0 " << oldval.GetSeconds() << std::endl;
178  firstRto[nodeId] = false;
179  }
180  *rtoStream[nodeId]->GetStream()
181  << Simulator::Now().GetSeconds() << " " << newval.GetSeconds() << std::endl;
182 }
183 
191 static void
192 NextTxTracer(std::string context, SequenceNumber32 old [[maybe_unused]], SequenceNumber32 nextTx)
193 {
194  uint32_t nodeId = GetNodeIdFromContext(context);
195 
196  *nextTxStream[nodeId]->GetStream()
197  << Simulator::Now().GetSeconds() << " " << nextTx << std::endl;
198 }
199 
207 static void
208 InFlightTracer(std::string context, uint32_t old [[maybe_unused]], uint32_t inFlight)
209 {
210  uint32_t nodeId = GetNodeIdFromContext(context);
211 
212  *inFlightStream[nodeId]->GetStream()
213  << Simulator::Now().GetSeconds() << " " << inFlight << std::endl;
214 }
215 
223 static void
224 NextRxTracer(std::string context, SequenceNumber32 old [[maybe_unused]], SequenceNumber32 nextRx)
225 {
226  uint32_t nodeId = GetNodeIdFromContext(context);
227 
228  *nextRxStream[nodeId]->GetStream()
229  << Simulator::Now().GetSeconds() << " " << nextRx << std::endl;
230 }
231 
238 static void
239 TraceCwnd(std::string cwnd_tr_file_name, uint32_t nodeId)
240 {
241  AsciiTraceHelper ascii;
242  cWndStream[nodeId] = ascii.CreateFileStream(cwnd_tr_file_name);
243  Config::Connect("/NodeList/" + std::to_string(nodeId) +
244  "/$ns3::TcpL4Protocol/SocketList/0/CongestionWindow",
246 }
247 
254 static void
255 TraceSsThresh(std::string ssthresh_tr_file_name, uint32_t nodeId)
256 {
257  AsciiTraceHelper ascii;
258  ssThreshStream[nodeId] = ascii.CreateFileStream(ssthresh_tr_file_name);
259  Config::Connect("/NodeList/" + std::to_string(nodeId) +
260  "/$ns3::TcpL4Protocol/SocketList/0/SlowStartThreshold",
262 }
263 
270 static void
271 TraceRtt(std::string rtt_tr_file_name, uint32_t nodeId)
272 {
273  AsciiTraceHelper ascii;
274  rttStream[nodeId] = ascii.CreateFileStream(rtt_tr_file_name);
275  Config::Connect("/NodeList/" + std::to_string(nodeId) + "/$ns3::TcpL4Protocol/SocketList/0/RTT",
277 }
278 
285 static void
286 TraceRto(std::string rto_tr_file_name, uint32_t nodeId)
287 {
288  AsciiTraceHelper ascii;
289  rtoStream[nodeId] = ascii.CreateFileStream(rto_tr_file_name);
290  Config::Connect("/NodeList/" + std::to_string(nodeId) + "/$ns3::TcpL4Protocol/SocketList/0/RTO",
292 }
293 
300 static void
301 TraceNextTx(std::string& next_tx_seq_file_name, uint32_t nodeId)
302 {
303  AsciiTraceHelper ascii;
304  nextTxStream[nodeId] = ascii.CreateFileStream(next_tx_seq_file_name);
305  Config::Connect("/NodeList/" + std::to_string(nodeId) +
306  "/$ns3::TcpL4Protocol/SocketList/0/NextTxSequence",
308 }
309 
316 static void
317 TraceInFlight(std::string& in_flight_file_name, uint32_t nodeId)
318 {
319  AsciiTraceHelper ascii;
320  inFlightStream[nodeId] = ascii.CreateFileStream(in_flight_file_name);
321  Config::Connect("/NodeList/" + std::to_string(nodeId) +
322  "/$ns3::TcpL4Protocol/SocketList/0/BytesInFlight",
324 }
325 
332 static void
333 TraceNextRx(std::string& next_rx_seq_file_name, uint32_t nodeId)
334 {
335  AsciiTraceHelper ascii;
336  nextRxStream[nodeId] = ascii.CreateFileStream(next_rx_seq_file_name);
337  Config::Connect("/NodeList/" + std::to_string(nodeId) +
338  "/$ns3::TcpL4Protocol/SocketList/1/RxBuffer/NextRxSequence",
340 }
341 
342 int
343 main(int argc, char* argv[])
344 {
345  std::string transport_prot = "TcpWestwoodPlus";
346  double error_p = 0.0;
347  std::string bandwidth = "2Mbps";
348  std::string delay = "0.01ms";
349  std::string access_bandwidth = "10Mbps";
350  std::string access_delay = "45ms";
351  bool tracing = false;
352  std::string prefix_file_name = "TcpVariantsComparison";
353  uint64_t data_mbytes = 0;
354  uint32_t mtu_bytes = 400;
355  uint16_t num_flows = 1;
356  double duration = 100.0;
357  uint32_t run = 0;
358  bool flow_monitor = false;
359  bool pcap = false;
360  bool sack = true;
361  std::string queue_disc_type = "ns3::PfifoFastQueueDisc";
362  std::string recovery = "ns3::TcpClassicRecovery";
363 
364  CommandLine cmd(__FILE__);
365  cmd.AddValue("transport_prot",
366  "Transport protocol to use: TcpNewReno, TcpLinuxReno, "
367  "TcpHybla, TcpHighSpeed, TcpHtcp, TcpVegas, TcpScalable, TcpVeno, "
368  "TcpBic, TcpYeah, TcpIllinois, TcpWestwoodPlus, TcpLedbat, "
369  "TcpLp, TcpDctcp, TcpCubic, TcpBbr",
370  transport_prot);
371  cmd.AddValue("error_p", "Packet error rate", error_p);
372  cmd.AddValue("bandwidth", "Bottleneck bandwidth", bandwidth);
373  cmd.AddValue("delay", "Bottleneck delay", delay);
374  cmd.AddValue("access_bandwidth", "Access link bandwidth", access_bandwidth);
375  cmd.AddValue("access_delay", "Access link delay", access_delay);
376  cmd.AddValue("tracing", "Flag to enable/disable tracing", tracing);
377  cmd.AddValue("prefix_name", "Prefix of output trace file", prefix_file_name);
378  cmd.AddValue("data", "Number of Megabytes of data to transmit", data_mbytes);
379  cmd.AddValue("mtu", "Size of IP packets to send in bytes", mtu_bytes);
380  cmd.AddValue("num_flows", "Number of flows", num_flows);
381  cmd.AddValue("duration", "Time to allow flows to run in seconds", duration);
382  cmd.AddValue("run", "Run index (for setting repeatable seeds)", run);
383  cmd.AddValue("flow_monitor", "Enable flow monitor", flow_monitor);
384  cmd.AddValue("pcap_tracing", "Enable or disable PCAP tracing", pcap);
385  cmd.AddValue("queue_disc_type",
386  "Queue disc type for gateway (e.g. ns3::CoDelQueueDisc)",
387  queue_disc_type);
388  cmd.AddValue("sack", "Enable or disable SACK option", sack);
389  cmd.AddValue("recovery", "Recovery algorithm type to use (e.g., ns3::TcpPrrRecovery", recovery);
390  cmd.Parse(argc, argv);
391 
392  transport_prot = std::string("ns3::") + transport_prot;
393 
395  SeedManager::SetRun(run);
396 
397  // User may find it convenient to enable logging
398  // LogComponentEnable("TcpVariantsComparison", LOG_LEVEL_ALL);
399  // LogComponentEnable("BulkSendApplication", LOG_LEVEL_INFO);
400  // LogComponentEnable("PfifoFastQueueDisc", LOG_LEVEL_ALL);
401 
402  // Calculate the ADU size
403  Header* temp_header = new Ipv4Header();
404  uint32_t ip_header = temp_header->GetSerializedSize();
405  NS_LOG_LOGIC("IP Header size is: " << ip_header);
406  delete temp_header;
407  temp_header = new TcpHeader();
408  uint32_t tcp_header = temp_header->GetSerializedSize();
409  NS_LOG_LOGIC("TCP Header size is: " << tcp_header);
410  delete temp_header;
411  uint32_t tcp_adu_size = mtu_bytes - 20 - (ip_header + tcp_header);
412  NS_LOG_LOGIC("TCP ADU size is: " << tcp_adu_size);
413 
414  // Set the simulation start and stop time
415  double start_time = 0.1;
416  double stop_time = start_time + duration;
417 
418  // 2 MB of TCP buffer
419  Config::SetDefault("ns3::TcpSocket::RcvBufSize", UintegerValue(1 << 21));
420  Config::SetDefault("ns3::TcpSocket::SndBufSize", UintegerValue(1 << 21));
421  Config::SetDefault("ns3::TcpSocketBase::Sack", BooleanValue(sack));
422 
423  Config::SetDefault("ns3::TcpL4Protocol::RecoveryType",
424  TypeIdValue(TypeId::LookupByName(recovery)));
425  // Select TCP variant
426  TypeId tcpTid;
427  NS_ABORT_MSG_UNLESS(TypeId::LookupByNameFailSafe(transport_prot, &tcpTid),
428  "TypeId " << transport_prot << " not found");
429  Config::SetDefault("ns3::TcpL4Protocol::SocketType",
430  TypeIdValue(TypeId::LookupByName(transport_prot)));
431 
432  // Create gateways, sources, and sinks
433  NodeContainer gateways;
434  gateways.Create(1);
435  NodeContainer sources;
436  sources.Create(num_flows);
437  NodeContainer sinks;
438  sinks.Create(num_flows);
439 
440  // Configure the error model
441  // Here we use RateErrorModel with packet error rate
442  Ptr<UniformRandomVariable> uv = CreateObject<UniformRandomVariable>();
443  uv->SetStream(50);
444  RateErrorModel error_model;
445  error_model.SetRandomVariable(uv);
447  error_model.SetRate(error_p);
448 
449  PointToPointHelper UnReLink;
450  UnReLink.SetDeviceAttribute("DataRate", StringValue(bandwidth));
451  UnReLink.SetChannelAttribute("Delay", StringValue(delay));
452  UnReLink.SetDeviceAttribute("ReceiveErrorModel", PointerValue(&error_model));
453 
455  stack.InstallAll();
456 
457  TrafficControlHelper tchPfifo;
458  tchPfifo.SetRootQueueDisc("ns3::PfifoFastQueueDisc");
459 
460  TrafficControlHelper tchCoDel;
461  tchCoDel.SetRootQueueDisc("ns3::CoDelQueueDisc");
462 
464  address.SetBase("10.0.0.0", "255.255.255.0");
465 
466  // Configure the sources and sinks net devices
467  // and the channels between the sources/sinks and the gateways
468  PointToPointHelper LocalLink;
469  LocalLink.SetDeviceAttribute("DataRate", StringValue(access_bandwidth));
470  LocalLink.SetChannelAttribute("Delay", StringValue(access_delay));
471 
472  Ipv4InterfaceContainer sink_interfaces;
473 
474  DataRate access_b(access_bandwidth);
475  DataRate bottle_b(bandwidth);
476  Time access_d(access_delay);
477  Time bottle_d(delay);
478 
479  uint32_t size = static_cast<uint32_t>((std::min(access_b, bottle_b).GetBitRate() / 8) *
480  ((access_d + bottle_d) * 2).GetSeconds());
481 
482  Config::SetDefault("ns3::PfifoFastQueueDisc::MaxSize",
483  QueueSizeValue(QueueSize(QueueSizeUnit::PACKETS, size / mtu_bytes)));
484  Config::SetDefault("ns3::CoDelQueueDisc::MaxSize",
485  QueueSizeValue(QueueSize(QueueSizeUnit::BYTES, size)));
486 
487  for (uint32_t i = 0; i < num_flows; i++)
488  {
490  devices = LocalLink.Install(sources.Get(i), gateways.Get(0));
491  tchPfifo.Install(devices);
492  address.NewNetwork();
494 
495  devices = UnReLink.Install(gateways.Get(0), sinks.Get(i));
496  if (queue_disc_type == "ns3::PfifoFastQueueDisc")
497  {
498  tchPfifo.Install(devices);
499  }
500  else if (queue_disc_type == "ns3::CoDelQueueDisc")
501  {
502  tchCoDel.Install(devices);
503  }
504  else
505  {
506  NS_FATAL_ERROR("Queue not recognized. Allowed values are ns3::CoDelQueueDisc or "
507  "ns3::PfifoFastQueueDisc");
508  }
509  address.NewNetwork();
510  interfaces = address.Assign(devices);
511  sink_interfaces.Add(interfaces.Get(1));
512  }
513 
514  NS_LOG_INFO("Initialize Global Routing.");
516 
517  uint16_t port = 50000;
518  Address sinkLocalAddress(InetSocketAddress(Ipv4Address::GetAny(), port));
519  PacketSinkHelper sinkHelper("ns3::TcpSocketFactory", sinkLocalAddress);
520 
521  for (uint32_t i = 0; i < sources.GetN(); i++)
522  {
523  AddressValue remoteAddress(InetSocketAddress(sink_interfaces.GetAddress(i, 0), port));
524  Config::SetDefault("ns3::TcpSocket::SegmentSize", UintegerValue(tcp_adu_size));
525  BulkSendHelper ftp("ns3::TcpSocketFactory", Address());
526  ftp.SetAttribute("Remote", remoteAddress);
527  ftp.SetAttribute("SendSize", UintegerValue(tcp_adu_size));
528  ftp.SetAttribute("MaxBytes", UintegerValue(data_mbytes * 1000000));
529 
530  ApplicationContainer sourceApp = ftp.Install(sources.Get(i));
531  sourceApp.Start(Seconds(start_time * i));
532  sourceApp.Stop(Seconds(stop_time - 3));
533 
534  sinkHelper.SetAttribute("Protocol", TypeIdValue(TcpSocketFactory::GetTypeId()));
535  ApplicationContainer sinkApp = sinkHelper.Install(sinks.Get(i));
536  sinkApp.Start(Seconds(start_time * i));
537  sinkApp.Stop(Seconds(stop_time));
538  }
539 
540  // Set up tracing if enabled
541  if (tracing)
542  {
543  std::ofstream ascii;
544  Ptr<OutputStreamWrapper> ascii_wrap;
545  ascii.open(prefix_file_name + "-ascii");
546  ascii_wrap = new OutputStreamWrapper(prefix_file_name + "-ascii", std::ios::out);
547  stack.EnableAsciiIpv4All(ascii_wrap);
548 
549  for (uint16_t index = 0; index < num_flows; index++)
550  {
551  std::string flowString;
552  if (num_flows > 1)
553  {
554  flowString = "-flow" + std::to_string(index);
555  }
556 
557  firstCwnd[index + 1] = true;
558  firstSshThr[index + 1] = true;
559  firstRtt[index + 1] = true;
560  firstRto[index + 1] = true;
561 
562  Simulator::Schedule(Seconds(start_time * index + 0.00001),
563  &TraceCwnd,
564  prefix_file_name + flowString + "-cwnd.data",
565  index + 1);
566  Simulator::Schedule(Seconds(start_time * index + 0.00001),
567  &TraceSsThresh,
568  prefix_file_name + flowString + "-ssth.data",
569  index + 1);
570  Simulator::Schedule(Seconds(start_time * index + 0.00001),
571  &TraceRtt,
572  prefix_file_name + flowString + "-rtt.data",
573  index + 1);
574  Simulator::Schedule(Seconds(start_time * index + 0.00001),
575  &TraceRto,
576  prefix_file_name + flowString + "-rto.data",
577  index + 1);
578  Simulator::Schedule(Seconds(start_time * index + 0.00001),
579  &TraceNextTx,
580  prefix_file_name + flowString + "-next-tx.data",
581  index + 1);
582  Simulator::Schedule(Seconds(start_time * index + 0.00001),
583  &TraceInFlight,
584  prefix_file_name + flowString + "-inflight.data",
585  index + 1);
586  Simulator::Schedule(Seconds(start_time * index + 0.1),
587  &TraceNextRx,
588  prefix_file_name + flowString + "-next-rx.data",
589  num_flows + index + 1);
590  }
591  }
592 
593  if (pcap)
594  {
595  UnReLink.EnablePcapAll(prefix_file_name, true);
596  LocalLink.EnablePcapAll(prefix_file_name, true);
597  }
598 
599  // Flow monitor
600  FlowMonitorHelper flowHelper;
601  if (flow_monitor)
602  {
603  flowHelper.InstallAll();
604  }
605 
606  Simulator::Stop(Seconds(stop_time));
607  Simulator::Run();
608 
609  if (flow_monitor)
610  {
611  flowHelper.SerializeToXmlFile(prefix_file_name + ".flowmonitor", true, true);
612  }
613 
615  return 0;
616 }
#define min(a, b)
Definition: 80211b.c:41
a polymophic address class
Definition: address.h:101
holds a vector of ns3::Application pointers.
void Start(Time start) const
Start all of the Applications in this container at the start time given as a parameter.
void Stop(Time stop) const
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:174
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.
A helper to make it easier to instantiate an ns3::BulkSendApplication on a set of nodes.
Parse command-line arguments.
Definition: command-line.h:232
Class for representing data rates.
Definition: data-rate.h:89
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:44
virtual uint32_t GetSerializedSize() 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.
static Ipv4Address GetAny()
static void PopulateRoutingTables()
Build a routing database and initialize the routing tables of the nodes in the simulation.
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() 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:96
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:184
void SetRate(double rate)
Definition: error-model.cc:215
void SetUnit(ErrorUnit error_unit)
Definition: error-model.cc:201
void SetRandomVariable(Ptr< RandomVariableStream >)
Definition: error-model.cc:222
static void SetRun(uint64_t run)
Set the run number of simulation.
static void SetSeed(uint32_t seed)
Set the seed.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:571
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:142
static Time Now()
Return the current simulation virtual time.
Definition: simulator.cc:208
static void Run()
Run the simulation.
Definition: simulator.cc:178
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition: simulator.cc:186
Hold variables of type string.
Definition: string.h:56
Header for the Transmission Control Protocol.
Definition: tcp-header.h:47
static TypeId GetTypeId()
Get the type ID.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:403
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
static TypeId LookupByName(std::string name)
Get a TypeId by name.
Definition: type-id.cc:835
static bool LookupByNameFailSafe(std::string name, TypeId *tid)
Get a TypeId by name.
Definition: type-id.cc:844
Hold an unsigned integer type.
Definition: uinteger.h:45
uint16_t port
Definition: dsdv-manet.cc:44
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:890
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:974
#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:179
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:282
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:275
@ BYTES
Use number of bytes for queue size.
Definition: queue-size.h:46
@ PACKETS
Use number of packets for queue size.
Definition: queue-size.h:45
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1326
address
Definition: first.py:47
devices
Definition: first.py:42
stack
Definition: first.py:44
interfaces
Definition: first.py:50
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
Definition: json.h:25255
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:704
cmd
Definition: second.py:40
static void RttTracer(std::string context, Time oldval, Time newval)
RTT tracer.
static std::map< uint32_t, bool > firstCwnd
First congestion window.
static std::map< uint32_t, uint32_t > cWndValue
congestion window value.
static void TraceInFlight(std::string &in_flight_file_name, uint32_t nodeId)
In flight trace connection.
static std::map< uint32_t, Ptr< OutputStreamWrapper > > nextTxStream
Next TX output stream.
static std::map< uint32_t, Ptr< OutputStreamWrapper > > inFlightStream
In flight output stream.
static std::map< uint32_t, bool > firstSshThr
First SlowStart threshold.
static std::map< uint32_t, bool > firstRto
First RTO.
static std::map< uint32_t, Ptr< OutputStreamWrapper > > nextRxStream
Next RX output stream.
static uint32_t GetNodeIdFromContext(std::string context)
Get the Node Id From Context.
static void InFlightTracer(std::string context, uint32_t old[[maybe_unused]], uint32_t inFlight)
In-flight tracer.
static std::map< uint32_t, Ptr< OutputStreamWrapper > > rtoStream
RTO output stream.
static void NextTxTracer(std::string context, SequenceNumber32 old[[maybe_unused]], SequenceNumber32 nextTx)
Next TX tracer.
static std::map< uint32_t, uint32_t > ssThreshValue
SlowStart threshold value.
static void TraceRtt(std::string rtt_tr_file_name, uint32_t nodeId)
RTT trace connection.
static void TraceSsThresh(std::string ssthresh_tr_file_name, uint32_t nodeId)
Slow start threshold trace connection.
static std::map< uint32_t, bool > firstRtt
First RTT.
static void TraceNextTx(std::string &next_tx_seq_file_name, uint32_t nodeId)
Next TX trace connection.
static void CwndTracer(std::string context, uint32_t oldval, uint32_t newval)
Congestion window tracer.
static void SsThreshTracer(std::string context, uint32_t oldval, uint32_t newval)
Slow start threshold tracer.
static std::map< uint32_t, Ptr< OutputStreamWrapper > > ssThreshStream
SlowStart threshold output stream.
static std::map< uint32_t, Ptr< OutputStreamWrapper > > rttStream
RTT output stream.
static void NextRxTracer(std::string context, SequenceNumber32 old[[maybe_unused]], SequenceNumber32 nextRx)
Next RX tracer.
static void TraceCwnd(std::string cwnd_tr_file_name, uint32_t nodeId)
Congestion window trace connection.
static void RtoTracer(std::string context, Time oldval, Time newval)
RTO tracer.
static void TraceNextRx(std::string &next_rx_seq_file_name, uint32_t nodeId)
Next RX trace connection.
static std::map< uint32_t, Ptr< OutputStreamWrapper > > cWndStream
Congstion window output stream.
static void TraceRto(std::string rto_tr_file_name, uint32_t nodeId)
RTO trace connection.
bool tracing
Flag to enable/disable generation of tracing files.