author | John Abraham <john.abraham@gatech.edu> |
Thu, 24 May 2012 03:02:51 -0400 | |
changeset 8806 | 089f19e3b412 |
parent 7564 | 642fa0627ba6 |
child 8966 | 060dba23e9bb |
permissions | -rw-r--r-- |
5776 | 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 |
* Author: Josh Pelkey <jpelkey@gatech.edu> |
|
17 |
*/ |
|
18 |
||
19 |
#include <iostream> |
|
20 |
||
21 |
#include "ns3/core-module.h" |
|
6823
a27f86fb4e55
Merge node and common modules into new network module
Tom Henderson <tomh@tomh.org>
parents:
6821
diff
changeset
|
22 |
#include "ns3/network-module.h" |
6848
1f453ad50ef3
Converts csma, emu, tap-bridge, point-to-point, wifi and wimax modules into modular format
Lalith Suresh <suresh.lalith@gmail.com>
parents:
6847
diff
changeset
|
23 |
#include "ns3/internet-module.h" |
1f453ad50ef3
Converts csma, emu, tap-bridge, point-to-point, wifi and wimax modules into modular format
Lalith Suresh <suresh.lalith@gmail.com>
parents:
6847
diff
changeset
|
24 |
#include "ns3/point-to-point-module.h" |
6864 | 25 |
#include "ns3/netanim-module.h" |
6847
138f00c56381
Move applications to a single module
Mitch Watrous <watrous@u.washington.edu>
parents:
6845
diff
changeset
|
26 |
#include "ns3/applications-module.h" |
7089
ebe626d82692
Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
7081
diff
changeset
|
27 |
#include "ns3/point-to-point-layout-module.h" |
5776 | 28 |
|
29 |
using namespace ns3; |
|
30 |
||
31 |
int main (int argc, char *argv[]) |
|
32 |
{ |
|
33 |
Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (512)); |
|
34 |
Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue ("500kb/s")); |
|
35 |
||
36 |
uint32_t xSize = 5; |
|
37 |
uint32_t ySize = 5; |
|
7564
642fa0627ba6
NetAnim: Reduce config verbosity, provide utility for setting position
John Abraham <john.abraham@gatech.edu>
parents:
7529
diff
changeset
|
38 |
std::string animFile = "grid-animation.xml"; |
5776 | 39 |
|
40 |
CommandLine cmd; |
|
41 |
cmd.AddValue ("xSize", "Number of rows of nodes", xSize); |
|
42 |
cmd.AddValue ("ySize", "Number of columns of nodes", ySize); |
|
43 |
cmd.AddValue ("animFile", "File Name for Animation Output", animFile); |
|
44 |
||
45 |
cmd.Parse (argc,argv); |
|
46 |
if (xSize < 1 || ySize < 1 || (xSize < 2 && ySize < 2)) |
|
47 |
{ |
|
48 |
NS_FATAL_ERROR ("Need more nodes for grid."); |
|
49 |
} |
|
7181
7ff8011cf487
net-anim coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7089
diff
changeset
|
50 |
|
5776 | 51 |
PointToPointHelper pointToPoint; |
52 |
pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps")); |
|
53 |
pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms")); |
|
54 |
||
55 |
// Create Grid |
|
56 |
PointToPointGridHelper grid (xSize, ySize, pointToPoint); |
|
57 |
||
58 |
// Install stack on Grid |
|
59 |
InternetStackHelper stack; |
|
60 |
grid.InstallStack (stack); |
|
61 |
||
62 |
// Assign Addresses to Grid |
|
63 |
grid.AssignIpv4Addresses (Ipv4AddressHelper ("10.1.1.0", "255.255.255.0"), |
|
64 |
Ipv4AddressHelper ("10.2.1.0", "255.255.255.0")); |
|
65 |
||
66 |
||
67 |
OnOffHelper clientHelper ("ns3::UdpSocketFactory", Address ()); |
|
68 |
clientHelper.SetAttribute |
|
7252
c8200621e252
rerun check-style.py with uncrustify-0.58
Tom Henderson <tomh@tomh.org>
parents:
7181
diff
changeset
|
69 |
("OnTime", RandomVariableValue (ConstantVariable (1))); |
5776 | 70 |
clientHelper.SetAttribute |
7252
c8200621e252
rerun check-style.py with uncrustify-0.58
Tom Henderson <tomh@tomh.org>
parents:
7181
diff
changeset
|
71 |
("OffTime", RandomVariableValue (ConstantVariable (0))); |
5776 | 72 |
ApplicationContainer clientApps; |
73 |
||
74 |
// Create an on/off app sending packets |
|
75 |
AddressValue remoteAddress (InetSocketAddress (grid.GetIpv4Address (xSize-1,ySize-1), 1000)); |
|
76 |
clientHelper.SetAttribute ("Remote", remoteAddress); |
|
77 |
clientApps.Add (clientHelper.Install (grid.GetNode (0,0))); |
|
78 |
||
79 |
clientApps.Start (Seconds (0.0)); |
|
80 |
clientApps.Stop (Seconds (1.5)); |
|
81 |
||
82 |
// Set the bounding box for animation |
|
7081
9e2c7d8d842f
Bug 1106: Remove CanvasLocation dependencies
John Abraham <john.abraham@gatech.edu>
parents:
6864
diff
changeset
|
83 |
grid.BoundingBox (1, 1, 100, 100); |
5776 | 84 |
|
85 |
// Create the animation object and configure for specified output |
|
7564
642fa0627ba6
NetAnim: Reduce config verbosity, provide utility for setting position
John Abraham <john.abraham@gatech.edu>
parents:
7529
diff
changeset
|
86 |
AnimationInterface anim (animFile); |
7181
7ff8011cf487
net-anim coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7089
diff
changeset
|
87 |
|
5776 | 88 |
// Set up the actual simulation |
89 |
Ipv4GlobalRoutingHelper::PopulateRoutingTables (); |
|
90 |
||
91 |
Simulator::Run (); |
|
92 |
Simulator::Destroy (); |
|
93 |
return 0; |
|
94 |
} |