author | Tom Henderson <tomh@tomh.org> |
Fri, 20 Aug 2010 12:17:19 -0700 | |
changeset 6589 | 9c325569fb01 |
parent 5464 | 050630fcf15e |
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> |
5181
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
19 |
* |
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
20 |
* |
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
21 |
* By default this script creates m_xSize * m_ySize square grid topology with |
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
22 |
* IEEE802.11s stack installed at each node with peering management |
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
23 |
* and HWMP protocol. |
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
24 |
* The side of the square cell is defined by m_step parameter. |
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
25 |
* When topology is created, UDP ping is installed to opposite corners |
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
26 |
* by diagonals. packet size of the UDP ping and interval between two |
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
27 |
* successive packets is configurable. |
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
28 |
* |
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
29 |
* m_xSize * step |
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
30 |
* |<--------->| |
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
31 |
* step |
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
32 |
* |<--->| |
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
33 |
* * --- * --- * <---Ping sink _ |
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
34 |
* | \ | / | ^ |
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
35 |
* | \ | / | | |
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
36 |
* * --- * --- * m_ySize * step | |
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
37 |
* | / | \ | | |
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
38 |
* | / | \ | | |
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
39 |
* * --- * --- * _ |
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
40 |
* ^ Ping source |
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
41 |
* |
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
42 |
* See also MeshTest::Configure to read more about configurable |
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
43 |
* parameters. |
4793 | 44 |
*/ |
45 |
||
46 |
||
47 |
#include "ns3/core-module.h" |
|
48 |
#include "ns3/simulator-module.h" |
|
49 |
#include "ns3/node-module.h" |
|
50 |
#include "ns3/helper-module.h" |
|
51 |
#include "ns3/global-routing-module.h" |
|
52 |
#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
|
53 |
#include "ns3/mesh-module.h" |
4793 | 54 |
#include "ns3/mobility-module.h" |
5087 | 55 |
#include "ns3/mesh-helper.h" |
4793 | 56 |
|
5011
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
57 |
#include <iostream> |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
58 |
#include <sstream> |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
59 |
#include <fstream> |
4860
bb5194d57734
New peer management protocol moved to 802.11s/
Pavel Boyko <boyko@iitp.ru>
parents:
4858
diff
changeset
|
60 |
|
4793 | 61 |
using namespace ns3; |
62 |
||
63 |
NS_LOG_COMPONENT_DEFINE ("TestMeshScript"); |
|
5011
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
64 |
class MeshTest |
4793 | 65 |
{ |
5011
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
66 |
public: |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
67 |
/// Init test |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
68 |
MeshTest (); |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
69 |
/// Configure test from command line arguments |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
70 |
void Configure (int argc, char ** argv); |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
71 |
/// Run test |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
72 |
int Run (); |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
73 |
private: |
5156 | 74 |
int m_xSize; |
75 |
int m_ySize; |
|
76 |
double m_step; |
|
77 |
double m_randomStart; |
|
78 |
double m_totalTime; |
|
79 |
double m_packetInterval; |
|
80 |
uint16_t m_packetSize; |
|
81 |
uint32_t m_nIfaces; |
|
82 |
bool m_chan; |
|
83 |
bool m_pcap; |
|
84 |
std::string m_stack; |
|
85 |
std::string m_root; |
|
5011
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
86 |
/// List of network nodes |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
87 |
NodeContainer nodes; |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
88 |
/// List of all mesh point devices |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
89 |
NetDeviceContainer meshDevices; |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
90 |
//Addresses of interfaces: |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
91 |
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
|
92 |
// 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
|
93 |
MeshHelper mesh; |
5011
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
94 |
private: |
5063 | 95 |
/// Create nodes and setup their mobility |
5011
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
96 |
void CreateNodes (); |
5156 | 97 |
/// Install internet m_stack on nodes |
5011
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
98 |
void InstallInternetStack (); |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
99 |
/// Install applications |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
100 |
void InstallApplication (); |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
101 |
/// Print mesh devices diagnostics |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
102 |
void Report (); |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
103 |
}; |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
104 |
MeshTest::MeshTest () : |
5156 | 105 |
m_xSize (3), |
106 |
m_ySize (3), |
|
107 |
m_step (100.0), |
|
108 |
m_randomStart (0.1), |
|
109 |
m_totalTime (100.0), |
|
110 |
m_packetInterval (0.1), |
|
111 |
m_packetSize (1024), |
|
112 |
m_nIfaces (1), |
|
113 |
m_chan (true), |
|
114 |
m_pcap (false), |
|
115 |
m_stack ("ns3::Dot11sStack"), |
|
116 |
m_root ("ff:ff:ff:ff:ff:ff") |
|
5011
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
117 |
{ |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
118 |
} |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
119 |
void |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
120 |
MeshTest::Configure (int argc, char *argv[]) |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
121 |
{ |
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
122 |
CommandLine cmd; |
5156 | 123 |
cmd.AddValue ("x-size", "Number of nodes in a row grid. [6]", m_xSize); |
124 |
cmd.AddValue ("y-size", "Number of rows in a grid. [6]", m_ySize); |
|
5181
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
125 |
cmd.AddValue ("step", "Size of edge in our grid, meters. [100 m]", m_step); |
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
126 |
/* |
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
127 |
* As soon as starting node means that it sends a beacon, |
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
128 |
* simultaneous start is not good. |
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
129 |
*/ |
5156 | 130 |
cmd.AddValue ("start", "Maximum random start delay, seconds. [0.1 s]", m_randomStart); |
131 |
cmd.AddValue ("time", "Simulation time, seconds [100 s]", m_totalTime); |
|
5181
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
132 |
cmd.AddValue ("packet-interval", "Interval between packets in UDP ping, seconds [0.001 s]", m_packetInterval); |
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
133 |
cmd.AddValue ("packet-size", "Size of packets in UDP ping", m_packetSize); |
5156 | 134 |
cmd.AddValue ("interfaces", "Number of radio interfaces used by each mesh point. [1]", m_nIfaces); |
5181
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
135 |
cmd.AddValue ("channels", "Use different frequency channels for different interfaces. [0]", m_chan); |
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
136 |
cmd.AddValue ("pcap", "Enable PCAP traces on interfaces. [0]", m_pcap); |
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
137 |
cmd.AddValue ("stack", "Type of protocol stack. ns3::Dot11sStack by default", m_stack); |
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
138 |
cmd.AddValue ("root", "Mac address of root mesh point in HWMP", m_root); |
4930
fa5e570d56fa
Mesh test refactored, see --pcap and --interfaces command line arguments
Pavel Boyko <boyko@iitp.ru>
parents:
4929
diff
changeset
|
139 |
|
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
140 |
cmd.Parse (argc, argv); |
5156 | 141 |
NS_LOG_DEBUG ("Grid:" << m_xSize << "*" << m_ySize); |
142 |
NS_LOG_DEBUG ("Simulation time: " << m_totalTime << " s"); |
|
5011
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
143 |
} |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
144 |
void |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
145 |
MeshTest::CreateNodes () |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
146 |
{ |
5181
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
147 |
/* |
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
148 |
* Create m_ySize*m_xSize stations to form a grid topology |
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
149 |
*/ |
5156 | 150 |
nodes.Create (m_ySize*m_xSize); |
5181
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
151 |
// Configure YansWifiChannel |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
152 |
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
153 |
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
154 |
wifiPhy.SetChannel (wifiChannel.Create ()); |
5181
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
155 |
/* |
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
156 |
* Create mesh helper and set stack installer to it |
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
157 |
* Stack installer creates all needed protocols and install them to |
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
158 |
* mesh point device |
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
159 |
*/ |
5164
b81ab8394a61
Restructured helper - removed MeshInterfaceHelper
Kirill Andreev <andreev@iitp.ru>
parents:
5163
diff
changeset
|
160 |
mesh = MeshHelper::Default (); |
5464
050630fcf15e
Mesh: fixed FLAME PATH_UPDATE procedure, fixed mesh.cc, valgrind errors in
Kirill Andreev <andreev@iitp.ru>
parents:
5369
diff
changeset
|
161 |
if (!Mac48Address (m_root.c_str ()).IsBroadcast ()) |
050630fcf15e
Mesh: fixed FLAME PATH_UPDATE procedure, fixed mesh.cc, valgrind errors in
Kirill Andreev <andreev@iitp.ru>
parents:
5369
diff
changeset
|
162 |
{ |
050630fcf15e
Mesh: fixed FLAME PATH_UPDATE procedure, fixed mesh.cc, valgrind errors in
Kirill Andreev <andreev@iitp.ru>
parents:
5369
diff
changeset
|
163 |
mesh.SetStackInstaller (m_stack, "Root", Mac48AddressValue (Mac48Address (m_root.c_str ()))); |
050630fcf15e
Mesh: fixed FLAME PATH_UPDATE procedure, fixed mesh.cc, valgrind errors in
Kirill Andreev <andreev@iitp.ru>
parents:
5369
diff
changeset
|
164 |
} |
050630fcf15e
Mesh: fixed FLAME PATH_UPDATE procedure, fixed mesh.cc, valgrind errors in
Kirill Andreev <andreev@iitp.ru>
parents:
5369
diff
changeset
|
165 |
else |
050630fcf15e
Mesh: fixed FLAME PATH_UPDATE procedure, fixed mesh.cc, valgrind errors in
Kirill Andreev <andreev@iitp.ru>
parents:
5369
diff
changeset
|
166 |
{ |
050630fcf15e
Mesh: fixed FLAME PATH_UPDATE procedure, fixed mesh.cc, valgrind errors in
Kirill Andreev <andreev@iitp.ru>
parents:
5369
diff
changeset
|
167 |
//If root is not set, we do not use "Root" attribute, because it |
050630fcf15e
Mesh: fixed FLAME PATH_UPDATE procedure, fixed mesh.cc, valgrind errors in
Kirill Andreev <andreev@iitp.ru>
parents:
5369
diff
changeset
|
168 |
//is specified only for 11s |
050630fcf15e
Mesh: fixed FLAME PATH_UPDATE procedure, fixed mesh.cc, valgrind errors in
Kirill Andreev <andreev@iitp.ru>
parents:
5369
diff
changeset
|
169 |
mesh.SetStackInstaller (m_stack); |
050630fcf15e
Mesh: fixed FLAME PATH_UPDATE procedure, fixed mesh.cc, valgrind errors in
Kirill Andreev <andreev@iitp.ru>
parents:
5369
diff
changeset
|
170 |
} |
5163 | 171 |
if (m_chan) |
172 |
{ |
|
173 |
mesh.SetSpreadInterfaceChannels (MeshHelper::SPREAD_CHANNELS); |
|
174 |
} |
|
175 |
else |
|
176 |
{ |
|
177 |
mesh.SetSpreadInterfaceChannels (MeshHelper::ZERO_CHANNEL); |
|
178 |
} |
|
5164
b81ab8394a61
Restructured helper - removed MeshInterfaceHelper
Kirill Andreev <andreev@iitp.ru>
parents:
5163
diff
changeset
|
179 |
mesh.SetMacType ("RandomStart", TimeValue (Seconds(m_randomStart))); |
5181
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
180 |
// Set number of interfaces - default is single-interface mesh point |
5163 | 181 |
mesh.SetNumberOfInterfaces (m_nIfaces); |
5181
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
182 |
// Install protocols and return container if MeshPointDevices |
5164
b81ab8394a61
Restructured helper - removed MeshInterfaceHelper
Kirill Andreev <andreev@iitp.ru>
parents:
5163
diff
changeset
|
183 |
meshDevices = mesh.Install (wifiPhy, nodes); |
5181
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
184 |
// Setup mobility - static grid topology |
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
185 |
MobilityHelper mobility; |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
186 |
mobility.SetPositionAllocator ("ns3::GridPositionAllocator", |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
187 |
"MinX", DoubleValue (0.0), |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
188 |
"MinY", DoubleValue (0.0), |
5156 | 189 |
"DeltaX", DoubleValue (m_step), |
190 |
"DeltaY", DoubleValue (m_step), |
|
191 |
"GridWidth", UintegerValue (m_xSize), |
|
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4830
diff
changeset
|
192 |
"LayoutType", StringValue ("RowFirst")); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
193 |
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
194 |
mobility.Install (nodes); |
5156 | 195 |
if (m_pcap) |
5020
79e8178d69eb
Mesh ID is made separately from SSID
Kirill Andreev <andreev@iitp.ru>
parents:
5011
diff
changeset
|
196 |
wifiPhy.EnablePcapAll (std::string ("mp-")); |
5011
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
197 |
} |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
198 |
void |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
199 |
MeshTest::InstallInternetStack () |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
200 |
{ |
5181
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
201 |
InternetStackHelper internetStack; |
22f73ce46375
Added comments in mesh.cc
Kirill Andreev <andreev@iitp.ru>
parents:
5164
diff
changeset
|
202 |
internetStack.Install (nodes); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
203 |
Ipv4AddressHelper address; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
204 |
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
|
205 |
interfaces = address.Assign (meshDevices); |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
206 |
} |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
207 |
void |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
208 |
MeshTest::InstallApplication () |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
209 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
210 |
UdpEchoServerHelper echoServer (9); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
211 |
ApplicationContainer serverApps = echoServer.Install (nodes.Get (0)); |
4964 | 212 |
serverApps.Start (Seconds (0.0)); |
5156 | 213 |
serverApps.Stop (Seconds (m_totalTime)); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
214 |
UdpEchoClientHelper echoClient (interfaces.GetAddress (0), 9); |
5156 | 215 |
echoClient.SetAttribute ("MaxPackets", UintegerValue ((uint32_t)(m_totalTime*(1/m_packetInterval)))); |
216 |
echoClient.SetAttribute ("Interval", TimeValue (Seconds (m_packetInterval))); |
|
217 |
echoClient.SetAttribute ("PacketSize", UintegerValue (m_packetSize)); |
|
218 |
ApplicationContainer clientApps = echoClient.Install (nodes.Get (m_xSize*m_ySize-1)); |
|
4964 | 219 |
clientApps.Start (Seconds (0.0)); |
5156 | 220 |
clientApps.Stop (Seconds (m_totalTime)); |
5011
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
221 |
} |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
222 |
int |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
223 |
MeshTest::Run () |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
224 |
{ |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
225 |
CreateNodes (); |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
226 |
InstallInternetStack (); |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
227 |
InstallApplication (); |
5156 | 228 |
Simulator::Schedule (Seconds(m_totalTime), & MeshTest::Report, this); |
229 |
Simulator::Stop (Seconds (m_totalTime)); |
|
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4830
diff
changeset
|
230 |
Simulator::Run (); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4830
diff
changeset
|
231 |
Simulator::Destroy (); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
232 |
return 0; |
4793 | 233 |
} |
5011
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
234 |
void |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
235 |
MeshTest::Report () |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
236 |
{ |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
237 |
unsigned n (0); |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
238 |
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
|
239 |
{ |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
240 |
std::ostringstream os; |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
241 |
os << "mp-report-" << n << ".xml"; |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
242 |
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
|
243 |
std::ofstream of; |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
244 |
of.open (os.str().c_str()); |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
245 |
if (! of.is_open ()) |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
246 |
{ |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
247 |
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
|
248 |
return; |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
249 |
} |
5081 | 250 |
mesh.Report (*i, of); |
5011
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
251 |
of.close (); |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
252 |
} |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
253 |
} |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
254 |
int |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
255 |
main (int argc, char *argv[]) |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
256 |
{ |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
257 |
MeshTest t; |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
258 |
t.Configure (argc, argv); |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
259 |
return t.Run(); |
79b4af29924a
Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
260 |
} |