1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 as
5 * published by the Free Software Foundation;
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 #include "ns3/core-module.h"
18 #include "ns3/simulator-module.h"
19 #include "ns3/node-module.h"
20 #include "ns3/helper-module.h"
24 NS_LOG_COMPONENT_DEFINE ("FirstScriptExample");
27 main (int argc, char *argv[])
29 LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO);
30 LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_INFO);
35 PointToPointHelper pointToPoint;
36 pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
37 pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
39 NetDeviceContainer devices;
40 devices = pointToPoint.Install (nodes);
42 InternetStackHelper stack;
43 stack.Install (nodes);
45 Ipv4AddressHelper address;
46 address.SetBase ("10.1.1.0", "255.255.255.0");
48 Ipv4InterfaceContainer interfaces = address.Assign (devices);
50 UdpEchoServerHelper echoServer (9);
52 ApplicationContainer serverApps = echoServer.Install (nodes.Get (1));
53 serverApps.Start (Seconds (1.0));
54 serverApps.Stop (Seconds (10.0));
56 UdpEchoClientHelper echoClient (interfaces.GetAddress (1), 9);
57 echoClient.SetAttribute ("MaxPackets", UintegerValue (2));
58 echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.)));
59 echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
61 ApplicationContainer clientApps = echoClient.Install (nodes.Get (0));
62 clientApps.Start (Seconds (2.0));
63 clientApps.Stop (Seconds (10.0));
65 PointToPointHelper::EnablePcapAll ("netfilter");
68 Simulator::Destroy ();