examples/routing/global-injection-slash32.cc
author Mitch Watrous
Thu, 23 Aug 2012 16:00:17 -0700
changeset 9000 3ec20a64fd08
parent 8966 060dba23e9bb
permissions -rw-r--r--
Add a constant rate setting function to the on-off helper
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4745
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
     2
/*
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
     3
 * This program is free software; you can redistribute it and/or modify
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
     4
 * it under the terms of the GNU General Public License version 2 as
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
     5
 * published by the Free Software Foundation;
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
     6
 *
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
     7
 * This program is distributed in the hope that it will be useful,
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
     8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
     9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    10
 * GNU General Public License for more details.
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    11
 *
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    12
 * You should have received a copy of the GNU General Public License
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    13
 * along with this program; if not, write to the Free Software
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    14
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    15
 *
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    16
 */
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    17
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    18
// Test program for this 3-router scenario, using global routing
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    19
//
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    20
// (a.a.a.a/32)A<--x.x.x.0/30-->B<--y.y.y.0/30-->C(c.c.c.c/32)
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    21
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    22
#include <iostream>
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    23
#include <fstream>
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    24
#include <string>
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    25
#include <cassert>
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    26
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    27
#include "ns3/csma-net-device.h"
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    28
#include "ns3/core-module.h"
6823
a27f86fb4e55 Merge node and common modules into new network module
Tom Henderson <tomh@tomh.org>
parents: 6821
diff changeset
    29
#include "ns3/network-module.h"
6848
1f453ad50ef3 Converts csma, emu, tap-bridge, point-to-point, wifi and wimax modules into modular format
Lalith Suresh <suresh.lalith@gmail.com>
parents: 6847
diff changeset
    30
#include "ns3/internet-module.h"
1f453ad50ef3 Converts csma, emu, tap-bridge, point-to-point, wifi and wimax modules into modular format
Lalith Suresh <suresh.lalith@gmail.com>
parents: 6847
diff changeset
    31
#include "ns3/point-to-point-module.h"
6847
138f00c56381 Move applications to a single module
Mitch Watrous <watrous@u.washington.edu>
parents: 6845
diff changeset
    32
#include "ns3/applications-module.h"
4745
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    33
#include "ns3/ipv4-static-routing.h"
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    34
#include "ns3/ipv4-global-routing.h"
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    35
#include "ns3/ipv4-list-routing.h"
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    36
#include "ns3/ipv4-routing-table-entry.h"
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    37
#include "ns3/global-router-interface.h"
6648
d1785ce489c5 Module layout rework for static-routing, list-routing, global-routing
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6014
diff changeset
    38
#include "ns3/ipv4-static-routing-helper.h"
d1785ce489c5 Module layout rework for static-routing, list-routing, global-routing
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6014
diff changeset
    39
#include "ns3/ipv4-list-routing-helper.h"
6649
f5413d463948 Missing ipv4-global-routing-helper.h include
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6648
diff changeset
    40
#include "ns3/ipv4-global-routing-helper.h"
4745
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    41
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    42
using namespace ns3;
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    43
using std::cout;
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    44
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    45
NS_LOG_COMPONENT_DEFINE ("GlobalRouterInjectionTest");
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    46
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    47
int 
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    48
main (int argc, char *argv[])
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    49
{
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    50
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    51
  // Allow the user to override any of the defaults and the above
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    52
  // DefaultValue::Bind ()s at run-time, via command-line arguments
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    53
  CommandLine cmd;
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    54
  cmd.Parse (argc, argv);
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    55
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    56
  Ptr<Node> nA = CreateObject<Node> ();
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    57
  Ptr<Node> nB = CreateObject<Node> ();
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    58
  Ptr<Node> nC = CreateObject<Node> ();
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    59
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    60
  NodeContainer c = NodeContainer (nA, nB, nC);
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    61
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    62
  InternetStackHelper internet;
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    63
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    64
  // Point-to-point links
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    65
  NodeContainer nAnB = NodeContainer (nA, nB);
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    66
  NodeContainer nBnC = NodeContainer (nB, nC);
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    67
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    68
  internet.Install (nAnB);
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    69
  Ipv4ListRoutingHelper staticonly;
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    70
  Ipv4ListRoutingHelper staticRouting;
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7196
diff changeset
    71
  staticonly.Add (staticRouting, 0);
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7196
diff changeset
    72
  internet.SetRoutingHelper (staticonly);  // has effect on the next Install ()
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7196
diff changeset
    73
  internet.Install (NodeContainer (nC));
4745
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    74
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    75
  // We create the channels first without any IP addressing information
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    76
  PointToPointHelper p2p;
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    77
  p2p.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    78
  p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    79
  NetDeviceContainer dAdB = p2p.Install (nAnB);
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    80
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    81
  NetDeviceContainer dBdC = p2p.Install (nBnC);;
7196
0f12b1572bca general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7157
diff changeset
    82
4745
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    83
  Ptr<CsmaNetDevice> deviceA = CreateObject<CsmaNetDevice> ();
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    84
  deviceA->SetAddress (Mac48Address::Allocate ());
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    85
  nA->AddDevice (deviceA);
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    86
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    87
  Ptr<CsmaNetDevice> deviceC = CreateObject<CsmaNetDevice> ();
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    88
  deviceC->SetAddress (Mac48Address::Allocate ());
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    89
  nC->AddDevice (deviceC);
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    90
7196
0f12b1572bca general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7157
diff changeset
    91
  // Later, we add IP addresses.
4745
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    92
  Ipv4AddressHelper ipv4;
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    93
  ipv4.SetBase ("10.1.1.0", "255.255.255.252");
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    94
  Ipv4InterfaceContainer iAiB = ipv4.Assign (dAdB);
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    95
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    96
  ipv4.SetBase ("10.1.1.4", "255.255.255.252");
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    97
  Ipv4InterfaceContainer iBiC = ipv4.Assign (dBdC);
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    98
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
    99
  Ptr<Ipv4> ipv4A = nA->GetObject<Ipv4> ();
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   100
  Ptr<Ipv4> ipv4B = nB->GetObject<Ipv4> ();
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   101
  Ptr<Ipv4> ipv4C = nC->GetObject<Ipv4> ();
7196
0f12b1572bca general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7157
diff changeset
   102
4745
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   103
  int32_t ifIndexA = ipv4A->AddInterface (deviceA);
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   104
  int32_t ifIndexC = ipv4C->AddInterface (deviceC);
7196
0f12b1572bca general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7157
diff changeset
   105
4745
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   106
  Ipv4InterfaceAddress ifInAddrA = Ipv4InterfaceAddress (Ipv4Address ("172.16.1.1"), Ipv4Mask ("255.255.255.255"));
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   107
  ipv4A->AddAddress (ifIndexA, ifInAddrA);
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   108
  ipv4A->SetMetric (ifIndexA, 1);
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   109
  ipv4A->SetUp (ifIndexA);
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   110
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   111
  Ipv4InterfaceAddress ifInAddrC = Ipv4InterfaceAddress (Ipv4Address ("192.168.1.1"), Ipv4Mask ("255.255.255.255"));
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   112
  ipv4C->AddAddress (ifIndexC, ifInAddrC);
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   113
  ipv4C->SetMetric (ifIndexC, 1);
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   114
  ipv4C->SetUp (ifIndexC);
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   115
 
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   116
  // Create router nodes, initialize routing database and set up the routing
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   117
  // tables in the nodes.
7196
0f12b1572bca general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7157
diff changeset
   118
4745
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   119
  // Populate routing tables for nodes nA and nB
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   120
  Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   121
  // Inject global routes from Node B, including transit network...
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   122
  Ptr<GlobalRouter> globalRouterB = nB->GetObject<GlobalRouter> ();
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   123
  globalRouterB->InjectRoute ("10.1.1.4", "255.255.255.252");
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   124
  // ...and the host in network "C"
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   125
  globalRouterB->InjectRoute ("192.168.1.1", "255.255.255.255");
7196
0f12b1572bca general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7157
diff changeset
   126
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7196
diff changeset
   127
  Ipv4GlobalRoutingHelper::RecomputeRoutingTables ();
4745
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   128
  // In addition, nB needs a static route to nC so it knows what to do with stuff
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   129
  // going to 192.168.1.1
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   130
  Ipv4StaticRoutingHelper ipv4RoutingHelper;
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7196
diff changeset
   131
  Ptr<Ipv4StaticRouting> staticRoutingB = ipv4RoutingHelper.GetStaticRouting (ipv4B);
4745
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   132
  staticRoutingB->AddHostRouteTo (Ipv4Address ("192.168.1.1"), Ipv4Address ("10.1.1.6"),2);
7196
0f12b1572bca general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7157
diff changeset
   133
4745
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   134
  // Create the OnOff application to send UDP datagrams of size
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   135
  // 210 bytes at a rate of 448 Kb/s
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   136
  uint16_t port = 9;   // Discard port (RFC 863)
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   137
  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: 7196
diff changeset
   138
                     Address (InetSocketAddress (ifInAddrC.GetLocal (), port)));
9000
3ec20a64fd08 Add a constant rate setting function to the on-off helper
Mitch Watrous
parents: 8966
diff changeset
   139
  onoff.SetConstantRate (DataRate (6000));
4745
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   140
  ApplicationContainer apps = onoff.Install (nA);
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   141
  apps.Start (Seconds (1.0));
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   142
  apps.Stop (Seconds (10.0));
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   143
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   144
  // Create a packet sink to receive these packets
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   145
  PacketSinkHelper sink ("ns3::UdpSocketFactory",
7196
0f12b1572bca general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7157
diff changeset
   146
                         Address (InetSocketAddress (Ipv4Address::GetAny (), port)));
4745
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   147
  apps = sink.Install (nC);
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   148
  apps.Start (Seconds (1.0));
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   149
  apps.Stop (Seconds (10.0));
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   150
6014
d251d4a44fde checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   151
  AsciiTraceHelper ascii;
d251d4a44fde checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   152
  p2p.EnableAsciiAll (ascii.CreateFileStream ("global-routing-injection32.tr"));
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
   153
  p2p.EnablePcapAll ("global-routing-injection32");
4745
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   154
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   155
  Simulator::Run ();
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   156
  Simulator::Destroy ();
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   157
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   158
  return 0;
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
diff changeset
   159
}