View | Details | Raw Unified | Return to bug 1831
Collapse All | Expand All

(-)a/examples/tcp/tcp-variants-comparison.cc (-120 / +96 lines)
 Lines 1-6    Link Here 
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
2
/*
3
 * Copyright (c) 2013 ResiliNets, ITTC, University of Kansas 
3
 * Copyright (c) 2013 ResiliNets, ITTC, University of Kansas
4
 *
4
 *
5
 * This program is free software; you can redistribute it and/or modify
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
6
 * it under the terms of the GNU General Public License version 2 as
 Lines 54-143    Link Here 
54
54
55
NS_LOG_COMPONENT_DEFINE ("TcpVariantsComparison");
55
NS_LOG_COMPONENT_DEFINE ("TcpVariantsComparison");
56
56
57
double old_time = 0.0;
57
bool firstCwnd = true;
58
EventId output;
58
bool firstSshThr = true;
59
Time current = Time::FromInteger(3, Time::S);  //Only record cwnd and ssthresh values every 3 seconds
60
bool first = true;
61
62
static void
63
OutputTrace ()
64
{
65
 // *stream->GetStream() << newtime << " " << newval << std::endl;
66
 // old_time = newval;
67
}
68
59
69
static void
60
static void
70
CwndTracer (Ptr<OutputStreamWrapper>stream, uint32_t oldval, uint32_t newval)
61
CwndTracer (Ptr<OutputStreamWrapper>stream, uint32_t oldval, uint32_t newval)
71
{
62
{
72
  double new_time = Simulator::Now().GetSeconds();
63
  if (firstCwnd)
73
  if (old_time == 0 && first)
74
  {
75
    double mycurrent = current.GetSeconds();
76
    *stream->GetStream() << new_time << " " << mycurrent << " " << newval << std::endl;
77
    first = false;
78
    output = Simulator::Schedule(current,&OutputTrace);
79
  }
80
  else
81
  {
82
    if (output.IsExpired())
83
    {
64
    {
84
      *stream->GetStream() << new_time << " " << newval << std::endl;
65
      *stream->GetStream () << "0.0 " << oldval << std::endl;
85
      output.Cancel();
66
      firstCwnd = false;
86
      output = Simulator::Schedule(current,&OutputTrace);
87
    }
67
    }
88
  }
68
  *stream->GetStream () << Simulator::Now ().GetSeconds () << " " << newval << std::endl;
89
}
69
}
90
70
91
static void
71
static void
92
SsThreshTracer (Ptr<OutputStreamWrapper>stream, uint32_t oldval, uint32_t newval)
72
SsThreshTracer (Ptr<OutputStreamWrapper>stream, uint32_t oldval, uint32_t newval)
93
{
73
{
94
  double new_time = Simulator::Now().GetSeconds();
74
  if (firstCwnd)
95
  if (old_time == 0 && first)
96
  {
97
    double mycurrent = current.GetSeconds();
98
    *stream->GetStream() << new_time << " " << mycurrent << " " << newval << std::endl;
99
    first = false;
100
    output = Simulator::Schedule(current,&OutputTrace);
101
  }
102
  else
103
  {
104
    if (output.IsExpired())
105
    {
75
    {
106
      *stream->GetStream() << new_time << " " << newval << std::endl;
76
      *stream->GetStream () << "0.0 " << oldval << std::endl;
107
      output.Cancel();
77
      firstSshThr = false;
108
      output = Simulator::Schedule(current,&OutputTrace);
109
    }
78
    }
110
  }
79
  *stream->GetStream () << Simulator::Now ().GetSeconds () << " " << newval << std::endl;
111
}
80
}
112
81
82
113
static void
83
static void
114
TraceCwnd (std::string cwnd_tr_file_name)
84
TraceCwnd (std::string cwnd_tr_file_name)
115
{
85
{
116
  AsciiTraceHelper ascii;
86
  AsciiTraceHelper ascii;
117
  if (cwnd_tr_file_name.compare("") == 0)
87
  if (cwnd_tr_file_name.compare ("") == 0)
118
     {
88
    {
119
       NS_LOG_DEBUG ("No trace file for cwnd provided");
89
      NS_LOG_DEBUG ("No trace file for cwnd provided");
120
       return;
90
      return;
121
     }
91
    }
122
  else
92
  else
123
    {
93
    {
124
      Ptr<OutputStreamWrapper> stream = ascii.CreateFileStream(cwnd_tr_file_name.c_str());
94
      Ptr<OutputStreamWrapper> stream = ascii.CreateFileStream (cwnd_tr_file_name.c_str ());
125
      Config::ConnectWithoutContext ("/NodeList/1/$ns3::TcpL4Protocol/SocketList/0/CongestionWindow",MakeBoundCallback (&CwndTracer, stream));
95
      Config::ConnectWithoutContext ("/NodeList/1/$ns3::TcpL4Protocol/SocketList/0/CongestionWindow",MakeBoundCallback (&CwndTracer, stream));
126
    }
96
    }
127
}
97
}
128
98
129
static void
99
static void
130
TraceSsThresh(std::string ssthresh_tr_file_name)
100
TraceSsThresh (std::string ssthresh_tr_file_name)
131
{
101
{
132
  AsciiTraceHelper ascii;
102
  AsciiTraceHelper ascii;
133
  if (ssthresh_tr_file_name.compare("") == 0)
103
  if (ssthresh_tr_file_name.compare ("") == 0)
134
    {
104
    {
135
      NS_LOG_DEBUG ("No trace file for ssthresh provided");
105
      NS_LOG_DEBUG ("No trace file for ssthresh provided");
136
      return;
106
      return;
137
    }
107
    }
138
  else
108
  else
139
    {
109
    {
140
      Ptr<OutputStreamWrapper> stream = ascii.CreateFileStream(ssthresh_tr_file_name.c_str());
110
      Ptr<OutputStreamWrapper> stream = ascii.CreateFileStream (ssthresh_tr_file_name.c_str ());
141
      Config::ConnectWithoutContext ("/NodeList/1/$ns3::TcpL4Protocol/SocketList/0/SlowStartThreshold",MakeBoundCallback (&SsThreshTracer, stream));
111
      Config::ConnectWithoutContext ("/NodeList/1/$ns3::TcpL4Protocol/SocketList/0/SlowStartThreshold",MakeBoundCallback (&SsThreshTracer, stream));
142
    }
112
    }
143
}
113
}
 Lines 162-186    Link Here 
162
132
163
133
164
  CommandLine cmd;
134
  CommandLine cmd;
165
  cmd.AddValue("transport_prot", "Transport protocol to use: TcpTahoe, TcpReno, TcpNewReno, TcpWestwood, TcpWestwoodPlus ", transport_prot);
135
  cmd.AddValue ("transport_prot", "Transport protocol to use: TcpTahoe, TcpReno, TcpNewReno, TcpWestwood, TcpWestwoodPlus ", transport_prot);
166
  cmd.AddValue("error_p", "Packet error rate", error_p);
136
  cmd.AddValue ("error_p", "Packet error rate", error_p);
167
  cmd.AddValue("bandwidth", "Bottleneck bandwidth", bandwidth);
137
  cmd.AddValue ("bandwidth", "Bottleneck bandwidth", bandwidth);
168
  cmd.AddValue("access_bandwidth", "Access link bandwidth", access_bandwidth);
138
  cmd.AddValue ("access_bandwidth", "Access link bandwidth", access_bandwidth);
169
  cmd.AddValue("delay", "Access link delay", access_delay);
139
  cmd.AddValue ("delay", "Access link delay", access_delay);
170
  cmd.AddValue("tracing", "Flag to enable/disable tracing", tracing);
140
  cmd.AddValue ("tracing", "Flag to enable/disable tracing", tracing);
171
  cmd.AddValue("tr_name", "Name of output trace file", tr_file_name);
141
  cmd.AddValue ("tr_name", "Name of output trace file", tr_file_name);
172
  cmd.AddValue("cwnd_tr_name", "Name of output trace file", cwnd_tr_file_name);
142
  cmd.AddValue ("cwnd_tr_name", "Name of output trace file", cwnd_tr_file_name);
173
  cmd.AddValue("ssthresh_tr_name", "Name of output trace file", ssthresh_tr_file_name);
143
  cmd.AddValue ("ssthresh_tr_name", "Name of output trace file", ssthresh_tr_file_name);
174
  cmd.AddValue("data", "Number of Megabytes of data to transmit", data_mbytes);
144
  cmd.AddValue ("data", "Number of Megabytes of data to transmit", data_mbytes);
175
  cmd.AddValue("mtu", "Size of IP packets to send in bytes", mtu_bytes);
145
  cmd.AddValue ("mtu", "Size of IP packets to send in bytes", mtu_bytes);
176
  cmd.AddValue("num_flows", "Number of flows", num_flows);
146
  cmd.AddValue ("num_flows", "Number of flows", num_flows);
177
  cmd.AddValue("duration", "Time to allow flows to run in seconds", duration);
147
  cmd.AddValue ("duration", "Time to allow flows to run in seconds", duration);
178
  cmd.AddValue("run", "Run index (for setting repeatable seeds)", run);
148
  cmd.AddValue ("run", "Run index (for setting repeatable seeds)", run);
179
  cmd.AddValue("flow_monitor", "Enable flow monitor", flow_monitor);
149
  cmd.AddValue ("flow_monitor", "Enable flow monitor", flow_monitor);
180
  cmd.Parse (argc, argv);
150
  cmd.Parse (argc, argv);
181
151
182
  SeedManager::SetSeed(1);
152
  SeedManager::SetSeed (1);
183
  SeedManager::SetRun(run);
153
  SeedManager::SetRun (run);
184
154
185
  // User may find it convenient to enable logging
155
  // User may find it convenient to enable logging
186
  //LogComponentEnable("TcpVariantsComparison", LOG_LEVEL_ALL);
156
  //LogComponentEnable("TcpVariantsComparison", LOG_LEVEL_ALL);
 Lines 188-199    Link Here 
188
  //LogComponentEnable("DropTailQueue", LOG_LEVEL_ALL);
158
  //LogComponentEnable("DropTailQueue", LOG_LEVEL_ALL);
189
159
190
  // Calculate the ADU size
160
  // Calculate the ADU size
191
  Header* temp_header = new Ipv4Header();
161
  Header* temp_header = new Ipv4Header ();
192
  uint32_t ip_header = temp_header->GetSerializedSize();
162
  uint32_t ip_header = temp_header->GetSerializedSize ();
193
  NS_LOG_LOGIC ("IP Header size is: " << ip_header);
163
  NS_LOG_LOGIC ("IP Header size is: " << ip_header);
194
  delete temp_header;
164
  delete temp_header;
195
  temp_header = new TcpHeader();
165
  temp_header = new TcpHeader ();
196
  uint32_t tcp_header = temp_header->GetSerializedSize();
166
  uint32_t tcp_header = temp_header->GetSerializedSize ();
197
  NS_LOG_LOGIC ("TCP Header size is: " << tcp_header);
167
  NS_LOG_LOGIC ("TCP Header size is: " << tcp_header);
198
  delete temp_header;
168
  delete temp_header;
199
  uint32_t tcp_adu_size = mtu_bytes - (ip_header + tcp_header);
169
  uint32_t tcp_adu_size = mtu_bytes - (ip_header + tcp_header);
 Lines 204-225    Link Here 
204
  float stop_time = start_time + duration;
174
  float stop_time = start_time + duration;
205
175
206
  // Select TCP variant
176
  // Select TCP variant
207
  if (transport_prot.compare("TcpTahoe") == 0)
177
  if (transport_prot.compare ("TcpTahoe") == 0)
208
    Config::SetDefault("ns3::TcpL4Protocol::SocketType", TypeIdValue (TcpTahoe::GetTypeId()));
178
    {
209
  else if (transport_prot.compare("TcpReno") == 0)
179
      Config::SetDefault ("ns3::TcpL4Protocol::SocketType", TypeIdValue (TcpTahoe::GetTypeId ()));
210
    Config::SetDefault("ns3::TcpL4Protocol::SocketType", TypeIdValue (TcpReno::GetTypeId()));
211
  else if (transport_prot.compare("TcpNewReno") == 0)
212
    Config::SetDefault("ns3::TcpL4Protocol::SocketType", TypeIdValue (TcpNewReno::GetTypeId()));
213
  else if (transport_prot.compare("TcpWestwood") == 0)
214
    {// the default protocol type in ns3::TcpWestwood is WESTWOOD
215
      Config::SetDefault("ns3::TcpL4Protocol::SocketType", TypeIdValue (TcpWestwood::GetTypeId()));
216
      Config::SetDefault("ns3::TcpWestwood::FilterType", EnumValue(TcpWestwood::TUSTIN));
217
    }
180
    }
218
  else if (transport_prot.compare("TcpWestwoodPlus") == 0)
181
  else if (transport_prot.compare ("TcpReno") == 0)
219
    {
182
    {
220
      Config::SetDefault("ns3::TcpL4Protocol::SocketType", TypeIdValue (TcpWestwood::GetTypeId()));
183
      Config::SetDefault ("ns3::TcpL4Protocol::SocketType", TypeIdValue (TcpReno::GetTypeId ()));
221
      Config::SetDefault("ns3::TcpWestwood::ProtocolType", EnumValue(TcpWestwood::WESTWOODPLUS));
184
    }
222
      Config::SetDefault("ns3::TcpWestwood::FilterType", EnumValue(TcpWestwood::TUSTIN));
185
  else if (transport_prot.compare ("TcpNewReno") == 0)
186
    {
187
      Config::SetDefault ("ns3::TcpL4Protocol::SocketType", TypeIdValue (TcpNewReno::GetTypeId ()));
188
    }
189
  else if (transport_prot.compare ("TcpWestwood") == 0)
190
    { // the default protocol type in ns3::TcpWestwood is WESTWOOD
191
      Config::SetDefault ("ns3::TcpL4Protocol::SocketType", TypeIdValue (TcpWestwood::GetTypeId ()));
192
      Config::SetDefault ("ns3::TcpWestwood::FilterType", EnumValue (TcpWestwood::TUSTIN));
193
    }
194
  else if (transport_prot.compare ("TcpWestwoodPlus") == 0)
195
    {
196
      Config::SetDefault ("ns3::TcpL4Protocol::SocketType", TypeIdValue (TcpWestwood::GetTypeId ()));
197
      Config::SetDefault ("ns3::TcpWestwood::ProtocolType", EnumValue (TcpWestwood::WESTWOODPLUS));
198
      Config::SetDefault ("ns3::TcpWestwood::FilterType", EnumValue (TcpWestwood::TUSTIN));
223
    }
199
    }
224
  else
200
  else
225
    {
201
    {
 Lines 231-248    Link Here 
231
  NodeContainer gateways;
207
  NodeContainer gateways;
232
  gateways.Create (1);
208
  gateways.Create (1);
233
  NodeContainer sources;
209
  NodeContainer sources;
234
  sources.Create(num_flows);
210
  sources.Create (num_flows);
235
  NodeContainer sinks;
211
  NodeContainer sinks;
236
  sinks.Create(num_flows);
212
  sinks.Create (num_flows);
237
213
238
  // Configure the error model
214
  // Configure the error model
239
  // Here we use RateErrorModel with packet error rate
215
  // Here we use RateErrorModel with packet error rate
240
  Ptr<UniformRandomVariable> uv = CreateObject<UniformRandomVariable>();
216
  Ptr<UniformRandomVariable> uv = CreateObject<UniformRandomVariable> ();
241
  uv->SetStream (50);
217
  uv->SetStream (50);
242
  RateErrorModel error_model;
218
  RateErrorModel error_model;
243
  error_model.SetRandomVariable(uv);
219
  error_model.SetRandomVariable (uv);
244
  error_model.SetUnit(RateErrorModel::ERROR_UNIT_PACKET);
220
  error_model.SetUnit (RateErrorModel::ERROR_UNIT_PACKET);
245
  error_model.SetRate(error_p);
221
  error_model.SetRate (error_p);
246
222
247
  PointToPointHelper UnReLink;
223
  PointToPointHelper UnReLink;
248
  UnReLink.SetDeviceAttribute ("DataRate", StringValue (bandwidth));
224
  UnReLink.SetDeviceAttribute ("DataRate", StringValue (bandwidth));
 Lines 262-277    Link Here 
262
  LocalLink.SetDeviceAttribute ("DataRate", StringValue (access_bandwidth));
238
  LocalLink.SetDeviceAttribute ("DataRate", StringValue (access_bandwidth));
263
  LocalLink.SetChannelAttribute ("Delay", StringValue (access_delay));
239
  LocalLink.SetChannelAttribute ("Delay", StringValue (access_delay));
264
  Ipv4InterfaceContainer sink_interfaces;
240
  Ipv4InterfaceContainer sink_interfaces;
265
  for (int i=0; i<num_flows; i++)
241
  for (int i = 0; i < num_flows; i++)
266
    {
242
    {
267
      NetDeviceContainer devices;
243
      NetDeviceContainer devices;
268
      devices = LocalLink.Install(sources.Get(i), gateways.Get(0));
244
      devices = LocalLink.Install (sources.Get (i), gateways.Get (0));
269
      address.NewNetwork();
245
      address.NewNetwork ();
270
      Ipv4InterfaceContainer interfaces = address.Assign (devices);
246
      Ipv4InterfaceContainer interfaces = address.Assign (devices);
271
      devices = UnReLink.Install(gateways.Get(0), sinks.Get(i));
247
      devices = UnReLink.Install (gateways.Get (0), sinks.Get (i));
272
      address.NewNetwork();
248
      address.NewNetwork ();
273
      interfaces = address.Assign (devices);
249
      interfaces = address.Assign (devices);
274
      sink_interfaces.Add(interfaces.Get(1));
250
      sink_interfaces.Add (interfaces.Get (1));
275
    }
251
    }
276
252
277
  NS_LOG_INFO ("Initialize Global Routing.");
253
  NS_LOG_INFO ("Initialize Global Routing.");
 Lines 281-309    Link Here 
281
  Address sinkLocalAddress (InetSocketAddress (Ipv4Address::GetAny (), port));
257
  Address sinkLocalAddress (InetSocketAddress (Ipv4Address::GetAny (), port));
282
  PacketSinkHelper sinkHelper ("ns3::TcpSocketFactory", sinkLocalAddress);
258
  PacketSinkHelper sinkHelper ("ns3::TcpSocketFactory", sinkLocalAddress);
283
259
284
  for(uint16_t i=0; i<sources.GetN(); i++)
260
  for (uint16_t i = 0; i < sources.GetN (); i++)
285
    {
261
    {
286
      AddressValue remoteAddress (InetSocketAddress (sink_interfaces.GetAddress(i, 0), port));
262
      AddressValue remoteAddress (InetSocketAddress (sink_interfaces.GetAddress (i, 0), port));
287
263
288
      if (transport_prot.compare("TcpTahoe") == 0
264
      if (transport_prot.compare ("TcpTahoe") == 0
289
          || transport_prot.compare("TcpReno") == 0
265
          || transport_prot.compare ("TcpReno") == 0
290
          || transport_prot.compare("TcpNewReno") == 0
266
          || transport_prot.compare ("TcpNewReno") == 0
291
          || transport_prot.compare("TcpWestwood") == 0
267
          || transport_prot.compare ("TcpWestwood") == 0
292
          || transport_prot.compare("TcpWestwoodPlus") == 0)
268
          || transport_prot.compare ("TcpWestwoodPlus") == 0)
293
        {
269
        {
294
          Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (tcp_adu_size));
270
          Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (tcp_adu_size));
295
          BulkSendHelper ftp("ns3::TcpSocketFactory", Address());
271
          BulkSendHelper ftp ("ns3::TcpSocketFactory", Address ());
296
          ftp.SetAttribute ("Remote", remoteAddress);
272
          ftp.SetAttribute ("Remote", remoteAddress);
297
          ftp.SetAttribute ("SendSize", UintegerValue (tcp_adu_size));
273
          ftp.SetAttribute ("SendSize", UintegerValue (tcp_adu_size));
298
          ftp.SetAttribute ("MaxBytes", UintegerValue (int(data_mbytes*1000000)));
274
          ftp.SetAttribute ("MaxBytes", UintegerValue (int(data_mbytes * 1000000)));
299
275
300
          ApplicationContainer sourceApp = ftp.Install (sources.Get(i));
276
          ApplicationContainer sourceApp = ftp.Install (sources.Get (i));
301
          sourceApp.Start (Seconds (start_time*i));
277
          sourceApp.Start (Seconds (start_time * i));
302
          sourceApp.Stop (Seconds (stop_time - 3));
278
          sourceApp.Stop (Seconds (stop_time - 3));
303
279
304
          sinkHelper.SetAttribute ("Protocol", TypeIdValue (TcpSocketFactory::GetTypeId ()));
280
          sinkHelper.SetAttribute ("Protocol", TypeIdValue (TcpSocketFactory::GetTypeId ()));
305
          ApplicationContainer sinkApp = sinkHelper.Install (sinks);
281
          ApplicationContainer sinkApp = sinkHelper.Install (sinks);
306
          sinkApp.Start (Seconds (start_time*i));
282
          sinkApp.Start (Seconds (start_time * i));
307
          sinkApp.Stop (Seconds (stop_time));
283
          sinkApp.Stop (Seconds (stop_time));
308
        }
284
        }
309
      else
285
      else
 Lines 318-356    Link Here 
318
    {
294
    {
319
      std::ofstream ascii;
295
      std::ofstream ascii;
320
      Ptr<OutputStreamWrapper> ascii_wrap;
296
      Ptr<OutputStreamWrapper> ascii_wrap;
321
      if (tr_file_name.compare("") == 0)
297
      if (tr_file_name.compare ("") == 0)
322
        {
298
        {
323
          NS_LOG_DEBUG ("No trace file provided");
299
          NS_LOG_DEBUG ("No trace file provided");
324
          exit (1);
300
          exit (1);
325
        }
301
        }
326
      else
302
      else
327
        {
303
        {
328
          ascii.open (tr_file_name.c_str());
304
          ascii.open (tr_file_name.c_str ());
329
          ascii_wrap = new OutputStreamWrapper(tr_file_name.c_str(), std::ios::out);
305
          ascii_wrap = new OutputStreamWrapper (tr_file_name.c_str (), std::ios::out);
330
        }
306
        }
331
307
332
      stack.EnableAsciiIpv4All (ascii_wrap);
308
      stack.EnableAsciiIpv4All (ascii_wrap);
333
309
334
      Simulator::Schedule(Seconds(0.00001), &TraceCwnd, cwnd_tr_file_name);
310
      Simulator::Schedule (Seconds (0.00001), &TraceCwnd, cwnd_tr_file_name);
335
      Simulator::Schedule(Seconds(0.00001), &TraceSsThresh, ssthresh_tr_file_name);
311
      Simulator::Schedule (Seconds (0.00001), &TraceSsThresh, ssthresh_tr_file_name);
336
    }
312
    }
337
313
338
  UnReLink.EnablePcapAll("TcpVariantsComparison", true);
314
  UnReLink.EnablePcapAll ("TcpVariantsComparison", true);
339
  LocalLink.EnablePcapAll("TcpVariantsComparison", true);
315
  LocalLink.EnablePcapAll ("TcpVariantsComparison", true);
340
316
341
  // Flow monitor
317
  // Flow monitor
342
  FlowMonitorHelper flowHelper;
318
  FlowMonitorHelper flowHelper;
343
  if (flow_monitor)
319
  if (flow_monitor)
344
    {
320
    {
345
      flowHelper.InstallAll();
321
      flowHelper.InstallAll ();
346
    }
322
    }
347
323
348
  Simulator::Stop (Seconds(stop_time));
324
  Simulator::Stop (Seconds (stop_time));
349
  Simulator::Run ();
325
  Simulator::Run ();
350
326
351
  if (flow_monitor)
327
  if (flow_monitor)
352
    {
328
    {
353
      flowHelper.SerializeToXmlFile("TcpVariantsComparison.flowmonitor", true, true);
329
      flowHelper.SerializeToXmlFile ("TcpVariantsComparison.flowmonitor", true, true);
354
    }
330
    }
355
331
356
  Simulator::Destroy ();
332
  Simulator::Destroy ();
(-)a/src/internet/model/nsc-tcp-socket-impl.cc (-4 / +9 lines)
 Lines 57-62    Link Here 
57
    .AddTraceSource ("CongestionWindow",
57
    .AddTraceSource ("CongestionWindow",
58
                     "The TCP connection's congestion window",
58
                     "The TCP connection's congestion window",
59
                     MakeTraceSourceAccessor (&NscTcpSocketImpl::m_cWnd))
59
                     MakeTraceSourceAccessor (&NscTcpSocketImpl::m_cWnd))
60
    .AddTraceSource ("SlowStartThreshold",
61
                     "TCP slow start threshold (bytes)",
62
                     MakeTraceSourceAccessor (&NscTcpSocketImpl::m_ssThresh))
60
  ;
63
  ;
61
  return tid;
64
  return tid;
62
}
65
}
 Lines 106-111    Link Here 
106
    m_cWnd (sock.m_cWnd),
109
    m_cWnd (sock.m_cWnd),
107
    m_ssThresh (sock.m_ssThresh),
110
    m_ssThresh (sock.m_ssThresh),
108
    m_initialCWnd (sock.m_initialCWnd),
111
    m_initialCWnd (sock.m_initialCWnd),
112
    m_initialSsThresh (sock.m_initialSsThresh),
109
    m_lastMeasuredRtt (Seconds (0.0)),
113
    m_lastMeasuredRtt (Seconds (0.0)),
110
    m_cnTimeout (sock.m_cnTimeout),
114
    m_cnTimeout (sock.m_cnTimeout),
111
    m_cnCount (sock.m_cnCount),
115
    m_cnCount (sock.m_cnCount),
 Lines 152-157    Link Here 
152
  m_node = node;
156
  m_node = node;
153
  // Initialize some variables 
157
  // Initialize some variables 
154
  m_cWnd = m_initialCWnd * m_segmentSize;
158
  m_cWnd = m_initialCWnd * m_segmentSize;
159
  m_ssThresh = m_initialSsThresh;
155
  m_rxWindowSize = m_advertisedWindowSize;
160
  m_rxWindowSize = m_advertisedWindowSize;
156
}
161
}
157
162
 Lines 730-744    Link Here 
730
}
735
}
731
736
732
void
737
void
733
NscTcpSocketImpl::SetSSThresh (uint32_t threshold)
738
NscTcpSocketImpl::SetInitialSSThresh (uint32_t threshold)
734
{
739
{
735
  m_ssThresh = threshold;
740
  m_initialSsThresh = threshold;
736
}
741
}
737
742
738
uint32_t
743
uint32_t
739
NscTcpSocketImpl::GetSSThresh (void) const
744
NscTcpSocketImpl::GetInitialSSThresh (void) const
740
{
745
{
741
  return m_ssThresh;
746
  return m_initialSsThresh;
742
}
747
}
743
748
744
void
749
void
(-)a/src/internet/model/nsc-tcp-socket-impl.h (-3 / +4 lines)
 Lines 187-194    Link Here 
187
   * \returns the window size
187
   * \returns the window size
188
   */
188
   */
189
  virtual uint32_t GetAdvWin (void) const;
189
  virtual uint32_t GetAdvWin (void) const;
190
  virtual void SetSSThresh (uint32_t threshold);
190
  virtual void SetInitialSSThresh (uint32_t threshold);
191
  virtual uint32_t GetSSThresh (void) const;
191
  virtual uint32_t GetInitialSSThresh (void) const;
192
  virtual void SetInitialCwnd (uint32_t cwnd);
192
  virtual void SetInitialCwnd (uint32_t cwnd);
193
  virtual uint32_t GetInitialCwnd (void) const;
193
  virtual uint32_t GetInitialCwnd (void) const;
194
  virtual void SetConnTimeout (Time timeout);
194
  virtual void SetConnTimeout (Time timeout);
 Lines 240-248    Link Here 
240
  uint32_t                       m_segmentSize;          //!< SegmentSize
240
  uint32_t                       m_segmentSize;          //!< SegmentSize
241
  uint32_t                       m_rxWindowSize;         //!< Receive window size
241
  uint32_t                       m_rxWindowSize;         //!< Receive window size
242
  uint32_t                       m_advertisedWindowSize; //!< Window to advertise
242
  uint32_t                       m_advertisedWindowSize; //!< Window to advertise
243
  TracedValue<uint32_t>          m_ssThresh;             //!< Slow Start Threshold
243
  TracedValue<uint32_t>          m_cWnd;                 //!< Congestion window
244
  TracedValue<uint32_t>          m_cWnd;                 //!< Congestion window
244
  uint32_t                       m_ssThresh;             //!< Slow Start Threshold
245
  uint32_t                       m_initialCWnd;          //!< Initial cWnd value
245
  uint32_t                       m_initialCWnd;          //!< Initial cWnd value
246
  uint32_t                       m_initialSsThresh;      //!< Initial Slow Start Threshold
246
247
247
  // Round trip time estimation
248
  // Round trip time estimation
248
  Time m_lastMeasuredRtt; //!< Last measured RTT
249
  Time m_lastMeasuredRtt; //!< Last measured RTT
(-)a/src/internet/model/tcp-newreno.cc (-9 / +14 lines)
 Lines 45-57    Link Here 
45
                    MakeUintegerAccessor (&TcpNewReno::m_retxThresh),
45
                    MakeUintegerAccessor (&TcpNewReno::m_retxThresh),
46
                    MakeUintegerChecker<uint32_t> ())
46
                    MakeUintegerChecker<uint32_t> ())
47
    .AddAttribute ("LimitedTransmit", "Enable limited transmit",
47
    .AddAttribute ("LimitedTransmit", "Enable limited transmit",
48
		    BooleanValue (false),
48
                   BooleanValue (false),
49
		    MakeBooleanAccessor (&TcpNewReno::m_limitedTx),
49
                   MakeBooleanAccessor (&TcpNewReno::m_limitedTx),
50
		    MakeBooleanChecker ())
50
                   MakeBooleanChecker ())
51
    .AddTraceSource ("CongestionWindow",
51
    .AddTraceSource ("CongestionWindow",
52
                     "The TCP connection's congestion window",
52
                     "The TCP connection's congestion window",
53
                     MakeTraceSourceAccessor (&TcpNewReno::m_cWnd))
53
                     MakeTraceSourceAccessor (&TcpNewReno::m_cWnd))
54
  ;
54
    .AddTraceSource ("SlowStartThreshold",
55
                     "TCP slow start threshold (bytes)",
56
                     MakeTraceSourceAccessor (&TcpNewReno::m_ssThresh))
57
 ;
55
  return tid;
58
  return tid;
56
}
59
}
57
60
 Lines 134-140    Link Here 
134
    }
137
    }
135
  else if (m_inFastRec && seq >= m_recover)
138
  else if (m_inFastRec && seq >= m_recover)
136
    { // Full ACK (RFC2582 sec.3 bullet #5 paragraph 2, option 1)
139
    { // Full ACK (RFC2582 sec.3 bullet #5 paragraph 2, option 1)
137
      m_cWnd = std::min (m_ssThresh, BytesInFlight () + m_segmentSize);
140
      m_cWnd = std::min (m_ssThresh.Get (), BytesInFlight () + m_segmentSize);
138
      m_inFastRec = false;
141
      m_inFastRec = false;
139
      NS_LOG_INFO ("Received full ACK. Leaving fast recovery with cwnd set to " << m_cWnd);
142
      NS_LOG_INFO ("Received full ACK. Leaving fast recovery with cwnd set to " << m_cWnd);
140
    }
143
    }
 Lines 220-234    Link Here 
220
}
223
}
221
224
222
void
225
void
223
TcpNewReno::SetSSThresh (uint32_t threshold)
226
TcpNewReno::SetInitialSSThresh (uint32_t threshold)
224
{
227
{
225
  m_ssThresh = threshold;
228
  NS_ABORT_MSG_UNLESS (m_state == CLOSED, "TcpNewReno::SetSSThresh() cannot change initial ssThresh after connection started.");
229
  m_initialSsThresh = threshold;
226
}
230
}
227
231
228
uint32_t
232
uint32_t
229
TcpNewReno::GetSSThresh (void) const
233
TcpNewReno::GetInitialSSThresh (void) const
230
{
234
{
231
  return m_ssThresh;
235
  return m_initialSsThresh;
232
}
236
}
233
237
234
void
238
void
 Lines 253-258    Link Here 
253
   * m_segmentSize are set by the attribute system in ns3::TcpSocket.
257
   * m_segmentSize are set by the attribute system in ns3::TcpSocket.
254
   */
258
   */
255
  m_cWnd = m_initialCWnd * m_segmentSize;
259
  m_cWnd = m_initialCWnd * m_segmentSize;
260
  m_ssThresh = m_initialSsThresh;
256
}
261
}
257
262
258
} // namespace ns3
263
} // namespace ns3
(-)a/src/internet/model/tcp-newreno.h (-3 / +4 lines)
 Lines 65-72    Link Here 
65
65
66
  // Implementing ns3::TcpSocket -- Attribute get/set
66
  // Implementing ns3::TcpSocket -- Attribute get/set
67
  virtual void     SetSegSize (uint32_t size);
67
  virtual void     SetSegSize (uint32_t size);
68
  virtual void     SetSSThresh (uint32_t threshold);
68
  virtual void     SetInitialSSThresh (uint32_t threshold);
69
  virtual uint32_t GetSSThresh (void) const;
69
  virtual uint32_t GetInitialSSThresh (void) const;
70
  virtual void     SetInitialCwnd (uint32_t cwnd);
70
  virtual void     SetInitialCwnd (uint32_t cwnd);
71
  virtual uint32_t GetInitialCwnd (void) const;
71
  virtual uint32_t GetInitialCwnd (void) const;
72
private:
72
private:
 Lines 77-84    Link Here 
77
77
78
protected:
78
protected:
79
  TracedValue<uint32_t>  m_cWnd;         //!< Congestion window
79
  TracedValue<uint32_t>  m_cWnd;         //!< Congestion window
80
  uint32_t               m_ssThresh;     //!< Slow Start Threshold
80
  TracedValue<uint32_t>  m_ssThresh;     //!< Slow Start Threshold
81
  uint32_t               m_initialCWnd;  //!< Initial cWnd value
81
  uint32_t               m_initialCWnd;  //!< Initial cWnd value
82
  uint32_t               m_initialSsThresh;  //!< Initial Slow Start Threshold value
82
  SequenceNumber32       m_recover;      //!< Previous highest Tx seqnum for fast recovery
83
  SequenceNumber32       m_recover;      //!< Previous highest Tx seqnum for fast recovery
83
  uint32_t               m_retxThresh;   //!< Fast Retransmit threshold
84
  uint32_t               m_retxThresh;   //!< Fast Retransmit threshold
84
  bool                   m_inFastRec;    //!< currently in fast recovery
85
  bool                   m_inFastRec;    //!< currently in fast recovery
(-)a/src/internet/model/tcp-reno.cc (-4 / +9 lines)
 Lines 47-52    Link Here 
47
    .AddTraceSource ("CongestionWindow",
47
    .AddTraceSource ("CongestionWindow",
48
                     "The TCP connection's congestion window",
48
                     "The TCP connection's congestion window",
49
                     MakeTraceSourceAccessor (&TcpReno::m_cWnd))
49
                     MakeTraceSourceAccessor (&TcpReno::m_cWnd))
50
    .AddTraceSource ("SlowStartThreshold",
51
                     "TCP slow start threshold (bytes)",
52
                     MakeTraceSourceAccessor (&TcpReno::m_ssThresh))
50
  ;
53
  ;
51
  return tid;
54
  return tid;
52
}
55
}
 Lines 194-208    Link Here 
194
}
197
}
195
198
196
void
199
void
197
TcpReno::SetSSThresh (uint32_t threshold)
200
TcpReno::SetInitialSSThresh (uint32_t threshold)
198
{
201
{
199
  m_ssThresh = threshold;
202
  NS_ABORT_MSG_UNLESS (m_state == CLOSED, "TcpReno::SetSSThresh() cannot change initial ssThresh after connection started.");
203
  m_initialSsThresh = threshold;
200
}
204
}
201
205
202
uint32_t
206
uint32_t
203
TcpReno::GetSSThresh (void) const
207
TcpReno::GetInitialSSThresh (void) const
204
{
208
{
205
  return m_ssThresh;
209
  return m_initialSsThresh;
206
}
210
}
207
211
208
void
212
void
 Lines 227-232    Link Here 
227
   * m_segmentSize are set by the attribute system in ns3::TcpSocket.
231
   * m_segmentSize are set by the attribute system in ns3::TcpSocket.
228
   */
232
   */
229
  m_cWnd = m_initialCWnd * m_segmentSize;
233
  m_cWnd = m_initialCWnd * m_segmentSize;
234
  m_ssThresh = m_initialSsThresh;
230
}
235
}
231
236
232
} // namespace ns3
237
} // namespace ns3
(-)a/src/internet/model/tcp-reno.h (-3 / +4 lines)
 Lines 67-74    Link Here 
67
67
68
  // Implementing ns3::TcpSocket -- Attribute get/set
68
  // Implementing ns3::TcpSocket -- Attribute get/set
69
  virtual void     SetSegSize (uint32_t size);
69
  virtual void     SetSegSize (uint32_t size);
70
  virtual void     SetSSThresh (uint32_t threshold);
70
  virtual void     SetInitialSSThresh (uint32_t threshold);
71
  virtual uint32_t GetSSThresh (void) const;
71
  virtual uint32_t GetInitialSSThresh (void) const;
72
  virtual void     SetInitialCwnd (uint32_t cwnd);
72
  virtual void     SetInitialCwnd (uint32_t cwnd);
73
  virtual uint32_t GetInitialCwnd (void) const;
73
  virtual uint32_t GetInitialCwnd (void) const;
74
private:
74
private:
 Lines 79-86    Link Here 
79
79
80
protected:
80
protected:
81
  TracedValue<uint32_t>  m_cWnd;         //!< Congestion window
81
  TracedValue<uint32_t>  m_cWnd;         //!< Congestion window
82
  uint32_t               m_ssThresh;     //!< Slow Start Threshold
82
  TracedValue<uint32_t>  m_ssThresh;     //!< Slow Start Threshold
83
  uint32_t               m_initialCWnd;  //!< Initial cWnd value
83
  uint32_t               m_initialCWnd;  //!< Initial cWnd value
84
  uint32_t               m_initialSsThresh;  //!< Initial Slow Start Threshold value
84
  uint32_t               m_retxThresh;   //!< Fast Retransmit threshold
85
  uint32_t               m_retxThresh;   //!< Fast Retransmit threshold
85
  bool                   m_inFastRec;    //!< currently in fast recovery
86
  bool                   m_inFastRec;    //!< currently in fast recovery
86
};
87
};
(-)a/src/internet/model/tcp-rfc793.cc (-2 / +2 lines)
 Lines 63-75    Link Here 
63
}
63
}
64
64
65
void
65
void
66
TcpRfc793::SetSSThresh (uint32_t threshold)
66
TcpRfc793::SetInitialSSThresh (uint32_t threshold)
67
{
67
{
68
  NS_LOG_WARN ("DoD TCP does not perform slow start");
68
  NS_LOG_WARN ("DoD TCP does not perform slow start");
69
}
69
}
70
70
71
uint32_t
71
uint32_t
72
TcpRfc793::GetSSThresh (void) const
72
TcpRfc793::GetInitialSSThresh (void) const
73
{
73
{
74
  NS_LOG_WARN ("DoD TCP does not perform slow start");
74
  NS_LOG_WARN ("DoD TCP does not perform slow start");
75
  return 0;
75
  return 0;
(-)a/src/internet/model/tcp-rfc793.h (-2 / +2 lines)
 Lines 58-65    Link Here 
58
protected:
58
protected:
59
  virtual Ptr<TcpSocketBase> Fork (); // Call CopyObject<TcpRfc793> to clone me
59
  virtual Ptr<TcpSocketBase> Fork (); // Call CopyObject<TcpRfc793> to clone me
60
  virtual void DupAck (const TcpHeader& t, uint32_t count);
60
  virtual void DupAck (const TcpHeader& t, uint32_t count);
61
  virtual void     SetSSThresh (uint32_t threshold);
61
  virtual void     SetInitialSSThresh (uint32_t threshold);
62
  virtual uint32_t GetSSThresh (void) const;
62
  virtual uint32_t GetInitialSSThresh (void) const;
63
  virtual void     SetInitialCwnd (uint32_t cwnd);
63
  virtual void     SetInitialCwnd (uint32_t cwnd);
64
  virtual uint32_t GetInitialCwnd (void) const;
64
  virtual uint32_t GetInitialCwnd (void) const;
65
};
65
};
(-)a/src/internet/model/tcp-socket-base.h (-2 / +2 lines)
 Lines 132-139    Link Here 
132
  virtual uint32_t GetRcvBufSize (void) const;
132
  virtual uint32_t GetRcvBufSize (void) const;
133
  virtual void     SetSegSize (uint32_t size);
133
  virtual void     SetSegSize (uint32_t size);
134
  virtual uint32_t GetSegSize (void) const;
134
  virtual uint32_t GetSegSize (void) const;
135
  virtual void     SetSSThresh (uint32_t threshold) = 0;
135
  virtual void     SetInitialSSThresh (uint32_t threshold) = 0;
136
  virtual uint32_t GetSSThresh (void) const = 0;
136
  virtual uint32_t GetInitialSSThresh (void) const = 0;
137
  virtual void     SetInitialCwnd (uint32_t cwnd) = 0;
137
  virtual void     SetInitialCwnd (uint32_t cwnd) = 0;
138
  virtual uint32_t GetInitialCwnd (void) const = 0;
138
  virtual uint32_t GetInitialCwnd (void) const = 0;
139
  virtual void     SetConnTimeout (Time timeout);
139
  virtual void     SetConnTimeout (Time timeout);
(-)a/src/internet/model/tcp-socket.cc (-4 / +4 lines)
 Lines 58-68    Link Here 
58
                   MakeUintegerAccessor (&TcpSocket::GetSegSize,
58
                   MakeUintegerAccessor (&TcpSocket::GetSegSize,
59
                                         &TcpSocket::SetSegSize),
59
                                         &TcpSocket::SetSegSize),
60
                   MakeUintegerChecker<uint32_t> ())
60
                   MakeUintegerChecker<uint32_t> ())
61
    .AddAttribute ("SlowStartThreshold",
61
    .AddAttribute ("InitialSlowStartThreshold",
62
                   "TCP slow start threshold (bytes)",
62
                   "TCP initial slow start threshold (bytes)",
63
                   UintegerValue (0xffff),
63
                   UintegerValue (0xffff),
64
                   MakeUintegerAccessor (&TcpSocket::GetSSThresh,
64
                   MakeUintegerAccessor (&TcpSocket::GetInitialSSThresh,
65
                                         &TcpSocket::SetSSThresh),
65
                                         &TcpSocket::SetInitialSSThresh),
66
                   MakeUintegerChecker<uint32_t> ())
66
                   MakeUintegerChecker<uint32_t> ())
67
    .AddAttribute ("InitialCwnd",
67
    .AddAttribute ("InitialCwnd",
68
                   "TCP initial congestion window size (segments)",
68
                   "TCP initial congestion window size (segments)",
(-)a/src/internet/model/tcp-socket.h (-4 / +4 lines)
 Lines 119-134    Link Here 
119
  virtual uint32_t GetSegSize (void) const = 0;
119
  virtual uint32_t GetSegSize (void) const = 0;
120
120
121
  /**
121
  /**
122
   * \brief Set the Slow Start Threshold.
122
   * \brief Set the initial Slow Start Threshold.
123
   * \param threshold the Slow Start Threshold (in bytes)
123
   * \param threshold the Slow Start Threshold (in bytes)
124
   */
124
   */
125
  virtual void SetSSThresh (uint32_t threshold) = 0;
125
  virtual void SetInitialSSThresh (uint32_t threshold) = 0;
126
126
127
  /**
127
  /**
128
   * \brief Get the Slow Start Threshold.
128
   * \brief Get the initial Slow Start Threshold.
129
   * \returns the Slow Start Threshold (in bytes)
129
   * \returns the Slow Start Threshold (in bytes)
130
   */
130
   */
131
  virtual uint32_t GetSSThresh (void) const = 0;
131
  virtual uint32_t GetInitialSSThresh (void) const = 0;
132
132
133
  /**
133
  /**
134
   * \brief Set the initial Congestion Window.
134
   * \brief Set the initial Congestion Window.
(-)a/src/internet/model/tcp-tahoe.cc (-5 / +10 lines)
 Lines 47-52    Link Here 
47
    .AddTraceSource ("CongestionWindow",
47
    .AddTraceSource ("CongestionWindow",
48
                     "The TCP connection's congestion window",
48
                     "The TCP connection's congestion window",
49
                     MakeTraceSourceAccessor (&TcpTahoe::m_cWnd))
49
                     MakeTraceSourceAccessor (&TcpTahoe::m_cWnd))
50
    .AddTraceSource ("SlowStartThreshold",
51
                     "TCP slow start threshold (bytes)",
52
                     MakeTraceSourceAccessor (&TcpTahoe::m_ssThresh))
50
  ;
53
  ;
51
  return tid;
54
  return tid;
52
}
55
}
 Lines 108-114    Link Here 
108
TcpTahoe::NewAck (SequenceNumber32 const& seq)
111
TcpTahoe::NewAck (SequenceNumber32 const& seq)
109
{
112
{
110
  NS_LOG_FUNCTION (this << seq);
113
  NS_LOG_FUNCTION (this << seq);
111
  NS_LOG_LOGIC ("TcpTahoe receieved ACK for seq " << seq <<
114
  NS_LOG_LOGIC ("TcpTahoe received ACK for seq " << seq <<
112
                " cwnd " << m_cWnd <<
115
                " cwnd " << m_cWnd <<
113
                " ssthresh " << m_ssThresh);
116
                " ssthresh " << m_ssThresh);
114
  if (m_cWnd < m_ssThresh)
117
  if (m_cWnd < m_ssThresh)
 Lines 172-186    Link Here 
172
}
175
}
173
176
174
void
177
void
175
TcpTahoe::SetSSThresh (uint32_t threshold)
178
TcpTahoe::SetInitialSSThresh (uint32_t threshold)
176
{
179
{
177
  m_ssThresh = threshold;
180
  NS_ABORT_MSG_UNLESS (m_state == CLOSED, "TcpTahoe::SetSSThresh() cannot change initial ssThresh after connection started.");
181
  m_initialSsThresh = threshold;
178
}
182
}
179
183
180
uint32_t
184
uint32_t
181
TcpTahoe::GetSSThresh (void) const
185
TcpTahoe::GetInitialSSThresh (void) const
182
{
186
{
183
  return m_ssThresh;
187
  return m_initialSsThresh;
184
}
188
}
185
189
186
void
190
void
 Lines 205-210    Link Here 
205
   * m_segmentSize are set by the attribute system in ns3::TcpSocket.
209
   * m_segmentSize are set by the attribute system in ns3::TcpSocket.
206
   */
210
   */
207
  m_cWnd = m_initialCWnd * m_segmentSize;
211
  m_cWnd = m_initialCWnd * m_segmentSize;
212
  m_ssThresh = m_initialSsThresh;
208
}
213
}
209
214
210
} // namespace ns3
215
} // namespace ns3
(-)a/src/internet/model/tcp-tahoe.h (-3 / +4 lines)
 Lines 71-78    Link Here 
71
71
72
  // Implementing ns3::TcpSocket -- Attribute get/set
72
  // Implementing ns3::TcpSocket -- Attribute get/set
73
  virtual void     SetSegSize (uint32_t size);
73
  virtual void     SetSegSize (uint32_t size);
74
  virtual void     SetSSThresh (uint32_t threshold);
74
  virtual void     SetInitialSSThresh (uint32_t threshold);
75
  virtual uint32_t GetSSThresh (void) const;
75
  virtual uint32_t GetInitialSSThresh (void) const;
76
  virtual void     SetInitialCwnd (uint32_t cwnd);
76
  virtual void     SetInitialCwnd (uint32_t cwnd);
77
  virtual uint32_t GetInitialCwnd (void) const;
77
  virtual uint32_t GetInitialCwnd (void) const;
78
private:
78
private:
 Lines 83-90    Link Here 
83
83
84
protected:
84
protected:
85
  TracedValue<uint32_t>  m_cWnd;         //!< Congestion window
85
  TracedValue<uint32_t>  m_cWnd;         //!< Congestion window
86
  uint32_t               m_ssThresh;     //!< Slow Start Threshold
86
  TracedValue<uint32_t>  m_ssThresh;     //!< Slow Start Threshold
87
  uint32_t               m_initialCWnd;  //!< Initial cWnd value
87
  uint32_t               m_initialCWnd;  //!< Initial cWnd value
88
  uint32_t               m_initialSsThresh;  //!< Initial Slow Start Threshold value
88
  uint32_t               m_retxThresh;   //!< Fast Retransmit threshold
89
  uint32_t               m_retxThresh;   //!< Fast Retransmit threshold
89
};
90
};
90
91
(-)a/src/internet/model/tcp-westwood.cc (-5 / +10 lines)
 Lines 56-61    Link Here 
56
      .AddConstructor<TcpWestwood>()
56
      .AddConstructor<TcpWestwood>()
57
      .AddTraceSource("CongestionWindow", "The TCP connection's congestion window",
57
      .AddTraceSource("CongestionWindow", "The TCP connection's congestion window",
58
                      MakeTraceSourceAccessor(&TcpWestwood::m_cWnd))
58
                      MakeTraceSourceAccessor(&TcpWestwood::m_cWnd))
59
      .AddTraceSource ("SlowStartThreshold",
60
                       "TCP slow start threshold (bytes)",
61
                       MakeTraceSourceAccessor (&TcpWestwood::m_ssThresh))
59
      .AddAttribute("FilterType", "Use this to choose no filter or Tustin's approximation filter",
62
      .AddAttribute("FilterType", "Use this to choose no filter or Tustin's approximation filter",
60
                    EnumValue(TcpWestwood::TUSTIN), MakeEnumAccessor(&TcpWestwood::m_fType),
63
                    EnumValue(TcpWestwood::TUSTIN), MakeEnumAccessor(&TcpWestwood::m_fType),
61
                    MakeEnumChecker(TcpWestwood::NONE, "None", TcpWestwood::TUSTIN, "Tustin"))
64
                    MakeEnumChecker(TcpWestwood::NONE, "None", TcpWestwood::TUSTIN, "Tustin"))
 Lines 272-278    Link Here 
272
  if (count == 3 && !m_inFastRec)
275
  if (count == 3 && !m_inFastRec)
273
    {// Triple duplicate ACK triggers fast retransmit
276
    {// Triple duplicate ACK triggers fast retransmit
274
     // Adjust cwnd and ssthresh based on the estimated BW
277
     // Adjust cwnd and ssthresh based on the estimated BW
275
      m_ssThresh = m_currentBW * static_cast<double> (m_minRtt.GetSeconds());
278
      m_ssThresh = uint32_t(m_currentBW * static_cast<double> (m_minRtt.GetSeconds()));
276
      if (m_cWnd > m_ssThresh)
279
      if (m_cWnd > m_ssThresh)
277
        {
280
        {
278
          m_cWnd = m_ssThresh;
281
          m_cWnd = m_ssThresh;
 Lines 380-396    Link Here 
380
}
383
}
381
384
382
void
385
void
383
TcpWestwood::SetSSThresh (uint32_t threshold)
386
TcpWestwood::SetInitialSSThresh (uint32_t threshold)
384
{
387
{
385
  NS_LOG_FUNCTION (this);
388
  NS_LOG_FUNCTION (this);
386
  m_ssThresh = threshold;
389
  NS_ABORT_MSG_UNLESS (m_state == CLOSED, "TcpWestwood::SetSSThresh() cannot change initial ssThresh after connection started.");
390
  m_initialSsThresh = threshold;
387
}
391
}
388
392
389
uint32_t
393
uint32_t
390
TcpWestwood::GetSSThresh (void) const
394
TcpWestwood::GetInitialSSThresh (void) const
391
{
395
{
392
  NS_LOG_FUNCTION (this);
396
  NS_LOG_FUNCTION (this);
393
  return m_ssThresh;
397
  return m_initialSsThresh;
394
}
398
}
395
399
396
void
400
void
 Lines 417-422    Link Here 
417
   * m_segmentSize are set by the attribute system in ns3::TcpSocket.
421
   * m_segmentSize are set by the attribute system in ns3::TcpSocket.
418
   */
422
   */
419
  m_cWnd = m_initialCWnd * m_segmentSize;
423
  m_cWnd = m_initialCWnd * m_segmentSize;
424
  m_ssThresh = m_initialSsThresh;
420
}
425
}
421
426
422
} // namespace ns3
427
} // namespace ns3
(-)a/src/internet/model/tcp-westwood.h (-3 / +4 lines)
 Lines 122-129    Link Here 
122
122
123
  // Implementing ns3::TcpSocket -- Attribute get/set
123
  // Implementing ns3::TcpSocket -- Attribute get/set
124
  virtual void     SetSegSize (uint32_t size);
124
  virtual void     SetSegSize (uint32_t size);
125
  virtual void     SetSSThresh (uint32_t threshold);
125
  virtual void     SetInitialSSThresh (uint32_t threshold);
126
  virtual uint32_t GetSSThresh (void) const;
126
  virtual uint32_t GetInitialSSThresh (void) const;
127
  virtual void     SetInitialCwnd (uint32_t cwnd);
127
  virtual void     SetInitialCwnd (uint32_t cwnd);
128
  virtual uint32_t GetInitialCwnd (void) const;
128
  virtual uint32_t GetInitialCwnd (void) const;
129
129
 Lines 164-171    Link Here 
164
164
165
protected:
165
protected:
166
  TracedValue<uint32_t>  m_cWnd;                   //!< Congestion window
166
  TracedValue<uint32_t>  m_cWnd;                   //!< Congestion window
167
  uint32_t               m_ssThresh;               //!< Slow Start Threshold
167
  TracedValue<uint32_t>  m_ssThresh;               //!< Slow Start Threshold
168
  uint32_t               m_initialCWnd;            //!< Initial cWnd value
168
  uint32_t               m_initialCWnd;            //!< Initial cWnd value
169
  uint32_t               m_initialSsThresh;        //!< Initial Slow Start Threshold value
169
  bool                   m_inFastRec;              //!< Currently in fast recovery if TRUE
170
  bool                   m_inFastRec;              //!< Currently in fast recovery if TRUE
170
171
171
  TracedValue<double>    m_currentBW;              //!< Current value of the estimated BW
172
  TracedValue<double>    m_currentBW;              //!< Current value of the estimated BW

Return to bug 1831