src/test/static-routing-test-suite.cc
author Mitch Watrous
Mon, 13 Aug 2012 16:08:13 -0700
changeset 8966 060dba23e9bb
parent 7191 7b9f3eba908b
child 9000 3ec20a64fd08
permissions -rw-r--r--
Replace src/application usage of RandomVariable with RandomVariableStream
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6624
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
     2
/*
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
     3
 * This program is free software; you can redistribute it and/or modify
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
     4
 * it under the terms of the GNU General Public License version 2 as
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
     5
 * published by the Free Software Foundation;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
     6
 *
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
     7
 * This program is distributed in the hope that it will be useful,
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
     8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
     9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    10
 * GNU General Public License for more details.
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    11
 *
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    12
 * You should have received a copy of the GNU General Public License
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    13
 * along with this program; if not, write to the Free Software
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    14
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    15
 */
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    16
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    17
// End-to-end tests for Ipv4 static routing
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    18
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    19
#include "ns3/boolean.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    20
#include "ns3/config.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    21
#include "ns3/csma-helper.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    22
#include "ns3/csma-net-device.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    23
#include "ns3/inet-socket-address.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    24
#include "ns3/internet-stack-helper.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    25
#include "ns3/ipv4-address-helper.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    26
#include "ns3/ipv4-static-routing-helper.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    27
#include "ns3/node.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    28
#include "ns3/node-container.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    29
#include "ns3/on-off-helper.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    30
#include "ns3/packet.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    31
#include "ns3/packet-sink-helper.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    32
#include "ns3/packet-sink.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    33
#include "ns3/packet-socket-helper.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    34
#include "ns3/packet-socket-address.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    35
#include "ns3/point-to-point-helper.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    36
#include "ns3/pointer.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    37
#include "ns3/simulator.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    38
#include "ns3/string.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    39
#include "ns3/test.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    40
#include "ns3/uinteger.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    41
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    42
using namespace ns3;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    43
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    44
class StaticRoutingSlash32TestCase : public TestCase
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    45
{
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    46
public:
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    47
  StaticRoutingSlash32TestCase ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    48
  virtual ~StaticRoutingSlash32TestCase ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    49
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    50
private:
6775
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6624
diff changeset
    51
  virtual void DoRun (void);
6624
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    52
};
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    53
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    54
// Add some help text to this case to describe what it is intended to test
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    55
StaticRoutingSlash32TestCase::StaticRoutingSlash32TestCase ()
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    56
  : TestCase ("Slash 32 static routing example")
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    57
{
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    58
}
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    59
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    60
StaticRoutingSlash32TestCase::~StaticRoutingSlash32TestCase ()
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    61
{
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    62
}
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    63
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    64
// Test program for this 3-router scenario, using static routing
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    65
//
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    66
// (a.a.a.a/32)A<--x.x.x.0/30-->B<--y.y.y.0/30-->C(c.c.c.c/32)
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    67
//
6775
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6624
diff changeset
    68
void
6624
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    69
StaticRoutingSlash32TestCase::DoRun (void)
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    70
{
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    71
  Ptr<Node> nA = CreateObject<Node> ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    72
  Ptr<Node> nB = CreateObject<Node> ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    73
  Ptr<Node> nC = CreateObject<Node> ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    74
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    75
  NodeContainer c = NodeContainer (nA, nB, nC);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    76
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    77
  InternetStackHelper internet;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    78
  internet.Install (c);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    79
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    80
  // Point-to-point links
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    81
  NodeContainer nAnB = NodeContainer (nA, nB);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    82
  NodeContainer nBnC = NodeContainer (nB, nC);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    83
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    84
  // We create the channels first without any IP addressing information
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    85
  PointToPointHelper p2p;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    86
  p2p.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    87
  p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    88
  NetDeviceContainer dAdB = p2p.Install (nAnB);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    89
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    90
  NetDeviceContainer dBdC = p2p.Install (nBnC);;
7191
7b9f3eba908b test coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7008
diff changeset
    91
6624
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    92
  Ptr<CsmaNetDevice> deviceA = CreateObject<CsmaNetDevice> ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    93
  deviceA->SetAddress (Mac48Address::Allocate ());
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    94
  nA->AddDevice (deviceA);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    95
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    96
  Ptr<CsmaNetDevice> deviceC = CreateObject<CsmaNetDevice> ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    97
  deviceC->SetAddress (Mac48Address::Allocate ());
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    98
  nC->AddDevice (deviceC);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    99
7191
7b9f3eba908b test coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7008
diff changeset
   100
  // Later, we add IP addresses.
6624
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   101
  Ipv4AddressHelper ipv4;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   102
  ipv4.SetBase ("10.1.1.0", "255.255.255.252");
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   103
  Ipv4InterfaceContainer iAiB = ipv4.Assign (dAdB);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   104
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   105
  ipv4.SetBase ("10.1.1.4", "255.255.255.252");
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   106
  Ipv4InterfaceContainer iBiC = ipv4.Assign (dBdC);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   107
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   108
  Ptr<Ipv4> ipv4A = nA->GetObject<Ipv4> ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   109
  Ptr<Ipv4> ipv4B = nB->GetObject<Ipv4> ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   110
  Ptr<Ipv4> ipv4C = nC->GetObject<Ipv4> ();
7191
7b9f3eba908b test coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7008
diff changeset
   111
6624
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   112
  int32_t ifIndexA = ipv4A->AddInterface (deviceA);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   113
  int32_t ifIndexC = ipv4C->AddInterface (deviceC);
7191
7b9f3eba908b test coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7008
diff changeset
   114
6624
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   115
  Ipv4InterfaceAddress ifInAddrA = Ipv4InterfaceAddress (Ipv4Address ("172.16.1.1"), Ipv4Mask ("/32"));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   116
  ipv4A->AddAddress (ifIndexA, ifInAddrA);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   117
  ipv4A->SetMetric (ifIndexA, 1);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   118
  ipv4A->SetUp (ifIndexA);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   119
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   120
  Ipv4InterfaceAddress ifInAddrC = Ipv4InterfaceAddress (Ipv4Address ("192.168.1.1"), Ipv4Mask ("/32"));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   121
  ipv4C->AddAddress (ifIndexC, ifInAddrC);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   122
  ipv4C->SetMetric (ifIndexC, 1);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   123
  ipv4C->SetUp (ifIndexC);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   124
 
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   125
  Ipv4StaticRoutingHelper ipv4RoutingHelper;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   126
  // Create static routes from A to C
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   127
  Ptr<Ipv4StaticRouting> staticRoutingA = ipv4RoutingHelper.GetStaticRouting (ipv4A);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   128
  // The ifIndex for this outbound route is 1; the first p2p link added
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   129
  staticRoutingA->AddHostRouteTo (Ipv4Address ("192.168.1.1"), Ipv4Address ("10.1.1.2"), 1);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   130
  Ptr<Ipv4StaticRouting> staticRoutingB = ipv4RoutingHelper.GetStaticRouting (ipv4B);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   131
  // The ifIndex we want on node B is 2; 0 corresponds to loopback, and 1 to the first point to point link
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   132
  staticRoutingB->AddHostRouteTo (Ipv4Address ("192.168.1.1"), Ipv4Address ("10.1.1.6"), 2);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   133
  // Create the OnOff application to send UDP datagrams of size
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   134
  // 210 bytes at a rate of 448 Kb/s
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   135
  uint16_t port = 9;   // Discard port (RFC 863)
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   136
  OnOffHelper onoff ("ns3::UdpSocketFactory", 
7191
7b9f3eba908b test coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7008
diff changeset
   137
                     Address (InetSocketAddress (ifInAddrC.GetLocal (), port)));
8966
060dba23e9bb Replace src/application usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7191
diff changeset
   138
  onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
060dba23e9bb Replace src/application usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7191
diff changeset
   139
  onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
6624
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   140
  onoff.SetAttribute ("DataRate", DataRateValue (DataRate (6000)));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   141
  ApplicationContainer apps = onoff.Install (nA);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   142
  apps.Start (Seconds (1.0));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   143
  apps.Stop (Seconds (10.0));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   144
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   145
  // Create a packet sink to receive these packets
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   146
  PacketSinkHelper sink ("ns3::UdpSocketFactory",
7191
7b9f3eba908b test coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7008
diff changeset
   147
                         Address (InetSocketAddress (Ipv4Address::GetAny (), port)));
6624
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   148
  apps = sink.Install (nC);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   149
  apps.Start (Seconds (1.0));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   150
  apps.Stop (Seconds (10.0));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   151
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   152
  Simulator::Run ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   153
  // Check that we received 13 * 512 = 6656 bytes
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   154
  Ptr<PacketSink> sinkPtr = DynamicCast <PacketSink> (apps.Get (0));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   155
  NS_TEST_ASSERT_MSG_EQ (sinkPtr->GetTotalRx (), 6656, "Static routing with /32 did not deliver all packets");
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   156
  Simulator::Destroy ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   157
}
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   158
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   159
class StaticRoutingTestSuite : public TestSuite
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   160
{
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   161
public:
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   162
  StaticRoutingTestSuite ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   163
};
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   164
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   165
StaticRoutingTestSuite::StaticRoutingTestSuite ()
7008
82c66d5c01f7 Relabel all build verification tests (BVT) to be unit tests (UNIT)
Mitch Watrous <watrous@u.washington.edu>
parents: 6775
diff changeset
   166
  : TestSuite ("static-routing", UNIT)
6624
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   167
{
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   168
  AddTestCase (new StaticRoutingSlash32TestCase);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   169
}
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   170
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   171
// Do not forget to allocate an instance of this TestSuite
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   172
static StaticRoutingTestSuite staticRoutingTestSuite;