author | Kirill Andreev <andreev@iitp.ru> |
Thu, 16 Apr 2009 15:21:09 +0400 | |
changeset 4964 | 9107f67330f3 |
parent 4963 | 869399fad0b6 |
child 4968 | ff5a2162d492 |
permissions | -rw-r--r-- |
4793 | 1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 |
/* |
|
3 |
* Copyright (c) 2008,2009 IITP RAS |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or modify |
|
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
4793 | 7 |
* published by the Free Software Foundation; |
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 |
* |
|
4811
080b8f23fa4a
Added license information to some files.
Andrey Mazo <mazo@iitp.ru>
parents:
4797
diff
changeset
|
18 |
* Author: Kirill Andreev <andreev@iitp.ru> |
4793 | 19 |
*/ |
20 |
||
21 |
||
22 |
#include "ns3/core-module.h" |
|
23 |
#include "ns3/simulator-module.h" |
|
24 |
#include "ns3/node-module.h" |
|
25 |
#include "ns3/helper-module.h" |
|
26 |
#include "ns3/global-routing-module.h" |
|
27 |
#include "ns3/wifi-module.h" |
|
4813
e4e2c44d27cd
All mesh related filed moved to devices/mesh. Let the refactoring begins!
Pavel Boyko <boyko@iitp.ru>
parents:
4812
diff
changeset
|
28 |
#include "ns3/mesh-module.h" |
4793 | 29 |
#include "ns3/mobility-module.h" |
30 |
||
4860
bb5194d57734
New peer management protocol moved to 802.11s/
Pavel Boyko <boyko@iitp.ru>
parents:
4858
diff
changeset
|
31 |
#include "ns3/dot11s-helper.h" |
bb5194d57734
New peer management protocol moved to 802.11s/
Pavel Boyko <boyko@iitp.ru>
parents:
4858
diff
changeset
|
32 |
|
4793 | 33 |
using namespace ns3; |
4872 | 34 |
using namespace dot11s; |
4793 | 35 |
|
36 |
NS_LOG_COMPONENT_DEFINE ("TestMeshScript"); |
|
37 |
||
38 |
int |
|
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4830
diff
changeset
|
39 |
main (int argc, char *argv[]) |
4793 | 40 |
{ |
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
41 |
// Creating square topology with nNodes x nNodes grid |
4962
00ee1735c339
Bugfixes. Changed traversal time, because 4x4 network does not work
Kirill Andreev <andreev@iitp.ru>
parents:
4961
diff
changeset
|
42 |
int xSize = 3; |
00ee1735c339
Bugfixes. Changed traversal time, because 4x4 network does not work
Kirill Andreev <andreev@iitp.ru>
parents:
4961
diff
changeset
|
43 |
int ySize = 3; |
00ee1735c339
Bugfixes. Changed traversal time, because 4x4 network does not work
Kirill Andreev <andreev@iitp.ru>
parents:
4961
diff
changeset
|
44 |
double step = 100.0; |
00ee1735c339
Bugfixes. Changed traversal time, because 4x4 network does not work
Kirill Andreev <andreev@iitp.ru>
parents:
4961
diff
changeset
|
45 |
double randomStart = 0.1; |
00ee1735c339
Bugfixes. Changed traversal time, because 4x4 network does not work
Kirill Andreev <andreev@iitp.ru>
parents:
4961
diff
changeset
|
46 |
double totalTime = 100.0; |
00ee1735c339
Bugfixes. Changed traversal time, because 4x4 network does not work
Kirill Andreev <andreev@iitp.ru>
parents:
4961
diff
changeset
|
47 |
double packetInterval = 0.001; |
00ee1735c339
Bugfixes. Changed traversal time, because 4x4 network does not work
Kirill Andreev <andreev@iitp.ru>
parents:
4961
diff
changeset
|
48 |
uint16_t packetSize = 1024; |
00ee1735c339
Bugfixes. Changed traversal time, because 4x4 network does not work
Kirill Andreev <andreev@iitp.ru>
parents:
4961
diff
changeset
|
49 |
uint32_t nIfaces = 2; |
00ee1735c339
Bugfixes. Changed traversal time, because 4x4 network does not work
Kirill Andreev <andreev@iitp.ru>
parents:
4961
diff
changeset
|
50 |
bool chan = true; |
00ee1735c339
Bugfixes. Changed traversal time, because 4x4 network does not work
Kirill Andreev <andreev@iitp.ru>
parents:
4961
diff
changeset
|
51 |
bool pcap = false; |
4963
869399fad0b6
Fixed proactive mode. 1 root works
Kirill Andreev <andreev@iitp.ru>
parents:
4962
diff
changeset
|
52 |
uint64_t seed =1; |
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
53 |
|
4930
fa5e570d56fa
Mesh test refactored, see --pcap and --interfaces command line arguments
Pavel Boyko <boyko@iitp.ru>
parents:
4929
diff
changeset
|
54 |
// Command line arguments |
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
55 |
CommandLine cmd; |
4930
fa5e570d56fa
Mesh test refactored, see --pcap and --interfaces command line arguments
Pavel Boyko <boyko@iitp.ru>
parents:
4929
diff
changeset
|
56 |
cmd.AddValue ("x-size", "Number of nodes in a row grid. [6]", xSize); |
fa5e570d56fa
Mesh test refactored, see --pcap and --interfaces command line arguments
Pavel Boyko <boyko@iitp.ru>
parents:
4929
diff
changeset
|
57 |
cmd.AddValue ("y-size", "Number of rows in a grid. [6]", ySize); |
fa5e570d56fa
Mesh test refactored, see --pcap and --interfaces command line arguments
Pavel Boyko <boyko@iitp.ru>
parents:
4929
diff
changeset
|
58 |
cmd.AddValue ("step", "Size of edge in our grid, meters. [100 m]", step); |
fa5e570d56fa
Mesh test refactored, see --pcap and --interfaces command line arguments
Pavel Boyko <boyko@iitp.ru>
parents:
4929
diff
changeset
|
59 |
cmd.AddValue ("start", "Maximum random start delay, seconds. [0.1 s]", randomStart); |
4962
00ee1735c339
Bugfixes. Changed traversal time, because 4x4 network does not work
Kirill Andreev <andreev@iitp.ru>
parents:
4961
diff
changeset
|
60 |
cmd.AddValue ("time", "Simulation time", totalTime); |
00ee1735c339
Bugfixes. Changed traversal time, because 4x4 network does not work
Kirill Andreev <andreev@iitp.ru>
parents:
4961
diff
changeset
|
61 |
cmd.AddValue ("packetInterval", "Interval between packets", packetInterval); |
00ee1735c339
Bugfixes. Changed traversal time, because 4x4 network does not work
Kirill Andreev <andreev@iitp.ru>
parents:
4961
diff
changeset
|
62 |
cmd.AddValue ("packetSize", "Size of packets", packetSize); |
4930
fa5e570d56fa
Mesh test refactored, see --pcap and --interfaces command line arguments
Pavel Boyko <boyko@iitp.ru>
parents:
4929
diff
changeset
|
63 |
cmd.AddValue ("interfaces", "Number of radio interfaces used by each mesh point. [1]", nIfaces); |
4937
7211ebc93e69
Add spread interfaces frequency channels option
Pavel Boyko <boyko@iitp.ru>
parents:
4933
diff
changeset
|
64 |
cmd.AddValue ("channels", "Use different frequency channels for different interfaces. [0]", chan); |
4930
fa5e570d56fa
Mesh test refactored, see --pcap and --interfaces command line arguments
Pavel Boyko <boyko@iitp.ru>
parents:
4929
diff
changeset
|
65 |
cmd.AddValue ("pcap", "Enable PCAP traces on interfaces. [0]", pcap); |
4963
869399fad0b6
Fixed proactive mode. 1 root works
Kirill Andreev <andreev@iitp.ru>
parents:
4962
diff
changeset
|
66 |
cmd.AddValue ("seed", "Seed value", seed); |
4930
fa5e570d56fa
Mesh test refactored, see --pcap and --interfaces command line arguments
Pavel Boyko <boyko@iitp.ru>
parents:
4929
diff
changeset
|
67 |
|
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
68 |
cmd.Parse (argc, argv); |
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
69 |
NS_LOG_DEBUG ("Grid:" << xSize << "*" << ySize); |
4963
869399fad0b6
Fixed proactive mode. 1 root works
Kirill Andreev <andreev@iitp.ru>
parents:
4962
diff
changeset
|
70 |
SeedManager::SetSeed(seed); |
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
71 |
// Creating nodes |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
72 |
NodeContainer nodes; |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
73 |
nodes.Create (ySize*xSize); |
4793 | 74 |
|
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
75 |
// Setting channel |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
76 |
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
77 |
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
78 |
wifiPhy.SetChannel (wifiChannel.Create ()); |
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
79 |
|
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
80 |
// Install mesh point devices & protocols |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
81 |
MeshWifiHelper mesh; |
4937
7211ebc93e69
Add spread interfaces frequency channels option
Pavel Boyko <boyko@iitp.ru>
parents:
4933
diff
changeset
|
82 |
mesh.SetSpreadInterfaceChannels (chan); |
4963
869399fad0b6
Fixed proactive mode. 1 root works
Kirill Andreev <andreev@iitp.ru>
parents:
4962
diff
changeset
|
83 |
std::vector<uint32_t> roots; |
869399fad0b6
Fixed proactive mode. 1 root works
Kirill Andreev <andreev@iitp.ru>
parents:
4962
diff
changeset
|
84 |
//roots.push_back(xSize-1); |
4964 | 85 |
//roots.push_back(xSize*ySize-xSize); |
4963
869399fad0b6
Fixed proactive mode. 1 root works
Kirill Andreev <andreev@iitp.ru>
parents:
4962
diff
changeset
|
86 |
NetDeviceContainer meshDevices = mesh.Install (wifiPhy, nodes, roots, nIfaces); |
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
87 |
|
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
88 |
// Setup mobility |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
89 |
MobilityHelper mobility; |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
90 |
mobility.SetPositionAllocator ("ns3::GridPositionAllocator", |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
91 |
"MinX", DoubleValue (0.0), |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
92 |
"MinY", DoubleValue (0.0), |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
93 |
"DeltaX", DoubleValue (step), |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
94 |
"DeltaY", DoubleValue (step), |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
95 |
"GridWidth", UintegerValue (xSize), |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4830
diff
changeset
|
96 |
"LayoutType", StringValue ("RowFirst")); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
97 |
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
98 |
mobility.Install (nodes); |
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
99 |
|
4877
f08902c42733
Added a method to find peer link, code cleanup
Kirill Andreev <andreev@iitp.ru>
parents:
4876
diff
changeset
|
100 |
NS_LOG_UNCOND("start"); |
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
101 |
|
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
102 |
// Install internet stack |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
103 |
InternetStackHelper stack; |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4830
diff
changeset
|
104 |
stack.Install (nodes); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
105 |
Ipv4AddressHelper address; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
106 |
address.SetBase ("10.1.1.0", "255.255.255.0"); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
107 |
Ipv4InterfaceContainer interfaces = address.Assign (meshDevices); |
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
108 |
|
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
109 |
// Install applications |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
110 |
UdpEchoServerHelper echoServer (9); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
111 |
ApplicationContainer serverApps = echoServer.Install (nodes.Get (0)); |
4964 | 112 |
serverApps.Start (Seconds (0.0)); |
4962
00ee1735c339
Bugfixes. Changed traversal time, because 4x4 network does not work
Kirill Andreev <andreev@iitp.ru>
parents:
4961
diff
changeset
|
113 |
serverApps.Stop (Seconds (totalTime)); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
114 |
UdpEchoClientHelper echoClient (interfaces.GetAddress (0), 9); |
4962
00ee1735c339
Bugfixes. Changed traversal time, because 4x4 network does not work
Kirill Andreev <andreev@iitp.ru>
parents:
4961
diff
changeset
|
115 |
echoClient.SetAttribute ("MaxPackets", UintegerValue ((uint32_t)(totalTime*(1/packetInterval)))); |
00ee1735c339
Bugfixes. Changed traversal time, because 4x4 network does not work
Kirill Andreev <andreev@iitp.ru>
parents:
4961
diff
changeset
|
116 |
echoClient.SetAttribute ("Interval", TimeValue (Seconds (packetInterval))); |
00ee1735c339
Bugfixes. Changed traversal time, because 4x4 network does not work
Kirill Andreev <andreev@iitp.ru>
parents:
4961
diff
changeset
|
117 |
echoClient.SetAttribute ("PacketSize", UintegerValue (packetSize)); |
4961
62ff08884f5e
Fixed bug pith routing information collected from PREP
Kirill Andreev <andreev@iitp.ru>
parents:
4947
diff
changeset
|
118 |
ApplicationContainer clientApps = echoClient.Install (nodes.Get (xSize*ySize-1)); |
4964 | 119 |
clientApps.Start (Seconds (0.0)); |
4962
00ee1735c339
Bugfixes. Changed traversal time, because 4x4 network does not work
Kirill Andreev <andreev@iitp.ru>
parents:
4961
diff
changeset
|
120 |
clientApps.Stop (Seconds (totalTime)); |
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
121 |
|
4930
fa5e570d56fa
Mesh test refactored, see --pcap and --interfaces command line arguments
Pavel Boyko <boyko@iitp.ru>
parents:
4929
diff
changeset
|
122 |
// Enable PCAP trace |
fa5e570d56fa
Mesh test refactored, see --pcap and --interfaces command line arguments
Pavel Boyko <boyko@iitp.ru>
parents:
4929
diff
changeset
|
123 |
if (pcap) |
fa5e570d56fa
Mesh test refactored, see --pcap and --interfaces command line arguments
Pavel Boyko <boyko@iitp.ru>
parents:
4929
diff
changeset
|
124 |
wifiPhy.EnablePcapAll (std::string ("mp-") + mesh.GetSsid ().PeekString ()); |
fa5e570d56fa
Mesh test refactored, see --pcap and --interfaces command line arguments
Pavel Boyko <boyko@iitp.ru>
parents:
4929
diff
changeset
|
125 |
|
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
126 |
// Happy end |
4962
00ee1735c339
Bugfixes. Changed traversal time, because 4x4 network does not work
Kirill Andreev <andreev@iitp.ru>
parents:
4961
diff
changeset
|
127 |
Simulator::Stop (Seconds (totalTime)); |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4830
diff
changeset
|
128 |
Simulator::Run (); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4830
diff
changeset
|
129 |
Simulator::Destroy (); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
130 |
return 0; |
4793 | 131 |
} |