author | Kirill Andreev <andreev@iitp.ru> |
Mon, 03 Aug 2009 19:22:42 +0400 | |
changeset 5146 | 9e0edb76a8c7 |
parent 5145 | 7f50ab7ce59d |
child 5152 | f14eff131d13 |
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" |
5087 | 30 |
#include "ns3/mesh-helper.h" |
5057
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
5056
diff
changeset
|
31 |
#include "ns3/mesh-interface-helper.h" |
4793 | 32 |
|
5011
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
33 |
#include <iostream> |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
34 |
#include <sstream> |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
35 |
#include <fstream> |
4860
bb5194d57734
New peer management protocol moved to 802.11s/
Pavel Boyko <boyko@iitp.ru>
parents:
4858
diff
changeset
|
36 |
|
4793 | 37 |
using namespace ns3; |
38 |
||
39 |
NS_LOG_COMPONENT_DEFINE ("TestMeshScript"); |
|
5011
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
40 |
class MeshTest |
4793 | 41 |
{ |
5011
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
42 |
public: |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
43 |
/// Init test |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
44 |
MeshTest (); |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
45 |
/// Configure test from command line arguments |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
46 |
void Configure (int argc, char ** argv); |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
47 |
/// Run test |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
48 |
int Run (); |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
49 |
private: |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
50 |
int xSize; |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
51 |
int ySize; |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
52 |
double step; |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
53 |
double randomStart; |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
54 |
double totalTime; |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
55 |
double packetInterval; |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
56 |
uint16_t packetSize; |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
57 |
uint32_t nIfaces; |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
58 |
bool chan; |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
59 |
bool pcap; |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
60 |
uint64_t seed; |
5081 | 61 |
std::string stack; |
5141
22e79c2a4c5f
Added root mesh point as argument of command line
Kirill Andreev <andreev@iitp.ru>
parents:
5087
diff
changeset
|
62 |
std::string root; |
5011
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
63 |
/// List of network nodes |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
64 |
NodeContainer nodes; |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
65 |
/// List of all mesh point devices |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
66 |
NetDeviceContainer meshDevices; |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
67 |
//Addresses of interfaces: |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
68 |
Ipv4InterfaceContainer interfaces; |
5086
fccfd0073ea3
Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents:
5081
diff
changeset
|
69 |
// MeshHelper. Report is not static methods |
fccfd0073ea3
Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents:
5081
diff
changeset
|
70 |
MeshHelper mesh; |
5011
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
71 |
private: |
5063 | 72 |
/// Create nodes and setup their mobility |
5011
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
73 |
void CreateNodes (); |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
74 |
/// Install internet stack on nodes |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
75 |
void InstallInternetStack (); |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
76 |
/// Install applications |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
77 |
void InstallApplication (); |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
78 |
/// Print mesh devices diagnostics |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
79 |
void Report (); |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
80 |
}; |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
81 |
MeshTest::MeshTest () : |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
82 |
xSize (3), |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
83 |
ySize (3), |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
84 |
step (100.0), |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
85 |
randomStart (0.1), |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
86 |
totalTime (100.0), |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
87 |
packetInterval (0.1), |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
88 |
packetSize (1024), |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
89 |
nIfaces (1), |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
90 |
chan (true), |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
91 |
pcap (false), |
5081 | 92 |
seed (1), |
5141
22e79c2a4c5f
Added root mesh point as argument of command line
Kirill Andreev <andreev@iitp.ru>
parents:
5087
diff
changeset
|
93 |
stack ("ns3::Dot11sStack"), |
22e79c2a4c5f
Added root mesh point as argument of command line
Kirill Andreev <andreev@iitp.ru>
parents:
5087
diff
changeset
|
94 |
root ("ff:ff:ff:ff:ff:ff") |
5011
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
95 |
{ |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
96 |
} |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
97 |
void |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
98 |
MeshTest::Configure (int argc, char *argv[]) |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
99 |
{ |
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
100 |
CommandLine cmd; |
4930
fa5e570d56fa
Mesh test refactored, see --pcap and --interfaces command line arguments
Pavel Boyko <boyko@iitp.ru>
parents:
4929
diff
changeset
|
101 |
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
|
102 |
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
|
103 |
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
|
104 |
cmd.AddValue ("start", "Maximum random start delay, seconds. [0.1 s]", randomStart); |
4968
ff5a2162d492
MulthopAction -> Action management frames in 802.11s according to std
Pavel Boyko <boyko@iitp.ru>
parents:
4964
diff
changeset
|
105 |
cmd.AddValue ("time", "Simulation time, seconds [100 s]", totalTime); |
ff5a2162d492
MulthopAction -> Action management frames in 802.11s according to std
Pavel Boyko <boyko@iitp.ru>
parents:
4964
diff
changeset
|
106 |
cmd.AddValue ("packet-interval", "Interval between packets, seconds [0.001 s]", packetInterval); |
ff5a2162d492
MulthopAction -> Action management frames in 802.11s according to std
Pavel Boyko <boyko@iitp.ru>
parents:
4964
diff
changeset
|
107 |
cmd.AddValue ("packet-size", "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
|
108 |
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
|
109 |
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
|
110 |
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
|
111 |
cmd.AddValue ("seed", "Seed value", seed); |
5081 | 112 |
cmd.AddValue ("stack", "Type of protocol stack. ns3::Dot11sStack by default", stack); |
5141
22e79c2a4c5f
Added root mesh point as argument of command line
Kirill Andreev <andreev@iitp.ru>
parents:
5087
diff
changeset
|
113 |
cmd.AddValue ("root", "Mac address of root mesh point", root); |
4930
fa5e570d56fa
Mesh test refactored, see --pcap and --interfaces command line arguments
Pavel Boyko <boyko@iitp.ru>
parents:
4929
diff
changeset
|
114 |
|
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
115 |
cmd.Parse (argc, argv); |
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
116 |
NS_LOG_DEBUG ("Grid:" << xSize << "*" << ySize); |
4968
ff5a2162d492
MulthopAction -> Action management frames in 802.11s according to std
Pavel Boyko <boyko@iitp.ru>
parents:
4964
diff
changeset
|
117 |
NS_LOG_DEBUG ("Simulation time: " << totalTime << " s"); |
4963
869399fad0b6
Fixed proactive mode. 1 root works
Kirill Andreev <andreev@iitp.ru>
parents:
4962
diff
changeset
|
118 |
SeedManager::SetSeed(seed); |
5011
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
119 |
} |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
120 |
void |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
121 |
MeshTest::CreateNodes () |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
122 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
123 |
nodes.Create (ySize*xSize); |
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
124 |
// Setting channel |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
125 |
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
126 |
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
127 |
wifiPhy.SetChannel (wifiChannel.Create ()); |
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
128 |
// Install mesh point devices & protocols |
5141
22e79c2a4c5f
Added root mesh point as argument of command line
Kirill Andreev <andreev@iitp.ru>
parents:
5087
diff
changeset
|
129 |
mesh.SetStackInstaller (stack, "Root", Mac48AddressValue (Mac48Address (root.c_str ()))); |
4937
7211ebc93e69
Add spread interfaces frequency channels option
Pavel Boyko <boyko@iitp.ru>
parents:
4933
diff
changeset
|
130 |
mesh.SetSpreadInterfaceChannels (chan); |
5054 | 131 |
MeshInterfaceHelper interface = MeshInterfaceHelper::Default (); |
132 |
interface.SetType ("RandomStart", TimeValue (Seconds(randomStart))); |
|
133 |
||
5081 | 134 |
meshDevices = mesh.Install (wifiPhy, interface, nodes, nIfaces); |
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
135 |
// Setup mobility |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
136 |
MobilityHelper mobility; |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
137 |
mobility.SetPositionAllocator ("ns3::GridPositionAllocator", |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
138 |
"MinX", DoubleValue (0.0), |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
139 |
"MinY", DoubleValue (0.0), |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
140 |
"DeltaX", DoubleValue (step), |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
141 |
"DeltaY", DoubleValue (step), |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
142 |
"GridWidth", UintegerValue (xSize), |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4830
diff
changeset
|
143 |
"LayoutType", StringValue ("RowFirst")); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
144 |
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
145 |
mobility.Install (nodes); |
5011
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
146 |
if (pcap) |
5020
79e8178d69eb
Mesh ID is made separately from SSID
Kirill Andreev <andreev@iitp.ru>
parents:
5011
diff
changeset
|
147 |
wifiPhy.EnablePcapAll (std::string ("mp-")); |
5011
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
148 |
} |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
149 |
void |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
150 |
MeshTest::InstallInternetStack () |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
151 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
152 |
InternetStackHelper stack; |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4830
diff
changeset
|
153 |
stack.Install (nodes); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
154 |
Ipv4AddressHelper address; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
155 |
address.SetBase ("10.1.1.0", "255.255.255.0"); |
5011
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
156 |
interfaces = address.Assign (meshDevices); |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
157 |
} |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
158 |
void |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
159 |
MeshTest::InstallApplication () |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
160 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
161 |
UdpEchoServerHelper echoServer (9); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
162 |
ApplicationContainer serverApps = echoServer.Install (nodes.Get (0)); |
4964 | 163 |
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
|
164 |
serverApps.Stop (Seconds (totalTime)); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
165 |
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
|
166 |
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
|
167 |
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
|
168 |
echoClient.SetAttribute ("PacketSize", UintegerValue (packetSize)); |
4961
62ff08884f5e
Fixed bug pith routing information collected from PREP
Kirill Andreev <andreev@iitp.ru>
parents:
4947
diff
changeset
|
169 |
ApplicationContainer clientApps = echoClient.Install (nodes.Get (xSize*ySize-1)); |
4964 | 170 |
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
|
171 |
clientApps.Stop (Seconds (totalTime)); |
5011
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
172 |
} |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
173 |
int |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
174 |
MeshTest::Run () |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
175 |
{ |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
176 |
CreateNodes (); |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
177 |
InstallInternetStack (); |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
178 |
InstallApplication (); |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
179 |
Simulator::Schedule (Seconds(totalTime), & MeshTest::Report, this); |
4962
00ee1735c339
Bugfixes. Changed traversal time, because 4x4 network does not work
Kirill Andreev <andreev@iitp.ru>
parents:
4961
diff
changeset
|
180 |
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
|
181 |
Simulator::Run (); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4830
diff
changeset
|
182 |
Simulator::Destroy (); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
183 |
return 0; |
4793 | 184 |
} |
5011
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
185 |
void |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
186 |
MeshTest::Report () |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
187 |
{ |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
188 |
NS_LOG_UNCOND("Report is here:"); |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
189 |
unsigned n (0); |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
190 |
for (NetDeviceContainer::Iterator i = meshDevices.Begin (); i != meshDevices.End (); ++i, ++n) |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
191 |
{ |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
192 |
std::ostringstream os; |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
193 |
os << "mp-report-" << n << ".xml"; |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
194 |
std::cerr << "Printing mesh point device #" << n << " diagnostics to " << os.str () << "\n"; |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
195 |
std::ofstream of; |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
196 |
of.open (os.str().c_str()); |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
197 |
if (! of.is_open ()) |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
198 |
{ |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
199 |
std::cerr << "Error: Can't open file " << os.str() << "\n"; |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
200 |
return; |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
201 |
} |
5081 | 202 |
mesh.Report (*i, of); |
5011
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
203 |
of.close (); |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
204 |
} |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
205 |
} |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
206 |
int |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
207 |
main (int argc, char *argv[]) |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
208 |
{ |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
209 |
MeshTest t; |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
210 |
t.Configure (argc, argv); |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
211 |
return t.Run(); |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
212 |
} |