Files
ns-3-dev/examples/routing/nix-simple.cc
T
Gustavo J. A. M. Carneiro b668f9f9c9 Module layout rework for static-routing, list-routing, global-routing
--HG--
rename : src/helper/ipv4-global-routing-helper.cc => src/routing/global-routing/helper/ipv4-global-routing-helper.cc
rename : src/helper/ipv4-global-routing-helper.h => src/routing/global-routing/helper/ipv4-global-routing-helper.h
rename : src/routing/global-routing/candidate-queue.cc => src/routing/global-routing/model/candidate-queue.cc
rename : src/routing/global-routing/candidate-queue.h => src/routing/global-routing/model/candidate-queue.h
rename : src/routing/global-routing/global-route-manager-impl.cc => src/routing/global-routing/model/global-route-manager-impl.cc
rename : src/routing/global-routing/global-route-manager-impl.h => src/routing/global-routing/model/global-route-manager-impl.h
rename : src/routing/global-routing/global-route-manager.cc => src/routing/global-routing/model/global-route-manager.cc
rename : src/routing/global-routing/global-route-manager.h => src/routing/global-routing/model/global-route-manager.h
rename : src/routing/global-routing/global-router-interface.cc => src/routing/global-routing/model/global-router-interface.cc
rename : src/routing/global-routing/global-router-interface.h => src/routing/global-routing/model/global-router-interface.h
rename : src/routing/global-routing/global-routing.h => src/routing/global-routing/model/global-routing.h
rename : src/routing/global-routing/ipv4-global-routing.cc => src/routing/global-routing/model/ipv4-global-routing.cc
rename : src/routing/global-routing/ipv4-global-routing.h => src/routing/global-routing/model/ipv4-global-routing.h
rename : src/helper/ipv4-list-routing-helper.cc => src/routing/list-routing/helper/ipv4-list-routing-helper.cc
rename : src/helper/ipv4-list-routing-helper.h => src/routing/list-routing/helper/ipv4-list-routing-helper.h
rename : src/helper/ipv6-list-routing-helper.cc => src/routing/list-routing/helper/ipv6-list-routing-helper.cc
rename : src/helper/ipv6-list-routing-helper.h => src/routing/list-routing/helper/ipv6-list-routing-helper.h
rename : src/routing/list-routing/ipv4-list-routing.cc => src/routing/list-routing/model/ipv4-list-routing.cc
rename : src/routing/list-routing/ipv4-list-routing.h => src/routing/list-routing/model/ipv4-list-routing.h
rename : src/routing/list-routing/ipv6-list-routing.cc => src/routing/list-routing/model/ipv6-list-routing.cc
rename : src/routing/list-routing/ipv6-list-routing.h => src/routing/list-routing/model/ipv6-list-routing.h
rename : src/helper/ipv4-static-routing-helper.cc => src/routing/static-routing/helper/ipv4-static-routing-helper.cc
rename : src/helper/ipv4-static-routing-helper.h => src/routing/static-routing/helper/ipv4-static-routing-helper.h
rename : src/helper/ipv6-static-routing-helper.cc => src/routing/static-routing/helper/ipv6-static-routing-helper.cc
rename : src/helper/ipv6-static-routing-helper.h => src/routing/static-routing/helper/ipv6-static-routing-helper.h
rename : src/routing/static-routing/ipv4-routing-table-entry.cc => src/routing/static-routing/model/ipv4-routing-table-entry.cc
rename : src/routing/static-routing/ipv4-routing-table-entry.h => src/routing/static-routing/model/ipv4-routing-table-entry.h
rename : src/routing/static-routing/ipv4-static-routing.cc => src/routing/static-routing/model/ipv4-static-routing.cc
rename : src/routing/static-routing/ipv4-static-routing.h => src/routing/static-routing/model/ipv4-static-routing.h
rename : src/routing/static-routing/ipv6-routing-table-entry.cc => src/routing/static-routing/model/ipv6-routing-table-entry.cc
rename : src/routing/static-routing/ipv6-routing-table-entry.h => src/routing/static-routing/model/ipv6-routing-table-entry.h
rename : src/routing/static-routing/ipv6-static-routing.cc => src/routing/static-routing/model/ipv6-static-routing.cc
rename : src/routing/static-routing/ipv6-static-routing.h => src/routing/static-routing/model/ipv6-static-routing.h
2010-10-26 18:02:17 +01:00

117 lines
3.4 KiB
C++

/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "ns3/core-module.h"
#include "ns3/simulator-module.h"
#include "ns3/node-module.h"
#include "ns3/helper-module.h"
#include "ns3/ipv4-static-routing-helper.h"
#include "ns3/ipv4-list-routing-helper.h"
/*
* Simple point to point links:
*
* n0 -- n1 -- n2 -- n3
*
* n0 has UdpEchoClient
* n3 has UdpEchoServer
*
* n0 IP: 10.1.1.1
* n1 IP: 10.1.1.2, 10.1.2.1
* n2 IP: 10.1.2.2, 10.1.3.1
* n3 IP: 10.1.3.2
*
*/
using namespace ns3;
NS_LOG_COMPONENT_DEFINE ("FirstScriptExample");
int
main (int argc, char *argv[])
{
LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO);
LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_INFO);
NodeContainer nodes12;
nodes12.Create (2);
NodeContainer nodes23;
nodes23.Add (nodes12.Get (1));
nodes23.Create (1);
NodeContainer nodes34;
nodes34.Add(nodes23.Get (1));
nodes34.Create (1);
PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
NodeContainer allNodes = NodeContainer (nodes12, nodes23.Get (1), nodes34.Get (1));
// NixHelper to install nix-vector routing
// on all nodes
Ipv4NixVectorHelper nixRouting;
Ipv4StaticRoutingHelper staticRouting;
Ipv4ListRoutingHelper list;
list.Add (staticRouting, 0);
list.Add (nixRouting, 10);
InternetStackHelper stack;
stack.SetRoutingHelper (list);
stack.Install (allNodes);
NetDeviceContainer devices12;
NetDeviceContainer devices23;
NetDeviceContainer devices34;
devices12 = pointToPoint.Install (nodes12);
devices23 = pointToPoint.Install (nodes23);
devices34 = pointToPoint.Install (nodes34);
Ipv4AddressHelper address1;
address1.SetBase ("10.1.1.0", "255.255.255.0");
Ipv4AddressHelper address2;
address2.SetBase ("10.1.2.0", "255.255.255.0");
Ipv4AddressHelper address3;
address3.SetBase ("10.1.3.0", "255.255.255.0");
address1.Assign (devices12);
address2.Assign (devices23);
Ipv4InterfaceContainer interfaces = address3.Assign (devices34);
UdpEchoServerHelper echoServer (9);
ApplicationContainer serverApps = echoServer.Install (nodes34.Get (1));
serverApps.Start (Seconds (1.0));
serverApps.Stop (Seconds (10.0));
UdpEchoClientHelper echoClient (interfaces.GetAddress (1), 9);
echoClient.SetAttribute ("MaxPackets", UintegerValue (1));
echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.)));
echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
ApplicationContainer clientApps = echoClient.Install (nodes12.Get (0));
clientApps.Start (Seconds (2.0));
clientApps.Stop (Seconds (10.0));
Simulator::Run ();
Simulator::Destroy ();
return 0;
}