author | Mitch Watrous |
Mon, 13 Aug 2012 16:08:13 -0700 | |
changeset 8966 | 060dba23e9bb |
parent 8804 | a9de94cf8bfa |
child 10613 | 0a24c30417a9 |
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: George F. Riley<riley@ece.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 nLeftLeaf = 5; |
|
37 |
uint32_t nRightLeaf = 5; |
|
38 |
uint32_t nLeaf = 0; // If non-zero, number of both left and right |
|
7564
642fa0627ba6
NetAnim: Reduce config verbosity, provide utility for setting position
John Abraham <john.abraham@gatech.edu>
parents:
7529
diff
changeset
|
39 |
std::string animFile = "dumbbell-animation.xml" ; // Name of file for animation output |
5776 | 40 |
|
41 |
CommandLine cmd; |
|
42 |
cmd.AddValue ("nLeftLeaf", "Number of left side leaf nodes", nLeftLeaf); |
|
43 |
cmd.AddValue ("nRightLeaf","Number of right side leaf nodes", nRightLeaf); |
|
44 |
cmd.AddValue ("nLeaf", "Number of left and right side leaf nodes", nLeaf); |
|
45 |
cmd.AddValue ("animFile", "File Name for Animation Output", animFile); |
|
46 |
||
47 |
cmd.Parse (argc,argv); |
|
48 |
if (nLeaf > 0) |
|
49 |
{ |
|
50 |
nLeftLeaf = nLeaf; |
|
51 |
nRightLeaf = nLeaf; |
|
52 |
} |
|
7181
7ff8011cf487
net-anim coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7089
diff
changeset
|
53 |
|
5776 | 54 |
// Create the point-to-point link helpers |
55 |
PointToPointHelper pointToPointRouter; |
|
56 |
pointToPointRouter.SetDeviceAttribute ("DataRate", StringValue ("10Mbps")); |
|
57 |
pointToPointRouter.SetChannelAttribute ("Delay", StringValue ("1ms")); |
|
58 |
PointToPointHelper pointToPointLeaf; |
|
59 |
pointToPointLeaf.SetDeviceAttribute ("DataRate", StringValue ("10Mbps")); |
|
60 |
pointToPointLeaf.SetChannelAttribute ("Delay", StringValue ("1ms")); |
|
61 |
||
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
62 |
PointToPointDumbbellHelper d (nLeftLeaf, pointToPointLeaf, |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
63 |
nRightLeaf, pointToPointLeaf, |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
64 |
pointToPointRouter); |
5776 | 65 |
|
66 |
// Install Stack |
|
67 |
InternetStackHelper stack; |
|
68 |
d.InstallStack (stack); |
|
69 |
||
70 |
// Assign IP Addresses |
|
71 |
d.AssignIpv4Addresses (Ipv4AddressHelper ("10.1.1.0", "255.255.255.0"), |
|
7181
7ff8011cf487
net-anim coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7089
diff
changeset
|
72 |
Ipv4AddressHelper ("10.2.1.0", "255.255.255.0"), |
7ff8011cf487
net-anim coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7089
diff
changeset
|
73 |
Ipv4AddressHelper ("10.3.1.0", "255.255.255.0")); |
7ff8011cf487
net-anim coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7089
diff
changeset
|
74 |
|
5776 | 75 |
// Install on/off app on all right side nodes |
76 |
OnOffHelper clientHelper ("ns3::UdpSocketFactory", Address ()); |
|
8966
060dba23e9bb
Replace src/application usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
8804
diff
changeset
|
77 |
clientHelper.SetAttribute ("OnTime", StringValue ("ns3::UniformRandomVariable")); |
060dba23e9bb
Replace src/application usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents:
8804
diff
changeset
|
78 |
clientHelper.SetAttribute ("OffTime", StringValue ("ns3::UniformRandomVariable")); |
5776 | 79 |
ApplicationContainer clientApps; |
80 |
||
81 |
for (uint32_t i = 0; i < d.RightCount (); ++i) |
|
82 |
{ |
|
83 |
// Create an on/off app sending packets to the same leaf right side |
|
84 |
AddressValue remoteAddress (InetSocketAddress (d.GetLeftIpv4Address (i), 1000)); |
|
85 |
clientHelper.SetAttribute ("Remote", remoteAddress); |
|
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7252
diff
changeset
|
86 |
clientApps.Add (clientHelper.Install (d.GetRight (i))); |
5776 | 87 |
} |
88 |
||
89 |
clientApps.Start (Seconds (0.0)); |
|
90 |
clientApps.Stop (Seconds (10.0)); |
|
91 |
||
92 |
// Set the bounding box for animation |
|
7081
9e2c7d8d842f
Bug 1106: Remove CanvasLocation dependencies
John Abraham <john.abraham@gatech.edu>
parents:
6864
diff
changeset
|
93 |
d.BoundingBox (1, 1, 100, 100); |
5776 | 94 |
|
95 |
// 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
|
96 |
AnimationInterface anim (animFile); |
642fa0627ba6
NetAnim: Reduce config verbosity, provide utility for setting position
John Abraham <john.abraham@gatech.edu>
parents:
7529
diff
changeset
|
97 |
|
5776 | 98 |
// Set up the acutal simulation |
99 |
Ipv4GlobalRoutingHelper::PopulateRoutingTables (); |
|
100 |
||
101 |
Simulator::Run (); |
|
8804 | 102 |
std::cout << "Animation Trace file created:" << animFile.c_str ()<< std::endl; |
5776 | 103 |
Simulator::Destroy (); |
104 |
return 0; |
|
105 |
} |