src/test/global-routing-test-suite.cc
author Mitch Watrous <watrous@u.washington.edu>
Fri, 15 Oct 2010 16:31:32 -0700
changeset 6624 a071889af159
child 6626 c00446e0d643
permissions -rw-r--r--
Remove regression tests from waf
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
#include "ns3/boolean.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    18
#include "ns3/config.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    19
#include "ns3/csma-helper.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    20
#include "ns3/flow-monitor.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    21
#include "ns3/flow-monitor-helper.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    22
#include "ns3/inet-socket-address.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    23
#include "ns3/internet-stack-helper.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    24
#include "ns3/ipv4-address-helper.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    25
#include "ns3/ipv4-global-routing-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/csma-net-device.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    36
#include "ns3/point-to-point-helper.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    37
#include "ns3/pointer.h"
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    38
#include "ns3/random-variable.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>);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    57
  virtual bool DoRun (void);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    58
  int m_count;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    59
  uint8_t m_firstInterface[16];
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    60
  uint8_t m_secondInterface[16];
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
{
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    67
}
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    68
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    69
DynamicGlobalRoutingTestCase::~DynamicGlobalRoutingTestCase ()
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
}
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
void
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    74
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
    75
{
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    76
  Ipv4PacketInfoTag tag;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    77
  bool found;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    78
  found = p->PeekPacketTag (tag);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    79
  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
    80
  if (found)
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    81
    {
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    82
      ;
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
  m_firstInterface[now]++;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    85
  m_count++;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    86
}
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    87
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    88
void 
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    89
DynamicGlobalRoutingTestCase::HandleRead (Ptr<Socket> socket)
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    90
{
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    91
  Ptr<Packet> packet;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    92
  Address from;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    93
  while (packet = socket->RecvFrom (from))
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    94
    {
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    95
      if (packet->GetSize() == 0)
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    96
        { //EOF
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    97
          break;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    98
        }
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
    99
      Ipv4PacketInfoTag tag;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   100
      bool found;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   101
      found = packet->PeekPacketTag (tag);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   102
      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
   103
      if (found)
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
          if (tag.GetRecvIf () == 1)
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
              m_firstInterface[now]++;
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
          if (tag.GetRecvIf () == 2)
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
              m_secondInterface[now]++;
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_count++;
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
    }
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
// Test derived from examples/routing/dynamic-global-routing.cc
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
// Network topology
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
//  n0
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   123
//     \ p-p
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   124
//      \          (shared csma/cd)
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   125
//       n2 -------------------------n3
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   126
//      /            |        | 
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   127
//     / p-p        n4        n5 ---------- n6
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   128
//   n1                             p-p
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   129
//   |                                      |
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   130
//   ----------------------------------------
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   131
//                p-p
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
// 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
   134
// 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
   135
// 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
   136
//
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   137
bool
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   138
DynamicGlobalRoutingTestCase::DoRun (void)
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   139
{
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   140
  // 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
   141
  // 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
   142
  Config::SetDefault ("ns3::Ipv4GlobalRouting::RespondToInterfaceEvents", BooleanValue (true));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   143
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   144
  NodeContainer c;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   145
  c.Create (7);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   146
  NodeContainer n0n2 = NodeContainer (c.Get (0), c.Get (2));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   147
  NodeContainer n1n2 = NodeContainer (c.Get (1), c.Get (2));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   148
  NodeContainer n5n6 = NodeContainer (c.Get (5), c.Get (6));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   149
  NodeContainer n1n6 = NodeContainer (c.Get (1), c.Get (6));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   150
  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
   151
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   152
  InternetStackHelper internet;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   153
  internet.Install (c);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   154
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   155
  // 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
   156
  PointToPointHelper p2p;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   157
  p2p.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   158
  p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   159
  NetDeviceContainer d0d2 = p2p.Install (n0n2);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   160
  NetDeviceContainer d1d6 = p2p.Install (n1n6);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   161
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   162
  NetDeviceContainer d1d2 = p2p.Install (n1n2);
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
  p2p.SetDeviceAttribute ("DataRate", StringValue ("1500kbps"));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   165
  p2p.SetChannelAttribute ("Delay", StringValue ("10ms"));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   166
  NetDeviceContainer d5d6 = p2p.Install (n5n6);
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
  // 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
   169
  CsmaHelper csma;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   170
  csma.SetChannelAttribute ("DataRate", StringValue ("5Mbps"));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   171
  csma.SetChannelAttribute ("Delay", StringValue ("2ms"));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   172
  NetDeviceContainer d2345 = csma.Install (n2345);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   173
  
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   174
  // Later, we add IP addresses.  
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   175
  Ipv4AddressHelper ipv4;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   176
  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
   177
  ipv4.Assign (d0d2);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   178
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   179
  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
   180
  ipv4.Assign (d1d2);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   181
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   182
  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
   183
  Ipv4InterfaceContainer i5i6 = ipv4.Assign (d5d6);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   184
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   185
  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
   186
  ipv4.Assign (d2345);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   187
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   188
  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
   189
  Ipv4InterfaceContainer i1i6 = ipv4.Assign (d1d6);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   190
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   191
  // 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
   192
  // tables in the nodes.
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   193
  Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   194
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   195
  // 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
   196
  // 210 bytes at a rate of 448 Kb/s
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   197
  uint16_t port = 9;   // Discard port (RFC 863)
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   198
  OnOffHelper onoff ("ns3::UdpSocketFactory",
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   199
                     InetSocketAddress (i5i6.GetAddress (1), port));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   200
  onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1)));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   201
  onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   202
  onoff.SetAttribute ("DataRate", StringValue ("2kbps"));
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",
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   212
                     InetSocketAddress (i1i6.GetAddress (1), port));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   213
  onoff2.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1)));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   214
  onoff2.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
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);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   230
  sink2->SetRecvCallback (MakeCallback(&DynamicGlobalRoutingTestCase::HandleRead, this));
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
  return GetErrorStatus ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   280
}
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
class GlobalRoutingSlash32TestCase : public TestCase
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   283
{
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   284
public:
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   285
  GlobalRoutingSlash32TestCase ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   286
  virtual ~GlobalRoutingSlash32TestCase ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   287
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   288
private:
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   289
  virtual bool DoRun (void);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   290
};
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   291
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   292
// 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
   293
GlobalRoutingSlash32TestCase::GlobalRoutingSlash32TestCase ()
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   294
  : TestCase ("Slash 32 global routing example")
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
}
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
GlobalRoutingSlash32TestCase::~GlobalRoutingSlash32TestCase ()
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
}
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
// 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
   303
//
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   304
// (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
   305
//
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   306
bool
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   307
GlobalRoutingSlash32TestCase::DoRun (void)
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   308
{
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   309
  Ptr<Node> nA = CreateObject<Node> ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   310
  Ptr<Node> nB = CreateObject<Node> ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   311
  Ptr<Node> nC = CreateObject<Node> ();
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
  NodeContainer c = NodeContainer (nA, nB, nC);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   314
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   315
  InternetStackHelper internet;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   316
  internet.Install (c);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   317
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   318
  // Point-to-point links
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   319
  NodeContainer nAnB = NodeContainer (nA, nB);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   320
  NodeContainer nBnC = NodeContainer (nB, nC);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   321
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   322
  // 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
   323
  PointToPointHelper p2p;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   324
  p2p.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   325
  p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   326
  NetDeviceContainer dAdB = p2p.Install (nAnB);
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
  NetDeviceContainer dBdC = p2p.Install (nBnC);;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   329
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   330
  Ptr<CsmaNetDevice> deviceA = CreateObject<CsmaNetDevice> ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   331
  deviceA->SetAddress (Mac48Address::Allocate ());
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   332
  nA->AddDevice (deviceA);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   333
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   334
  Ptr<CsmaNetDevice> deviceC = CreateObject<CsmaNetDevice> ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   335
  deviceC->SetAddress (Mac48Address::Allocate ());
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   336
  nC->AddDevice (deviceC);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   337
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   338
  // Later, we add IP addresses.  
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   339
  Ipv4AddressHelper ipv4;
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   340
  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
   341
  Ipv4InterfaceContainer iAiB = ipv4.Assign (dAdB);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   342
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   343
  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
   344
  Ipv4InterfaceContainer iBiC = ipv4.Assign (dBdC);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   345
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   346
  Ptr<Ipv4> ipv4A = nA->GetObject<Ipv4> ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   347
  Ptr<Ipv4> ipv4C = nC->GetObject<Ipv4> ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   348
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   349
  int32_t ifIndexA = ipv4A->AddInterface (deviceA);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   350
  int32_t ifIndexC = ipv4C->AddInterface (deviceC);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   351
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   352
  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
   353
  ipv4A->AddAddress (ifIndexA, ifInAddrA);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   354
  ipv4A->SetMetric (ifIndexA, 1);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   355
  ipv4A->SetUp (ifIndexA);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   356
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   357
  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
   358
  ipv4C->AddAddress (ifIndexC, ifInAddrC);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   359
  ipv4C->SetMetric (ifIndexC, 1);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   360
  ipv4C->SetUp (ifIndexC);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   361
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   362
  // 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
   363
  // tables in the nodes.
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   364
  Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   365
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   366
  // 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
   367
  // 210 bytes at a rate of 448 Kb/s
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   368
  uint16_t port = 9;   // Discard port (RFC 863)
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   369
  OnOffHelper onoff ("ns3::UdpSocketFactory",
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   370
    Address (InetSocketAddress (ifInAddrC.GetLocal(), port)));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   371
  onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1)));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   372
  onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   373
  onoff.SetAttribute ("DataRate", DataRateValue (DataRate (6000)));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   374
  ApplicationContainer apps = onoff.Install (nA);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   375
  apps.Start (Seconds (1.0));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   376
  apps.Stop (Seconds (10.0));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   377
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   378
  // Create a packet sink to receive these packets
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   379
  PacketSinkHelper sink ("ns3::UdpSocketFactory",
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   380
    Address (InetSocketAddress (Ipv4Address::GetAny (), port)));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   381
  apps = sink.Install (nC);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   382
  apps.Start (Seconds (1.0));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   383
  apps.Stop (Seconds (10.0));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   384
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   385
  Simulator::Run ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   386
  // Check that we received 13 * 512 = 6656 bytes
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   387
  Ptr<PacketSink> sinkPtr = DynamicCast <PacketSink> (apps.Get (0));
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   388
  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
   389
  Simulator::Destroy ();
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
  return GetErrorStatus ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   392
}
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
class GlobalRoutingTestSuite : public TestSuite
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   396
{
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   397
public:
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   398
  GlobalRoutingTestSuite ();
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   399
};
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
GlobalRoutingTestSuite::GlobalRoutingTestSuite ()
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   402
  : TestSuite ("global-routing", BVT)
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   403
{
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   404
  AddTestCase (new DynamicGlobalRoutingTestCase);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   405
  AddTestCase (new GlobalRoutingSlash32TestCase);
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   406
}
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   407
a071889af159 Remove regression tests from waf
Mitch Watrous <watrous@u.washington.edu>
parents:
diff changeset
   408
// 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
   409
static GlobalRoutingTestSuite globalRoutingTestSuite;