Files
ns-3-dev/examples/tutorial/second.cc
T
Mitch Watrous 75845a078e Move applications to a single module
--HG--
rename : src/helper/bulk-send-helper.cc => src/applications/helper/bulk-send-helper.cc
rename : src/helper/bulk-send-helper.h => src/applications/helper/bulk-send-helper.h
rename : src/helper/on-off-helper.cc => src/applications/helper/on-off-helper.cc
rename : src/helper/on-off-helper.h => src/applications/helper/on-off-helper.h
rename : src/helper/packet-sink-helper.cc => src/applications/helper/packet-sink-helper.cc
rename : src/helper/packet-sink-helper.h => src/applications/helper/packet-sink-helper.h
rename : src/helper/ping6-helper.cc => src/applications/helper/ping6-helper.cc
rename : src/helper/ping6-helper.h => src/applications/helper/ping6-helper.h
rename : src/helper/udp-client-server-helper.cc => src/applications/helper/udp-client-server-helper.cc
rename : src/helper/udp-client-server-helper.h => src/applications/helper/udp-client-server-helper.h
rename : src/helper/udp-echo-helper.cc => src/applications/helper/udp-echo-helper.cc
rename : src/helper/udp-echo-helper.h => src/applications/helper/udp-echo-helper.h
rename : src/helper/v4ping-helper.cc => src/applications/helper/v4ping-helper.cc
rename : src/helper/v4ping-helper.h => src/applications/helper/v4ping-helper.h
rename : src/applications/bulk-send/bulk-send-application.cc => src/applications/model/bulk-send-application.cc
rename : src/applications/bulk-send/bulk-send-application.h => src/applications/model/bulk-send-application.h
rename : src/applications/onoff/onoff-application.cc => src/applications/model/onoff-application.cc
rename : src/applications/onoff/onoff-application.h => src/applications/model/onoff-application.h
rename : src/applications/udp-client-server/packet-loss-counter.cc => src/applications/model/packet-loss-counter.cc
rename : src/applications/udp-client-server/packet-loss-counter.h => src/applications/model/packet-loss-counter.h
rename : src/applications/packet-sink/packet-sink.cc => src/applications/model/packet-sink.cc
rename : src/applications/packet-sink/packet-sink.h => src/applications/model/packet-sink.h
rename : src/applications/ping6/ping6.cc => src/applications/model/ping6.cc
rename : src/applications/ping6/ping6.h => src/applications/model/ping6.h
rename : src/applications/radvd/radvd-interface.cc => src/applications/model/radvd-interface.cc
rename : src/applications/radvd/radvd-interface.h => src/applications/model/radvd-interface.h
rename : src/applications/radvd/radvd-prefix.cc => src/applications/model/radvd-prefix.cc
rename : src/applications/radvd/radvd-prefix.h => src/applications/model/radvd-prefix.h
rename : src/applications/radvd/radvd.cc => src/applications/model/radvd.cc
rename : src/applications/radvd/radvd.h => src/applications/model/radvd.h
rename : src/applications/udp-client-server/seq-ts-header.cc => src/applications/model/seq-ts-header.cc
rename : src/applications/udp-client-server/seq-ts-header.h => src/applications/model/seq-ts-header.h
rename : src/applications/udp-client-server/udp-client.cc => src/applications/model/udp-client.cc
rename : src/applications/udp-client-server/udp-client.h => src/applications/model/udp-client.h
rename : src/applications/udp-echo/udp-echo-client.cc => src/applications/model/udp-echo-client.cc
rename : src/applications/udp-echo/udp-echo-client.h => src/applications/model/udp-echo-client.h
rename : src/applications/udp-echo/udp-echo-server.cc => src/applications/model/udp-echo-server.cc
rename : src/applications/udp-echo/udp-echo-server.h => src/applications/model/udp-echo-server.h
rename : src/applications/udp-client-server/udp-server.cc => src/applications/model/udp-server.cc
rename : src/applications/udp-client-server/udp-server.h => src/applications/model/udp-server.h
rename : src/applications/udp-client-server/udp-trace-client.cc => src/applications/model/udp-trace-client.cc
rename : src/applications/udp-client-server/udp-trace-client.h => src/applications/model/udp-trace-client.h
rename : src/applications/v4ping/v4ping.cc => src/applications/model/v4ping.cc
rename : src/applications/v4ping/v4ping.h => src/applications/model/v4ping.h
rename : src/applications/udp-client-server/udp-client-server-test.cc => src/applications/test/udp-client-server-test.cc
2011-03-02 13:42:28 -08:00

114 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/network-module.h"
#include "ns3/helper-module.h"
#include "ns3/applications-module.h"
#include "ns3/ipv4-global-routing-helper.h"
// Default Network Topology
//
// 10.1.1.0
// n0 -------------- n1 n2 n3 n4
// point-to-point | | | |
// ================
// LAN 10.1.2.0
using namespace ns3;
NS_LOG_COMPONENT_DEFINE ("SecondScriptExample");
int
main (int argc, char *argv[])
{
bool verbose = true;
uint32_t nCsma = 3;
CommandLine cmd;
cmd.AddValue ("nCsma", "Number of \"extra\" CSMA nodes/devices", nCsma);
cmd.AddValue ("verbose", "Tell echo applications to log if true", verbose);
cmd.Parse (argc,argv);
if (verbose)
{
LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO);
LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_INFO);
}
nCsma = nCsma == 0 ? 1 : nCsma;
NodeContainer p2pNodes;
p2pNodes.Create (2);
NodeContainer csmaNodes;
csmaNodes.Add (p2pNodes.Get (1));
csmaNodes.Create (nCsma);
PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
NetDeviceContainer p2pDevices;
p2pDevices = pointToPoint.Install (p2pNodes);
CsmaHelper csma;
csma.SetChannelAttribute ("DataRate", StringValue ("100Mbps"));
csma.SetChannelAttribute ("Delay", TimeValue (NanoSeconds (6560)));
NetDeviceContainer csmaDevices;
csmaDevices = csma.Install (csmaNodes);
InternetStackHelper stack;
stack.Install (p2pNodes.Get (0));
stack.Install (csmaNodes);
Ipv4AddressHelper address;
address.SetBase ("10.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer p2pInterfaces;
p2pInterfaces = address.Assign (p2pDevices);
address.SetBase ("10.1.2.0", "255.255.255.0");
Ipv4InterfaceContainer csmaInterfaces;
csmaInterfaces = address.Assign (csmaDevices);
UdpEchoServerHelper echoServer (9);
ApplicationContainer serverApps = echoServer.Install (csmaNodes.Get (nCsma));
serverApps.Start (Seconds (1.0));
serverApps.Stop (Seconds (10.0));
UdpEchoClientHelper echoClient (csmaInterfaces.GetAddress (nCsma), 9);
echoClient.SetAttribute ("MaxPackets", UintegerValue (1));
echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.)));
echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
ApplicationContainer clientApps = echoClient.Install (p2pNodes.Get (0));
clientApps.Start (Seconds (2.0));
clientApps.Stop (Seconds (10.0));
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
pointToPoint.EnablePcapAll ("second");
csma.EnablePcap ("second", csmaDevices.Get (1), true);
Simulator::Run ();
Simulator::Destroy ();
return 0;
}