src/test/global-routing-test-suite.cc
author Peter D. Barnes, Jr. <barnes26@llnl.gov>
Thu, 01 Aug 2013 16:26:07 -0700
changeset 10106 41f46a8e5a96
parent 9266 d26408b17360
permissions -rw-r--r--
Handle showpos bug in gcc libstc++ 4.2.
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
6626
c00446e0d643 fix valgrind issue in new global-routing test
Tom Henderson <tomh@tomh.org>
parents: 6624
diff changeset
    17
#include <vector>
6624
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    18
#include "ns3/boolean.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    19
#include "ns3/config.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    20
#include "ns3/csma-helper.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    21
#include "ns3/flow-monitor.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    22
#include "ns3/flow-monitor-helper.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-global-routing-helper.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    27
#include "ns3/ipv4-static-routing-helper.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    28
#include "ns3/node.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    29
#include "ns3/node-container.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    30
#include "ns3/on-off-helper.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    31
#include "ns3/packet.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    32
#include "ns3/packet-sink-helper.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    33
#include "ns3/packet-sink.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    34
#include "ns3/packet-socket-helper.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    35
#include "ns3/packet-socket-address.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    36
#include "ns3/csma-net-device.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    37
#include "ns3/point-to-point-helper.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    38
#include "ns3/pointer.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    39
#include "ns3/simple-channel.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    40
#include "ns3/simulator.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    41
#include "ns3/string.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    42
#include "ns3/test.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    43
#include "ns3/uinteger.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    44
#include "ns3/ipv4-packet-info-tag.h"
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
using namespace ns3;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    47
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    48
class DynamicGlobalRoutingTestCase : public TestCase
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
public:
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    51
  DynamicGlobalRoutingTestCase ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    52
  virtual ~DynamicGlobalRoutingTestCase ();
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
private:
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    55
  void SinkRx (std::string path, Ptr<const Packet> p, const Address &address);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    56
  void HandleRead (Ptr<Socket>);
6775
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6626
diff changeset
    57
  virtual void DoRun (void);
6624
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    58
  int m_count;
6626
c00446e0d643 fix valgrind issue in new global-routing test
Tom Henderson <tomh@tomh.org>
parents: 6624
diff changeset
    59
  std::vector<uint8_t> m_firstInterface;
c00446e0d643 fix valgrind issue in new global-routing test
Tom Henderson <tomh@tomh.org>
parents: 6624
diff changeset
    60
  std::vector<uint8_t> m_secondInterface;
6624
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
// 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
    64
DynamicGlobalRoutingTestCase::DynamicGlobalRoutingTestCase ()
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    65
  : TestCase ("Dynamic global routing example"), m_count (0)
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    66
{
6626
c00446e0d643 fix valgrind issue in new global-routing test
Tom Henderson <tomh@tomh.org>
parents: 6624
diff changeset
    67
  m_firstInterface.resize (16);
c00446e0d643 fix valgrind issue in new global-routing test
Tom Henderson <tomh@tomh.org>
parents: 6624
diff changeset
    68
  m_secondInterface.resize (16);
6624
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    69
}
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
DynamicGlobalRoutingTestCase::~DynamicGlobalRoutingTestCase ()
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    72
{
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    73
}
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
void
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    76
DynamicGlobalRoutingTestCase::SinkRx (std::string path, Ptr<const Packet> p, const Address& address)
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    77
{
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    78
  Ipv4PacketInfoTag tag;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    79
  bool found;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    80
  found = p->PeekPacketTag (tag);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    81
  uint8_t now = static_cast<uint8_t> (Simulator::Now ().GetSeconds ());
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    82
  if (found)
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
      ;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    85
    }
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    86
  m_firstInterface[now]++;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    87
  m_count++;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    88
}
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
void 
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    91
DynamicGlobalRoutingTestCase::HandleRead (Ptr<Socket> socket)
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    92
{
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    93
  Ptr<Packet> packet;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    94
  Address from;
7736
d3c1e0eab341 Add parenthesis in while (packet = socket->Recv ()) to make clang++ (LLVM) happy
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 7256
diff changeset
    95
  while ((packet = socket->RecvFrom (from)))
6624
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    96
    {
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7191
diff changeset
    97
      if (packet->GetSize () == 0)
6624
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    98
        { //EOF
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    99
          break;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   100
        }
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   101
      Ipv4PacketInfoTag tag;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   102
      bool found;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   103
      found = packet->PeekPacketTag (tag);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   104
      uint8_t now = static_cast<uint8_t> (Simulator::Now ().GetSeconds ());
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   105
      if (found)
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   106
        {
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   107
          if (tag.GetRecvIf () == 1)
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   108
            {
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   109
              m_firstInterface[now]++;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   110
            }
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   111
          if (tag.GetRecvIf () == 2)
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   112
            {
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   113
              m_secondInterface[now]++;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   114
            }
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   115
          m_count++;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   116
        }
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   117
    }
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   118
}
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
// Test derived from examples/routing/dynamic-global-routing.cc
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   121
//
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   122
// Network topology
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   123
//
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   124
//  n0
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   125
//     \ p-p
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   126
//      \          (shared csma/cd)
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   127
//       n2 -------------------------n3
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   128
//      /            |        | 
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   129
//     / p-p        n4        n5 ---------- n6
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   130
//   n1                             p-p
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   131
//   |                                      |
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   132
//   ----------------------------------------
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   133
//                p-p
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   134
//
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   135
// Test that for node n6, the interface facing n5 receives packets at
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   136
// times (1-2), (4-6), (8-10), (11-12), (14-16) and the interface
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   137
// facing n1 receives packets at times (2-4), (6-8), (12-13)
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   138
//
6775
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6626
diff changeset
   139
void
6624
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   140
DynamicGlobalRoutingTestCase::DoRun (void)
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   141
{
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   142
  // The below value configures the default behavior of global routing.
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   143
  // By default, it is disabled.  To respond to interface events, set to true
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   144
  Config::SetDefault ("ns3::Ipv4GlobalRouting::RespondToInterfaceEvents", BooleanValue (true));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   145
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   146
  NodeContainer c;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   147
  c.Create (7);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   148
  NodeContainer n0n2 = NodeContainer (c.Get (0), c.Get (2));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   149
  NodeContainer n1n2 = NodeContainer (c.Get (1), c.Get (2));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   150
  NodeContainer n5n6 = NodeContainer (c.Get (5), c.Get (6));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   151
  NodeContainer n1n6 = NodeContainer (c.Get (1), c.Get (6));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   152
  NodeContainer n2345 = NodeContainer (c.Get (2), c.Get (3), c.Get (4), c.Get (5));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   153
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   154
  InternetStackHelper internet;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   155
  internet.Install (c);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   156
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   157
  // 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
   158
  PointToPointHelper p2p;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   159
  p2p.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   160
  p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   161
  NetDeviceContainer d0d2 = p2p.Install (n0n2);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   162
  NetDeviceContainer d1d6 = p2p.Install (n1n6);
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
  NetDeviceContainer d1d2 = p2p.Install (n1n2);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   165
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   166
  p2p.SetDeviceAttribute ("DataRate", StringValue ("1500kbps"));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   167
  p2p.SetChannelAttribute ("Delay", StringValue ("10ms"));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   168
  NetDeviceContainer d5d6 = p2p.Install (n5n6);
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
  // 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
   171
  CsmaHelper csma;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   172
  csma.SetChannelAttribute ("DataRate", StringValue ("5Mbps"));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   173
  csma.SetChannelAttribute ("Delay", StringValue ("2ms"));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   174
  NetDeviceContainer d2345 = csma.Install (n2345);
7191
7b9f3eba908b test coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7008
diff changeset
   175
7b9f3eba908b test coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7008
diff changeset
   176
  // Later, we add IP addresses.
6624
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   177
  Ipv4AddressHelper ipv4;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   178
  ipv4.SetBase ("10.1.1.0", "255.255.255.0");
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   179
  ipv4.Assign (d0d2);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   180
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   181
  ipv4.SetBase ("10.1.2.0", "255.255.255.0");
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   182
  ipv4.Assign (d1d2);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   183
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   184
  ipv4.SetBase ("10.1.3.0", "255.255.255.0");
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   185
  Ipv4InterfaceContainer i5i6 = ipv4.Assign (d5d6);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   186
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   187
  ipv4.SetBase ("10.250.1.0", "255.255.255.0");
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   188
  ipv4.Assign (d2345);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   189
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   190
  ipv4.SetBase ("172.16.1.0", "255.255.255.0");
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   191
  Ipv4InterfaceContainer i1i6 = ipv4.Assign (d1d6);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   192
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   193
  // Create router nodes, initialize routing database and set up the routing
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   194
  // tables in the nodes.
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   195
  Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   196
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   197
  // 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
   198
  // 210 bytes at a rate of 448 Kb/s
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   199
  uint16_t port = 9;   // Discard port (RFC 863)
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   200
  OnOffHelper onoff ("ns3::UdpSocketFactory",
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   201
                     InetSocketAddress (i5i6.GetAddress (1), port));
9000
3ec20a64fd08 Add a constant rate setting function to the on-off helper
Mitch Watrous
parents: 8966
diff changeset
   202
  onoff.SetConstantRate (DataRate ("2kbps"));
6624
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   203
  onoff.SetAttribute ("PacketSize", UintegerValue (50));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   204
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   205
  ApplicationContainer apps = onoff.Install (c.Get (1));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   206
  apps.Start (Seconds (1.0));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   207
  apps.Stop (Seconds (10.0));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   208
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   209
  // Create a second OnOff application to send UDP datagrams of size
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   210
  // 210 bytes at a rate of 448 Kb/s
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   211
  OnOffHelper onoff2 ("ns3::UdpSocketFactory",
7191
7b9f3eba908b test coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7008
diff changeset
   212
                      InetSocketAddress (i1i6.GetAddress (1), port));
8966
060dba23e9bb Replace src/application usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7736
diff changeset
   213
  onoff2.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
060dba23e9bb Replace src/application usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7736
diff changeset
   214
  onoff2.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
6624
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   215
  onoff2.SetAttribute ("DataRate", StringValue ("2kbps"));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   216
  onoff2.SetAttribute ("PacketSize", UintegerValue (50));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   217
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   218
  ApplicationContainer apps2 = onoff2.Install (c.Get (1));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   219
  apps2.Start (Seconds (11.0));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   220
  apps2.Stop (Seconds (16.0));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   221
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   222
  // Create an optional packet sink to receive these packets
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   223
  TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory");
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   224
  Ptr<Socket> sink2 = Socket::CreateSocket (c.Get (6), tid);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   225
  sink2->Bind (Address (InetSocketAddress (Ipv4Address::GetAny (), port)));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   226
  sink2->Listen ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   227
  sink2->ShutdownSend ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   228
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   229
  sink2->SetRecvPktInfo (true);
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7191
diff changeset
   230
  sink2->SetRecvCallback (MakeCallback (&DynamicGlobalRoutingTestCase::HandleRead, this));
6624
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   231
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   232
  Ptr<Node> n1 = c.Get (1);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   233
  Ptr<Ipv4> ipv41 = n1->GetObject<Ipv4> ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   234
  // The first ifIndex is 0 for loopback, then the first p2p is numbered 1,
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   235
  // then the next p2p is numbered 2
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   236
  uint32_t ipv4ifIndex1 = 2;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   237
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   238
  // Trace receptions
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   239
  Config::Connect ("/NodeList/6/ApplicationList/*/$ns3::PacketSink/Rx",
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   240
                   MakeCallback (&DynamicGlobalRoutingTestCase::SinkRx, this));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   241
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   242
  Simulator::Schedule (Seconds (2),&Ipv4::SetDown,ipv41, ipv4ifIndex1);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   243
  Simulator::Schedule (Seconds (4),&Ipv4::SetUp,ipv41, ipv4ifIndex1);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   244
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   245
  Ptr<Node> n6 = c.Get (6);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   246
  Ptr<Ipv4> ipv46 = n6->GetObject<Ipv4> ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   247
  // The first ifIndex is 0 for loopback, then the first p2p is numbered 1,
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   248
  // then the next p2p is numbered 2
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   249
  uint32_t ipv4ifIndex6 = 2;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   250
  Simulator::Schedule (Seconds (6),&Ipv4::SetDown,ipv46, ipv4ifIndex6);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   251
  Simulator::Schedule (Seconds (8),&Ipv4::SetUp,ipv46, ipv4ifIndex6);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   252
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   253
  Simulator::Schedule (Seconds (12),&Ipv4::SetDown,ipv41, ipv4ifIndex1);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   254
  Simulator::Schedule (Seconds (14),&Ipv4::SetUp,ipv41, ipv4ifIndex1);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   255
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   256
  Simulator::Run ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   257
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   258
  NS_TEST_ASSERT_MSG_EQ (m_count, 68, "Dynamic global routing did not deliver all packets");
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   259
// Test that for node n6, the interface facing n5 receives packets at
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   260
// times (1-2), (4-6), (8-10), (11-12), (14-16) and the interface
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   261
// facing n1 receives packets at times (2-4), (6-8), (12-13)
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   262
  NS_TEST_ASSERT_MSG_EQ (m_firstInterface[1], 4, "Dynamic global routing did not deliver all packets");
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   263
  NS_TEST_ASSERT_MSG_EQ (m_secondInterface[2], 5, "Dynamic global routing did not deliver all packets");
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   264
  NS_TEST_ASSERT_MSG_EQ (m_secondInterface[3], 5, "Dynamic global routing did not deliver all packets");
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   265
  NS_TEST_ASSERT_MSG_EQ (m_firstInterface[4], 5, "Dynamic global routing did not deliver all packets");
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   266
  NS_TEST_ASSERT_MSG_EQ (m_firstInterface[5], 5, "Dynamic global routing did not deliver all packets");
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   267
  NS_TEST_ASSERT_MSG_EQ (m_secondInterface[6], 5, "Dynamic global routing did not deliver all packets");
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   268
  NS_TEST_ASSERT_MSG_EQ (m_secondInterface[7], 5, "Dynamic global routing did not deliver all packets");
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   269
  NS_TEST_ASSERT_MSG_EQ (m_firstInterface[8], 5, "Dynamic global routing did not deliver all packets");
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   270
  NS_TEST_ASSERT_MSG_EQ (m_firstInterface[9], 5, "Dynamic global routing did not deliver all packets");
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   271
  NS_TEST_ASSERT_MSG_EQ (m_firstInterface[10], 0, "Dynamic global routing did not deliver all packets");
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   272
  NS_TEST_ASSERT_MSG_EQ (m_firstInterface[11], 4, "Dynamic global routing did not deliver all packets");
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   273
  NS_TEST_ASSERT_MSG_EQ (m_secondInterface[12], 5, "Dynamic global routing did not deliver all packets");
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   274
  NS_TEST_ASSERT_MSG_EQ (m_secondInterface[13], 5, "Dynamic global routing did not deliver all packets");
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   275
  NS_TEST_ASSERT_MSG_EQ (m_firstInterface[14], 5, "Dynamic global routing did not deliver all packets");
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   276
  NS_TEST_ASSERT_MSG_EQ (m_firstInterface[15], 5, "Dynamic global routing did not deliver all packets");
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   277
  Simulator::Destroy ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   278
}
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   279
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   280
class GlobalRoutingSlash32TestCase : public TestCase
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   281
{
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   282
public:
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   283
  GlobalRoutingSlash32TestCase ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   284
  virtual ~GlobalRoutingSlash32TestCase ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   285
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   286
private:
6775
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6626
diff changeset
   287
  virtual void DoRun (void);
6624
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   288
};
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   289
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   290
// 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
   291
GlobalRoutingSlash32TestCase::GlobalRoutingSlash32TestCase ()
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   292
  : TestCase ("Slash 32 global routing example")
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   293
{
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   294
}
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   295
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   296
GlobalRoutingSlash32TestCase::~GlobalRoutingSlash32TestCase ()
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   297
{
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   298
}
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   299
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   300
// Test program for this 3-router scenario, using global routing
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   301
//
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   302
// (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
   303
//
6775
0783f42a364b Make test cases not return bool valuesMake all TestSuite instances be static
Mitch Watrous <watrous@u.washington.edu>
parents: 6626
diff changeset
   304
void
6624
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   305
GlobalRoutingSlash32TestCase::DoRun (void)
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   306
{
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   307
  Ptr<Node> nA = CreateObject<Node> ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   308
  Ptr<Node> nB = CreateObject<Node> ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   309
  Ptr<Node> nC = CreateObject<Node> ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   310
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   311
  NodeContainer c = NodeContainer (nA, nB, nC);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   312
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   313
  InternetStackHelper internet;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   314
  internet.Install (c);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   315
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   316
  // Point-to-point links
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   317
  NodeContainer nAnB = NodeContainer (nA, nB);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   318
  NodeContainer nBnC = NodeContainer (nB, nC);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   319
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   320
  // 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
   321
  PointToPointHelper p2p;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   322
  p2p.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   323
  p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   324
  NetDeviceContainer dAdB = p2p.Install (nAnB);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   325
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   326
  NetDeviceContainer dBdC = p2p.Install (nBnC);;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   327
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   328
  Ptr<CsmaNetDevice> deviceA = CreateObject<CsmaNetDevice> ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   329
  deviceA->SetAddress (Mac48Address::Allocate ());
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   330
  nA->AddDevice (deviceA);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   331
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   332
  Ptr<CsmaNetDevice> deviceC = CreateObject<CsmaNetDevice> ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   333
  deviceC->SetAddress (Mac48Address::Allocate ());
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   334
  nC->AddDevice (deviceC);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   335
7191
7b9f3eba908b test coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7008
diff changeset
   336
  // Later, we add IP addresses.
6624
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   337
  Ipv4AddressHelper ipv4;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   338
  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
   339
  Ipv4InterfaceContainer iAiB = ipv4.Assign (dAdB);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   340
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   341
  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
   342
  Ipv4InterfaceContainer iBiC = ipv4.Assign (dBdC);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   343
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   344
  Ptr<Ipv4> ipv4A = nA->GetObject<Ipv4> ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   345
  Ptr<Ipv4> ipv4C = nC->GetObject<Ipv4> ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   346
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   347
  int32_t ifIndexA = ipv4A->AddInterface (deviceA);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   348
  int32_t ifIndexC = ipv4C->AddInterface (deviceC);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   349
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   350
  Ipv4InterfaceAddress ifInAddrA = Ipv4InterfaceAddress (Ipv4Address ("172.16.1.1"), Ipv4Mask ("255.255.255.255"));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   351
  ipv4A->AddAddress (ifIndexA, ifInAddrA);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   352
  ipv4A->SetMetric (ifIndexA, 1);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   353
  ipv4A->SetUp (ifIndexA);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   354
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   355
  Ipv4InterfaceAddress ifInAddrC = Ipv4InterfaceAddress (Ipv4Address ("192.168.1.1"), Ipv4Mask ("255.255.255.255"));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   356
  ipv4C->AddAddress (ifIndexC, ifInAddrC);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   357
  ipv4C->SetMetric (ifIndexC, 1);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   358
  ipv4C->SetUp (ifIndexC);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   359
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   360
  // Create router nodes, initialize routing database and set up the routing
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   361
  // tables in the nodes.
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   362
  Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   363
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   364
  // 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
   365
  // 210 bytes at a rate of 448 Kb/s
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   366
  uint16_t port = 9;   // Discard port (RFC 863)
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   367
  OnOffHelper onoff ("ns3::UdpSocketFactory",
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7191
diff changeset
   368
                     Address (InetSocketAddress (ifInAddrC.GetLocal (), port)));
9000
3ec20a64fd08 Add a constant rate setting function to the on-off helper
Mitch Watrous
parents: 8966
diff changeset
   369
  onoff.SetConstantRate (DataRate (6000));
6624
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   370
  ApplicationContainer apps = onoff.Install (nA);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   371
  apps.Start (Seconds (1.0));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   372
  apps.Stop (Seconds (10.0));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   373
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   374
  // Create a packet sink to receive these packets
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   375
  PacketSinkHelper sink ("ns3::UdpSocketFactory",
7191
7b9f3eba908b test coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7008
diff changeset
   376
                         Address (InetSocketAddress (Ipv4Address::GetAny (), port)));
6624
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   377
  apps = sink.Install (nC);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   378
  apps.Start (Seconds (1.0));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   379
  apps.Stop (Seconds (10.0));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   380
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   381
  Simulator::Run ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   382
  // Check that we received 13 * 512 = 6656 bytes
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   383
  Ptr<PacketSink> sinkPtr = DynamicCast <PacketSink> (apps.Get (0));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   384
  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
   385
  Simulator::Destroy ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   386
}
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   387
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   388
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   389
class GlobalRoutingTestSuite : public TestSuite
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   390
{
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   391
public:
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   392
  GlobalRoutingTestSuite ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   393
};
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   394
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   395
GlobalRoutingTestSuite::GlobalRoutingTestSuite ()
7008
82c66d5c01f7 Relabel all build verification tests (BVT) to be unit tests (UNIT)
Mitch Watrous <watrous@u.washington.edu>
parents: 6775
diff changeset
   396
  : TestSuite ("global-routing", UNIT)
6624
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   397
{
9266
d26408b17360 bug 1563: get rid of default argument value in AddTestCase
Nicola Baldo <nbaldo@cttc.es>
parents: 9000
diff changeset
   398
  AddTestCase (new DynamicGlobalRoutingTestCase, TestCase::QUICK);
d26408b17360 bug 1563: get rid of default argument value in AddTestCase
Nicola Baldo <nbaldo@cttc.es>
parents: 9000
diff changeset
   399
  AddTestCase (new GlobalRoutingSlash32TestCase, TestCase::QUICK);
6624
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   400
}
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   401
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   402
// 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
   403
static GlobalRoutingTestSuite globalRoutingTestSuite;