Guest User

Untitled

a guest
Nov 17th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
  2. /*
  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;
  6. *
  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.
  11. *
  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
  15. */
  16.  
  17. #include "ns3/core-module.h"
  18. #include "ns3/network-module.h"
  19. #include "ns3/internet-module.h"
  20. #include "ns3/point-to-point-module.h"
  21. #include "ns3/point-to-point-layout-module.h"
  22. #include "ns3/applications-module.h"
  23. #include "ns3/ndnSIM-module.h"
  24.  
  25. using namespace ns3;
  26. using namespace std;
  27.  
  28. NS_LOG_COMPONENT_DEFINE ("Flooding");
  29.  
  30. int
  31. main (int argc, char *argv[])
  32. {
  33. CommandLine cmd;
  34. cmd.Parse (argc, argv);
  35.  
  36. Time::SetResolution (Time::NS);
  37. LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO);
  38. LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO);
  39.  
  40. //NodeContainer nodes;
  41. //nodes.Create (2);
  42.  
  43. // Setting up p2p attributes
  44. PointToPointHelper p2p;
  45. p2p.SetDeviceAttribute ("DataRate", StringValue ("1Mbps"));
  46. p2p.SetChannelAttribute ("Delay", StringValue ("10ms"));
  47.  
  48. // Creating 10x10 topology
  49. PointToPointGridHelper grid (10, 10, p2p);
  50. grid.BoundingBox(1, 1, 2000, 2000);
  51.  
  52. // Installing InternetStackHelper
  53. InternetStackHelper stack;
  54. grid.InstallStack (stack);
  55.  
  56. // Assign Addresses to Grid
  57. grid.AssignIpv4Addresses (Ipv4AddressHelper ("10.1.1.0", "255.255.255.0"),
  58. Ipv4AddressHelper ("10.2.1.0", "255.255.255.0"));
  59.  
  60. // Configuring UDP Application Server
  61. UdpEchoServerHelper echoServer (9);
  62. ApplicationContainer serverApps = echoServer.Install (grid.GetNode (9,9));
  63. serverApps.Start (Seconds (1.0));
  64. serverApps.Stop (Seconds (10.0));
  65.  
  66. // Configuring UDP Clients
  67. UdpEchoClientHelper echoClient (grid.GetIpv4Address(0, 0), 9);
  68. echoClient.SetAttribute ("MaxPackets", UintegerValue (1));
  69. echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
  70. echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
  71.  
  72. ApplicationContainer clientApps = echoClient.Install (grid.GetNode (0,0));
  73. clientApps.Start (Seconds (1.0));
  74. clientApps.Stop (Seconds (30.0));
  75.  
  76. Simulator::Run ();
  77. Simulator::Destroy ();
  78. return 0;
  79. }
Add Comment
Please, Sign In to add comment