examples/tcp-errors.cc
author Florian Westphal <fw@strlen.de>
Wed, 03 Sep 2008 23:24:59 +0200
changeset 3595 693faf7f4e9b
parent 3384 11747ae5b632
permissions -rw-r--r--
nsc: Fix build problem if gtk config store is disabled gtk config store pulled in libdl.so for us, so things fail to link of the config store isn't enabled. This makes nsc pull in libdl itself when its enabled.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3384
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
     2
/*
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
     3
 * This program is free software; you can redistribute it and/or modify
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
     4
 * it under the terms of the GNU General Public License version 2 as
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
     5
 * published by the Free Software Foundation;
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
     6
 *
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
     7
 * This program is distributed in the hope that it will be useful,
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
     8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
     9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    10
 * GNU General Public License for more details.
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    11
 *
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    12
 * You should have received a copy of the GNU General Public License
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    13
 * along with this program; if not, write to the Free Software
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    14
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    15
 *
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    16
 */
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    17
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    18
//
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    19
// Network topology
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    20
//
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    21
//           10Mb/s, 10ms       10Mb/s, 10ms
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    22
//       n0-----------------n1-----------------n2
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    23
//
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    24
//
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    25
// - CBR traffic for 1000 seconds
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    26
// - Tracing of queues and packet receptions to file 
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    27
//   "tcp-large-transfer.tr"
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    28
// - pcap traces also generated in the following files
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    29
//   "tcp-large-transfer-$n-$i.pcap" where n and i represent node and interface
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    30
// numbers respectively
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    31
//  Usage (e.g.): ./waf --run tcp-large-transfer
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    32
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    33
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    34
#include <ctype.h>
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    35
#include <iostream>
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    36
#include <fstream>
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    37
#include <string>
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    38
#include <cassert>
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    39
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    40
#include "ns3/core-module.h"
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    41
#include "ns3/common-module.h"
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    42
#include "ns3/helper-module.h"
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    43
#include "ns3/node-module.h"
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    44
#include "ns3/global-route-manager.h"
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    45
#include "ns3/simulator-module.h"
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    46
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    47
using namespace ns3;
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    48
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    49
NS_LOG_COMPONENT_DEFINE ("TcpErrors");
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    50
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    51
int main (int argc, char *argv[])
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    52
{
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    53
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    54
  // Users may find it convenient to turn on explicit debugging
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    55
  // for selected modules; the below lines suggest how to do this
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    56
  //  LogComponentEnable("TcpL4Protocol", LOG_LEVEL_ALL);
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    57
  //  LogComponentEnable("TcpSocketImpl", LOG_LEVEL_ALL);
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    58
  //  LogComponentEnable("PacketSink", LOG_LEVEL_ALL);
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    59
  //  LogComponentEnable("TcpErrors", LOG_LEVEL_ALL);
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    60
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    61
  //
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    62
  // Make the random number generators generate reproducible results.
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    63
  //
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    64
  RandomVariable::UseGlobalSeed (1, 1, 2, 3, 5, 8);
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    65
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    66
  // Allow the user to override any of the defaults and the above
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    67
  // Bind()s at run-time, via command-line arguments
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    68
  CommandLine cmd;
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    69
  cmd.Parse (argc, argv);
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    70
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    71
  // Here, we will explicitly create three nodes.  The first container contains
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    72
  // nodes 0 and 1 from the diagram above, and the second one contains nodes
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    73
  // 1 and 2.  This reflects the channel connectivity, and will be used to
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    74
  // install the network interfaces and connect them with a channel.
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    75
  NodeContainer n0n1;
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    76
  n0n1.Create (2);
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    77
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    78
  NodeContainer n1n2;
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    79
  n1n2.Add (n0n1.Get (1));
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    80
  n1n2.Create (1);
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    81
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    82
  // We create the channels first without any IP addressing information
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    83
  // First make and configure the helper, so that it will put the appropriate
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    84
  // parameters on the network interfaces and channels we are about to install.
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    85
  PointToPointHelper p2p;
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    86
  p2p.SetDeviceAttribute ("DataRate", DataRateValue (DataRate(10000000)));
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    87
  p2p.SetChannelAttribute ("Delay", TimeValue (MilliSeconds(10)));
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    88
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    89
  // And then install devices and channels connecting our topology.
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    90
  NetDeviceContainer d0d1 = p2p.Install (n0n1);
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    91
  NetDeviceContainer d1d2 = p2p.Install (n1n2);
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    92
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    93
  // Now add ip/tcp stack to all nodes.
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    94
  NodeContainer allNodes = NodeContainer (n0n1, n1n2.Get (1));
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    95
  InternetStackHelper internet;
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    96
  internet.Install (allNodes);
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    97
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    98
  // Later, we add IP addresses.
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
    99
  Ipv4AddressHelper ipv4;
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   100
  ipv4.SetBase ("10.1.3.0", "255.255.255.0");
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   101
  Ipv4InterfaceContainer i0i1 = ipv4.Assign (d0d1);
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   102
  ipv4.SetBase ("10.1.2.0", "255.255.255.0");
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   103
  Ipv4InterfaceContainer i1i2 = ipv4.Assign (d1d2);
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   104
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   105
  // and setup ip routing tables to get total ip-level connectivity.
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   106
  GlobalRouteManager::PopulateRoutingTables ();
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   107
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   108
  // Set up the sending CBR application
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   109
  uint16_t servPort = 50000;
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   110
  Address remoteAddress(InetSocketAddress(i1i2.GetAddress (1), servPort));
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   111
  OnOffHelper clientHelper ("ns3::TcpSocketFactory", remoteAddress);
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   112
  clientHelper.SetAttribute 
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   113
      ("OnTime", RandomVariableValue (ConstantVariable (1)));
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   114
  clientHelper.SetAttribute 
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   115
      ("OffTime", RandomVariableValue (ConstantVariable (0)));
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   116
  ApplicationContainer clientApp = clientHelper.Install(n0n1.Get(0));
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   117
  clientApp.Start (Seconds (1.0));
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   118
  clientApp.Stop (Seconds (10.0));
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   119
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   120
  // Create a packet sink to receive at n2
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   121
  PacketSinkHelper sinkHelper ("ns3::TcpSocketFactory",
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   122
                         InetSocketAddress (Ipv4Address::GetAny (), servPort));
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   123
  ApplicationContainer sinkApp = sinkHelper.Install (n1n2.Get(1));
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   124
  sinkApp.Start (Seconds (1.0));
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   125
  sinkApp.Stop (Seconds (10.0));
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   126
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   127
  // We're going to model a lossy channel
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   128
  RandomVariableValue u01(UniformVariable (0.0, 1.0));
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   129
  DoubleValue rate(0.001);
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   130
  Ptr<RateErrorModel> em1 = 
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   131
      CreateObject<RateErrorModel> ("RanVar", u01, "ErrorRate", rate);
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   132
  Ptr<RateErrorModel> em2 = 
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   133
      CreateObject<RateErrorModel> ("RanVar", u01, "ErrorRate", rate);
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   134
  //put error models on both netdevices of the router nodes so that there is
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   135
  //loss of both data and acks
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   136
  d0d1.Get(1)->SetAttribute("ReceiveErrorModel", PointerValue (em1));
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   137
  d1d2.Get(0)->SetAttribute("ReceiveErrorModel", PointerValue (em2));
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   138
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   139
  //Ask for ASCII and pcap traces of network traffic
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   140
  std::ofstream ascii;
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   141
  ascii.open ("tcp-errors.tr");
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   142
  PointToPointHelper::EnableAsciiAll (ascii);
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   143
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   144
  PointToPointHelper::EnablePcapAll ("tcp-errors");
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   145
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   146
  // Finally, set up the simulator to run for 1000 seconds.
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   147
  Simulator::Stop (Seconds(1000));
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   148
  Simulator::Run ();
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   149
  Simulator::Destroy ();
11747ae5b632 Check in a tcp example which has rate error models
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
diff changeset
   150
}