author | Kirill Andreev <andreev@iitp.ru> |
Thu, 19 Mar 2009 20:09:50 +0300 | |
changeset 4858 | 78437693dcc7 |
parent 4855 | 0b5980b04249 |
child 4860 | bb5194d57734 |
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 |
||
31 |
using namespace ns3; |
|
32 |
||
33 |
NS_LOG_COMPONENT_DEFINE ("TestMeshScript"); |
|
34 |
||
35 |
int |
|
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4830
diff
changeset
|
36 |
main (int argc, char *argv[]) |
4793 | 37 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
38 |
// Creating square topology with nNodes x nNodes grid: |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
39 |
int xSize = 5; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
40 |
int ySize = 5; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
41 |
double step = 100.0; //Grid with one-hop edge |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
42 |
double randomStart = 0.1; //One beacon interval |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
43 |
NodeContainer nodes; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
44 |
CommandLine cmd; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
45 |
MobilityHelper mobility; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
46 |
MeshWifiHelper wifi; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
47 |
NetDeviceContainer meshDevices; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
48 |
// Defining a size of our network: |
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); |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4830
diff
changeset
|
54 |
NS_LOG_DEBUG ("Grid:"<<xSize<<"*"<<ySize); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
55 |
// Creating nodes: |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
56 |
nodes.Create (ySize*xSize); |
4793 | 57 |
|
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
58 |
// Setting channel: |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
59 |
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
60 |
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
61 |
wifiPhy.SetChannel (wifiChannel.Create ()); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
62 |
// Setting Wifi: |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4830
diff
changeset
|
63 |
//wifi.SetPhy ("ns3::WifiPhy"); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4830
diff
changeset
|
64 |
wifi.SetRemoteStationManager ("ns3::AarfWifiManager"); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4830
diff
changeset
|
65 |
Ssid ssid = Ssid ("MyMeSH"); |
4855
0b5980b04249
Restructured helper: switch to new mac, now only beacon functionality works
Kirill Andreev <andreev@iitp.ru>
parents:
4852
diff
changeset
|
66 |
wifi.SetMac ("ns3::MeshWifiInterfaceMac", |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
67 |
"Ssid", SsidValue (ssid), |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
68 |
"RandomStart", TimeValue (Seconds (randomStart)) |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
69 |
); |
4858
78437693dcc7
Peer manager restructure - unfinished
Kirill Andreev <andreev@iitp.ru>
parents:
4855
diff
changeset
|
70 |
//wifi.SetPeerManager("ns3::WifiPeerManager"); |
78437693dcc7
Peer manager restructure - unfinished
Kirill Andreev <andreev@iitp.ru>
parents:
4855
diff
changeset
|
71 |
wifi.SetPeerManager("ns3::Dot11sPeerManagerProtocol"); |
4824
b41e1f24487a
information elements are moved to 802.11s
Kirill Andreev <andreev@iitp.ru>
parents:
4813
diff
changeset
|
72 |
wifi.SetL2RoutingNetDevice ("ns3::MeshPointDevice"); |
4855
0b5980b04249
Restructured helper: switch to new mac, now only beacon functionality works
Kirill Andreev <andreev@iitp.ru>
parents:
4852
diff
changeset
|
73 |
meshDevices = wifi.Install (wifiPhy,nodes); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
74 |
// Installing Mobility. |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
75 |
mobility.SetPositionAllocator ("ns3::GridPositionAllocator", |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
76 |
"MinX", DoubleValue (0.0), |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
77 |
"MinY", DoubleValue (0.0), |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
78 |
"DeltaX", DoubleValue (step), |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
79 |
"DeltaY", DoubleValue (step), |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
80 |
"GridWidth", UintegerValue (xSize), |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4830
diff
changeset
|
81 |
"LayoutType", StringValue ("RowFirst")); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
82 |
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
83 |
mobility.Install (nodes); |
4855
0b5980b04249
Restructured helper: switch to new mac, now only beacon functionality works
Kirill Andreev <andreev@iitp.ru>
parents:
4852
diff
changeset
|
84 |
#if 0 |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
85 |
// Setting Internet Stack: |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
86 |
InternetStackHelper stack; |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4830
diff
changeset
|
87 |
stack.Install (nodes); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
88 |
Ipv4AddressHelper address; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
89 |
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
|
90 |
Ipv4InterfaceContainer interfaces = address.Assign (meshDevices); |
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)); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
102 |
//end |
4855
0b5980b04249
Restructured helper: switch to new mac, now only beacon functionality works
Kirill Andreev <andreev@iitp.ru>
parents:
4852
diff
changeset
|
103 |
#endif |
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 |
} |