Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* -*- 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/internet-module.h"
- #include "ns3/point-to-point-module.h"
- #include "ns3/point-to-point-layout-module.h"
- #include "ns3/applications-module.h"
- #include "ns3/ndnSIM-module.h"
- using namespace ns3;
- using namespace std;
- NS_LOG_COMPONENT_DEFINE ("Flooding");
- int
- main (int argc, char *argv[])
- {
- CommandLine cmd;
- cmd.Parse (argc, argv);
- Time::SetResolution (Time::NS);
- LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO);
- LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO);
- //NodeContainer nodes;
- //nodes.Create (2);
- // Setting up p2p attributes
- PointToPointHelper p2p;
- p2p.SetDeviceAttribute ("DataRate", StringValue ("1Mbps"));
- p2p.SetChannelAttribute ("Delay", StringValue ("10ms"));
- // Creating 10x10 topology
- PointToPointGridHelper grid (10, 10, p2p);
- grid.BoundingBox(1, 1, 2000, 2000);
- // Installing InternetStackHelper
- InternetStackHelper stack;
- grid.InstallStack (stack);
- // Assign Addresses to Grid
- grid.AssignIpv4Addresses (Ipv4AddressHelper ("10.1.1.0", "255.255.255.0"),
- Ipv4AddressHelper ("10.2.1.0", "255.255.255.0"));
- // Configuring UDP Application Server
- UdpEchoServerHelper echoServer (9);
- ApplicationContainer serverApps = echoServer.Install (grid.GetNode (9,9));
- serverApps.Start (Seconds (1.0));
- serverApps.Stop (Seconds (10.0));
- // Configuring UDP Clients
- UdpEchoClientHelper echoClient (grid.GetIpv4Address(0, 0), 9);
- echoClient.SetAttribute ("MaxPackets", UintegerValue (1));
- echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
- echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
- ApplicationContainer clientApps = echoClient.Install (grid.GetNode (0,0));
- clientApps.Start (Seconds (1.0));
- clientApps.Stop (Seconds (30.0));
- Simulator::Run ();
- Simulator::Destroy ();
- return 0;
- }
Add Comment
Please, Sign In to add comment