examples/mesh.cc
author Kirill Andreev <andreev@iitp.ru>
Tue, 09 Jun 2009 20:13:11 +0400
changeset 5054 49851228eec9
parent 5020 79e8178d69eb
child 5055 903fb7d81b97
permissions -rw-r--r--
Added interface helper
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     2
/*
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     3
 * Copyright (c) 2008,2009 IITP RAS
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     4
 *
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     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
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     8
 *
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    12
 * GNU General Public License for more details.
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    13
 *
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    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
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    19
 */
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    20
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    21
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    22
#include "ns3/core-module.h"
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    23
#include "ns3/simulator-module.h"
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    24
#include "ns3/node-module.h"
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    25
#include "ns3/helper-module.h"
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    26
#include "ns3/global-routing-module.h"
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    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
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    29
#include "ns3/mobility-module.h"
5011
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    30
#include "ns3/dot11s-helper.h"
5054
49851228eec9 Added interface helper
Kirill Andreev <andreev@iitp.ru>
parents: 5020
diff changeset
    31
#include "ns3/dot11s-interface-helper.h"
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    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
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    37
using namespace ns3;
4872
ea1bce018a44 Added namespace dot11s
Kirill Andreev <andreev@iitp.ru>
parents: 4869
diff changeset
    38
using namespace dot11s;
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    39
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    40
NS_LOG_COMPONENT_DEFINE ("TestMeshScript");
5011
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    41
class MeshTest
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
    42
{
5011
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    43
  public:
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    44
    /// Init test
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    45
    MeshTest ();
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    46
    /// Configure test from command line arguments
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    47
    void Configure (int argc, char ** argv);
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    48
    /// Run test
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    49
    int Run ();
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    50
  private:
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    51
    int       xSize;
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    52
    int       ySize;
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    53
    double    step;
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    54
    double    randomStart;
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    55
    double    totalTime;
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    56
    double    packetInterval;
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    57
    uint16_t  packetSize;
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    58
    uint32_t  nIfaces;
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    59
    bool      chan;
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    60
    bool      pcap;
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    61
    uint64_t  seed;
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    62
    /// List of network nodes
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    63
    NodeContainer nodes;
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    64
    /// List of all mesh point devices
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    65
    NetDeviceContainer meshDevices;
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    66
    //Addresses of interfaces:
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    67
    Ipv4InterfaceContainer interfaces;
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    68
    //InternetStackHelper stack;
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    69
    //Ipv4AddressHelper address;
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    70
  private:
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    71
    /// Create nodes and setup theis mobility
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    72
    void CreateNodes ();
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    73
    /// Install internet stack on nodes
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    74
    void InstallInternetStack ();
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    75
    /// Install applications
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    76
    void InstallApplication ();
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    77
    /// Print mesh devices diagnostics
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    78
    void Report ();  
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    79
};
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    80
MeshTest::MeshTest () :
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    81
  xSize (3),
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    82
  ySize (3),
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    83
  step (100.0),
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    84
  randomStart (0.1),
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    85
  totalTime (100.0),
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    86
  packetInterval (0.1),
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    87
  packetSize (1024),
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    88
  nIfaces (1),
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    89
  chan (true),
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    90
  pcap (false),
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    91
  seed (1)
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    92
{
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    93
}
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    94
void
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    95
MeshTest::Configure (int argc, char *argv[])
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
    96
{
4929
1689c94d7442 802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents: 4919
diff changeset
    97
  CommandLine cmd;
4930
fa5e570d56fa Mesh test refactored, see --pcap and --interfaces command line arguments
Pavel Boyko <boyko@iitp.ru>
parents: 4929
diff changeset
    98
  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
    99
  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
   100
  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
   101
  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
   102
  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
   103
  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
   104
  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
   105
  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
   106
  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
   107
  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
   108
  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
   109
  
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4811
diff changeset
   110
  cmd.Parse (argc, argv);
4929
1689c94d7442 802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents: 4919
diff changeset
   111
  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
   112
  NS_LOG_DEBUG ("Simulation time: " << totalTime << " s");
4963
869399fad0b6 Fixed proactive mode. 1 root works
Kirill Andreev <andreev@iitp.ru>
parents: 4962
diff changeset
   113
  SeedManager::SetSeed(seed);
5011
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   114
}
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   115
void
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   116
MeshTest::CreateNodes ()
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   117
{ 
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4811
diff changeset
   118
  nodes.Create (ySize*xSize);
4929
1689c94d7442 802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents: 4919
diff changeset
   119
  // Setting channel
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4811
diff changeset
   120
  YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4811
diff changeset
   121
  YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4811
diff changeset
   122
  wifiPhy.SetChannel (wifiChannel.Create ());
4929
1689c94d7442 802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents: 4919
diff changeset
   123
  // Install mesh point devices & protocols
1689c94d7442 802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents: 4919
diff changeset
   124
  MeshWifiHelper mesh;
4937
7211ebc93e69 Add spread interfaces frequency channels option
Pavel Boyko <boyko@iitp.ru>
parents: 4933
diff changeset
   125
  mesh.SetSpreadInterfaceChannels (chan);
4963
869399fad0b6 Fixed proactive mode. 1 root works
Kirill Andreev <andreev@iitp.ru>
parents: 4962
diff changeset
   126
  std::vector<uint32_t> roots;
5054
49851228eec9 Added interface helper
Kirill Andreev <andreev@iitp.ru>
parents: 5020
diff changeset
   127
  roots.push_back(xSize-1);
49851228eec9 Added interface helper
Kirill Andreev <andreev@iitp.ru>
parents: 5020
diff changeset
   128
  roots.push_back(xSize*ySize-xSize);
49851228eec9 Added interface helper
Kirill Andreev <andreev@iitp.ru>
parents: 5020
diff changeset
   129
  MeshInterfaceHelper interface = MeshInterfaceHelper::Default ();
49851228eec9 Added interface helper
Kirill Andreev <andreev@iitp.ru>
parents: 5020
diff changeset
   130
  interface.SetType ("RandomStart", TimeValue (Seconds(randomStart)));
49851228eec9 Added interface helper
Kirill Andreev <andreev@iitp.ru>
parents: 5020
diff changeset
   131
49851228eec9 Added interface helper
Kirill Andreev <andreev@iitp.ru>
parents: 5020
diff changeset
   132
  meshDevices = mesh.Install (wifiPhy, interface, nodes, roots, nIfaces);
4929
1689c94d7442 802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents: 4919
diff changeset
   133
  // Setup mobility
1689c94d7442 802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents: 4919
diff changeset
   134
  MobilityHelper mobility;
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4811
diff changeset
   135
  mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4811
diff changeset
   136
                                 "MinX", DoubleValue (0.0),
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4811
diff changeset
   137
                                 "MinY", DoubleValue (0.0),
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4811
diff changeset
   138
                                 "DeltaX", DoubleValue (step),
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4811
diff changeset
   139
                                 "DeltaY", DoubleValue (step),
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4811
diff changeset
   140
                                 "GridWidth", UintegerValue (xSize),
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4830
diff changeset
   141
                                 "LayoutType", StringValue ("RowFirst"));
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4811
diff changeset
   142
  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4811
diff changeset
   143
  mobility.Install (nodes);
5011
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   144
  if (pcap)
5020
79e8178d69eb Mesh ID is made separately from SSID
Kirill Andreev <andreev@iitp.ru>
parents: 5011
diff changeset
   145
    wifiPhy.EnablePcapAll (std::string ("mp-"));
5011
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   146
}
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   147
void
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   148
MeshTest::InstallInternetStack ()
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   149
{
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4811
diff changeset
   150
  InternetStackHelper stack;
4852
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4830
diff changeset
   151
  stack.Install (nodes);
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4811
diff changeset
   152
  Ipv4AddressHelper address;
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4811
diff changeset
   153
  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
   154
  interfaces = address.Assign (meshDevices);
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   155
}
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   156
void
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   157
MeshTest::InstallApplication ()
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   158
{
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4811
diff changeset
   159
  UdpEchoServerHelper echoServer (9);
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4811
diff changeset
   160
  ApplicationContainer serverApps = echoServer.Install (nodes.Get (0));
4964
9107f67330f3 More than one root works
Kirill Andreev <andreev@iitp.ru>
parents: 4963
diff changeset
   161
  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
   162
  serverApps.Stop (Seconds (totalTime));
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4811
diff changeset
   163
  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
   164
  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
   165
  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
   166
  echoClient.SetAttribute ("PacketSize", UintegerValue (packetSize));
4961
62ff08884f5e Fixed bug pith routing information collected from PREP
Kirill Andreev <andreev@iitp.ru>
parents: 4947
diff changeset
   167
  ApplicationContainer clientApps = echoClient.Install (nodes.Get (xSize*ySize-1));
4964
9107f67330f3 More than one root works
Kirill Andreev <andreev@iitp.ru>
parents: 4963
diff changeset
   168
  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
   169
  clientApps.Stop (Seconds (totalTime));
5011
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   170
}
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   171
int
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   172
MeshTest::Run ()
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   173
{
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   174
  CreateNodes ();
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   175
  InstallInternetStack ();
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   176
  InstallApplication ();
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   177
  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
   178
  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
   179
  Simulator::Run ();
123dc54d734e Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents: 4830
diff changeset
   180
  Simulator::Destroy ();
4812
adcb26652e1d Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents: 4811
diff changeset
   181
  return 0;
4793
4f6a6772628e Merge 802.11s code.
Andrey Mazo <mazo@iitp.ru>
parents:
diff changeset
   182
}
5011
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   183
void
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   184
MeshTest::Report ()
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   185
{
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   186
  NS_LOG_UNCOND("Report is here:");
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   187
  unsigned n (0);
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   188
  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
   189
  {
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   190
    std::ostringstream os;
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   191
    os << "mp-report-" << n << ".xml";
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   192
    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
   193
    std::ofstream of;
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   194
    of.open (os.str().c_str());
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   195
    if (! of.is_open ())
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   196
    {
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   197
      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
   198
      return;
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   199
    }
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   200
    MeshWifiHelper::Report (*i, of);
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   201
    of.close ();
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   202
  }
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   203
}
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   204
int
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   205
main (int argc, char *argv[])
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
  MeshTest t; 
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   208
  t.Configure (argc, argv);
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   209
  return t.Run();
79b4af29924a Infrastructure for statistics is done
Kirill Andreev <andreev@iitp.ru>
parents: 4987
diff changeset
   210
}