author | Pavel Boyko <boyko@iitp.ru> |
Wed, 01 Apr 2009 18:05:36 +0400 | |
changeset 4929 | 1689c94d7442 |
parent 4919 | b8a0476c7e06 |
child 4930 | fa5e570d56fa |
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 |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
42 |
int xSize = 6; |
4919
b8a0476c7e06
Added unicast PREQ, peer link status callback.
Kirill Andreev <andreev@iitp.ru>
parents:
4906
diff
changeset
|
43 |
int ySize = 6; |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
44 |
double step = 100.0; //Grid with one-hop edge |
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
45 |
double randomStart = 0.1; //One beacon interval |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
46 |
|
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
47 |
// Defining a size of our network |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
48 |
CommandLine cmd; |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4830
diff
changeset
|
49 |
cmd.AddValue ("x-size", "Number of nodes in a row grid", xSize); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4830
diff
changeset
|
50 |
cmd.AddValue ("y-size", "Number of rows in a grid", ySize); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4830
diff
changeset
|
51 |
cmd.AddValue ("step", "Size of edge in our grid", step); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4830
diff
changeset
|
52 |
cmd.AddValue ("start", "Random start parameter", randomStart); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
53 |
cmd.Parse (argc, argv); |
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
54 |
NS_LOG_DEBUG ("Grid:" << xSize << "*" << ySize); |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
55 |
|
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
56 |
// Creating nodes |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
57 |
NodeContainer nodes; |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
58 |
nodes.Create (ySize*xSize); |
4793 | 59 |
|
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
60 |
// Setting channel |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
61 |
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
62 |
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
63 |
wifiPhy.SetChannel (wifiChannel.Create ()); |
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
64 |
|
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
65 |
// Install mesh point devices & protocols |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
66 |
MeshWifiHelper mesh; |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
67 |
NetDeviceContainer meshDevices = mesh.Install (wifiPhy, nodes); |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
68 |
|
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
69 |
// Setup mobility |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
70 |
MobilityHelper mobility; |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
71 |
mobility.SetPositionAllocator ("ns3::GridPositionAllocator", |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
72 |
"MinX", DoubleValue (0.0), |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
73 |
"MinY", DoubleValue (0.0), |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
74 |
"DeltaX", DoubleValue (step), |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
75 |
"DeltaY", DoubleValue (step), |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
76 |
"GridWidth", UintegerValue (xSize), |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4830
diff
changeset
|
77 |
"LayoutType", StringValue ("RowFirst")); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
78 |
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
79 |
mobility.Install (nodes); |
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
80 |
|
4877
f08902c42733
Added a method to find peer link, code cleanup
Kirill Andreev <andreev@iitp.ru>
parents:
4876
diff
changeset
|
81 |
NS_LOG_UNCOND("start"); |
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
82 |
|
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
83 |
// Install internet stack |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
84 |
InternetStackHelper stack; |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4830
diff
changeset
|
85 |
stack.Install (nodes); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
86 |
Ipv4AddressHelper address; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
87 |
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
|
88 |
Ipv4InterfaceContainer interfaces = address.Assign (meshDevices); |
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
89 |
|
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
90 |
// Install applications |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
91 |
UdpEchoServerHelper echoServer (9); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
92 |
ApplicationContainer serverApps = echoServer.Install (nodes.Get (0)); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
93 |
serverApps.Start (Seconds (1.0)); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
94 |
serverApps.Stop (Seconds (10.0)); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
95 |
UdpEchoClientHelper echoClient (interfaces.GetAddress (0), 9); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
96 |
echoClient.SetAttribute ("MaxPackets", UintegerValue (1000)); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
97 |
echoClient.SetAttribute ("Interval", TimeValue (Seconds (0.001))); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
98 |
echoClient.SetAttribute ("PacketSize", UintegerValue (1024)); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
99 |
ApplicationContainer clientApps = echoClient.Install (nodes.Get (1)); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
100 |
clientApps.Start (Seconds (2.0)); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
101 |
clientApps.Stop (Seconds (10.0)); |
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
102 |
|
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
103 |
// Happy end |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
104 |
Simulator::Stop (Seconds (10.0)); |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4830
diff
changeset
|
105 |
Simulator::Run (); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4830
diff
changeset
|
106 |
Simulator::Destroy (); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
107 |
return 0; |
4793 | 108 |
} |