examples/wifi-adhoc.cc
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Mon, 24 Mar 2008 10:42:18 -0700
changeset 2700 c54fbae72e8f
parent 2676 076b8636fea9
child 2739 5234783968ff
permissions -rw-r--r--
change signature of MobilityHelper::Layout and MobilityHelper::LayoutAll.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1884
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     2
/*
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     3
 * Copyright (c) 2005,2006,2007 INRIA
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     4
 *
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     8
 *
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    12
 * GNU General Public License for more details.
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    13
 *
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    17
 *
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    19
 */
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    20
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    21
#include "ns3/wifi-net-device.h"
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    22
#include "ns3/arf-wifi-manager.h"
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    23
#include "ns3/adhoc-wifi-mac.h"
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    24
#include "ns3/wifi-phy.h"
1884
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    25
#include "ns3/wifi-channel.h"
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    26
#include "ns3/simulator.h"
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    27
#include "ns3/callback.h"
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    28
#include "ns3/ptr.h"
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    29
#include "ns3/node.h"
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    30
#include "ns3/onoff-application.h"
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    31
#include "ns3/static-mobility-model.h"
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    32
#include "ns3/random-variable.h"
2152
5c6c0f580aca use packet sockets and generate all graphics
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2149
diff changeset
    33
#include "ns3/packet-socket-address.h"
2019
eee1c9d3811f enable packet metadata for debugging
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1973
diff changeset
    34
#include "ns3/packet.h"
2068
af5f03746dbe add throughput printer
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2019
diff changeset
    35
#include "ns3/socket.h"
af5f03746dbe add throughput printer
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2019
diff changeset
    36
#include "ns3/socket-factory.h"
2079
673a34d2e3d7 use the gnuplot machinery to output a set of plots
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2075
diff changeset
    37
#include "ns3/command-line.h"
673a34d2e3d7 use the gnuplot machinery to output a set of plots
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2075
diff changeset
    38
#include "ns3/gnuplot.h"
2494
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2470
diff changeset
    39
#include "ns3/uinteger.h"
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    40
#include "ns3/string.h"
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    41
#include "ns3/config.h"
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    42
#include "ns3/wifi-helper.h"
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    43
#include "ns3/mobility-helper.h"
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    44
#include "ns3/log.h"
1884
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    45
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    46
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    47
#include <iostream>
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    48
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    49
NS_LOG_COMPONENT_DEFINE ("Main");
1884
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    50
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    51
using namespace ns3;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    52
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    53
class Experiment
1884
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    54
{
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    55
public:
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    56
  Experiment ();
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    57
  Experiment (std::string name);
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    58
  GnuplotDataset Run (const WifiHelper &wifi);
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    59
private:
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    60
  void ReceivePacket (Ptr<Socket> socket, Ptr<Packet> packet, const Address &address);
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    61
  void SetPosition (Ptr<Node> node, Vector position);
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    62
  Vector GetPosition (Ptr<Node> node);
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    63
  void AdvancePosition (Ptr<Node> node);
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    64
  Ptr<Socket> SetupPacketReceive (Ptr<Node> node);
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    65
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    66
  uint32_t m_bytesTotal;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    67
  GnuplotDataset m_output;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    68
};
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    69
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    70
Experiment::Experiment ()
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    71
  : m_output ()
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    72
{}
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    73
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    74
Experiment::Experiment (std::string name)
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    75
  : m_output (name)
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    76
{
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    77
  m_output.SetStyle (GnuplotDataset::LINES);
1884
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    78
}
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    79
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    80
void
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    81
Experiment::SetPosition (Ptr<Node> node, Vector position)
1884
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    82
{
2257
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
    83
  Ptr<MobilityModel> mobility = node->GetObject<MobilityModel> ();
2115
4be7e10e471e merge with Position -> Vector rename
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2084
diff changeset
    84
  mobility->SetPosition (position);
1884
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    85
}
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    86
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    87
Vector
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    88
Experiment::GetPosition (Ptr<Node> node)
1884
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    89
{
2257
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
    90
  Ptr<MobilityModel> mobility = node->GetObject<MobilityModel> ();
2115
4be7e10e471e merge with Position -> Vector rename
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2084
diff changeset
    91
  return mobility->GetPosition ();
1884
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    92
}
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    93
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    94
void 
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    95
Experiment::AdvancePosition (Ptr<Node> node) 
1884
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    96
{
2115
4be7e10e471e merge with Position -> Vector rename
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2084
diff changeset
    97
  Vector pos = GetPosition (node);
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    98
  double mbs = ((m_bytesTotal * 8.0) / 1000000);
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
    99
  m_bytesTotal = 0;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   100
  m_output.Add (pos.x, mbs);
2082
d041fc198aad a real test
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2081
diff changeset
   101
  pos.x += 1.0;
2079
673a34d2e3d7 use the gnuplot machinery to output a set of plots
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2075
diff changeset
   102
  if (pos.x >= 210.0) 
673a34d2e3d7 use the gnuplot machinery to output a set of plots
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2075
diff changeset
   103
    {
673a34d2e3d7 use the gnuplot machinery to output a set of plots
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2075
diff changeset
   104
      return;
673a34d2e3d7 use the gnuplot machinery to output a set of plots
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2075
diff changeset
   105
    }
1884
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   106
  SetPosition (node, pos);
1971
2f9ca80a8d74 fix position printing code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1964
diff changeset
   107
  //std::cout << "x="<<pos.x << std::endl;
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   108
  Simulator::Schedule (Seconds (1.0), &Experiment::AdvancePosition, this, node);
1884
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   109
}
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   110
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   111
void
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   112
Experiment::ReceivePacket (Ptr<Socket> socket, Ptr<Packet> packet, const Address &address)
2068
af5f03746dbe add throughput printer
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2019
diff changeset
   113
{
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   114
  m_bytesTotal += packet->GetSize ();
2068
af5f03746dbe add throughput printer
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2019
diff changeset
   115
}
1884
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   116
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   117
Ptr<Socket>
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   118
Experiment::SetupPacketReceive (Ptr<Node> node)
2068
af5f03746dbe add throughput printer
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2019
diff changeset
   119
{
2602
d9262bff6df2 add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2600
diff changeset
   120
  TypeId tid = TypeId::LookupByName ("ns3::PacketSocketFactory");
2257
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   121
  Ptr<SocketFactory> socketFactory = node->GetObject<SocketFactory> (tid);
2068
af5f03746dbe add throughput printer
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2019
diff changeset
   122
  Ptr<Socket> sink = socketFactory->CreateSocket ();
2152
5c6c0f580aca use packet sockets and generate all graphics
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2149
diff changeset
   123
  sink->Bind ();
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   124
  sink->SetRecvCallback (MakeCallback (&Experiment::ReceivePacket, this));
2068
af5f03746dbe add throughput printer
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2019
diff changeset
   125
  return sink;
af5f03746dbe add throughput printer
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2019
diff changeset
   126
}
1884
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   127
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   128
GnuplotDataset
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   129
Experiment::Run (const WifiHelper &wifi)
1884
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   130
{
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   131
  m_bytesTotal = 0;
2149
6bf08d8a8eff plot the goodput for each data rate separately
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2115
diff changeset
   132
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   133
  NodeContainer c;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   134
  c.Create (2);
1884
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   135
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   136
  NetDeviceContainer devices = wifi.Build (c);
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   137
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   138
  MobilityHelper mobility;
2592
3ebf97150166 get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2575
diff changeset
   139
  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   140
  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   141
  positionAlloc->Add (Vector (5.0, 0.0, 0.0));
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   142
  mobility.SetPositionAllocator (positionAlloc);
2615
09e459167dc3 use the right position attribute name.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2614
diff changeset
   143
  mobility.SetMobilityModel ("ns3::StaticMobilityModel");
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   144
2700
c54fbae72e8f change signature of MobilityHelper::Layout and MobilityHelper::LayoutAll.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2676
diff changeset
   145
  mobility.Layout (c);
1884
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   146
2152
5c6c0f580aca use packet sockets and generate all graphics
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2149
diff changeset
   147
  PacketSocketAddress destination = PacketSocketAddress ();
5c6c0f580aca use packet sockets and generate all graphics
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2149
diff changeset
   148
  destination.SetProtocol (1);
5c6c0f580aca use packet sockets and generate all graphics
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2149
diff changeset
   149
  destination.SetSingleDevice (0);
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   150
  destination.SetPhysicalAddress (devices.Get (1)->GetAddress ());
2494
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2470
diff changeset
   151
  Ptr<Application> app = 
2600
6c389d0c717d add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2592
diff changeset
   152
    CreateObject<OnOffApplication> ("Remote", Address (destination),
2602
d9262bff6df2 add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2600
diff changeset
   153
                                    "Protocol", TypeId::LookupByName ("ns3::PacketSocketFactory"),
2600
6c389d0c717d add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2592
diff changeset
   154
                                    "OnTime", ConstantVariable (250),
6c389d0c717d add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2592
diff changeset
   155
                                    "OffTime", ConstantVariable (0),
6c389d0c717d add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2592
diff changeset
   156
                                    "DataRate", DataRate (60000000),
6c389d0c717d add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2592
diff changeset
   157
                                    "PacketSize", Uinteger (2000));
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   158
  c.Get (0)->AddApplication (app);
2068
af5f03746dbe add throughput printer
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2019
diff changeset
   159
1884
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   160
  app->Start (Seconds (0.5));
2079
673a34d2e3d7 use the gnuplot machinery to output a set of plots
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2075
diff changeset
   161
  app->Stop (Seconds (250.0));
1884
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   162
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   163
  Simulator::Schedule (Seconds (1.5), &Experiment::AdvancePosition, this, c.Get (1));
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   164
  Ptr<Socket> recvSink = SetupPacketReceive (c.Get (1));
1973
96673851351e configure correctly the ipv4 layer
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1971
diff changeset
   165
1884
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   166
  Simulator::Run ();
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   167
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   168
  Simulator::Destroy ();
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   169
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   170
  return m_output;
2079
673a34d2e3d7 use the gnuplot machinery to output a set of plots
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2075
diff changeset
   171
}
673a34d2e3d7 use the gnuplot machinery to output a set of plots
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2075
diff changeset
   172
673a34d2e3d7 use the gnuplot machinery to output a set of plots
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2075
diff changeset
   173
int main (int argc, char *argv[])
673a34d2e3d7 use the gnuplot machinery to output a set of plots
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2075
diff changeset
   174
{
673a34d2e3d7 use the gnuplot machinery to output a set of plots
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2075
diff changeset
   175
  // disable fragmentation
2614
5efb372326be more ns3:: prefix fixes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2602
diff changeset
   176
  Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", String ("2200"));
5efb372326be more ns3:: prefix fixes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2602
diff changeset
   177
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", String ("2200"));
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   178
2575
1aae382e65e2 rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2559
diff changeset
   179
  CommandLine cmd;
1aae382e65e2 rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2559
diff changeset
   180
  cmd.Parse (argc, argv);
2079
673a34d2e3d7 use the gnuplot machinery to output a set of plots
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2075
diff changeset
   181
2152
5c6c0f580aca use packet sockets and generate all graphics
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2149
diff changeset
   182
  Gnuplot gnuplot = Gnuplot ("reference-rates.png");
2079
673a34d2e3d7 use the gnuplot machinery to output a set of plots
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2075
diff changeset
   183
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   184
  Experiment experiment;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   185
  WifiHelper wifi;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   186
  GnuplotDataset dataset;
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   187
2602
d9262bff6df2 add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2600
diff changeset
   188
  wifi.SetMac ("ns3::AdhocWifiMac");
d9262bff6df2 add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2600
diff changeset
   189
  wifi.SetPhy ("ns3::WifiPhy");
2149
6bf08d8a8eff plot the goodput for each data rate separately
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2115
diff changeset
   190
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   191
  NS_LOG_DEBUG ("54");
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   192
  experiment = Experiment ("54mb");
2602
d9262bff6df2 add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2600
diff changeset
   193
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   194
                                "DataMode", String ("wifia-54mbs"));
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   195
  dataset = experiment.Run (wifi);
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   196
  gnuplot.AddDataset (dataset);
2149
6bf08d8a8eff plot the goodput for each data rate separately
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2115
diff changeset
   197
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   198
  NS_LOG_DEBUG ("48");
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   199
  experiment = Experiment ("48mb");
2602
d9262bff6df2 add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2600
diff changeset
   200
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   201
                                "DataMode", String ("wifia-48mbs"));
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   202
  dataset = experiment.Run (wifi);
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   203
  gnuplot.AddDataset (dataset);
2149
6bf08d8a8eff plot the goodput for each data rate separately
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2115
diff changeset
   204
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   205
  NS_LOG_DEBUG ("36");
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   206
  experiment = Experiment ("36mb");
2602
d9262bff6df2 add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2600
diff changeset
   207
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   208
                                "DataMode", String ("wifia-36mbs"));
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   209
  dataset = experiment.Run (wifi);
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   210
  gnuplot.AddDataset (dataset);
2149
6bf08d8a8eff plot the goodput for each data rate separately
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2115
diff changeset
   211
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   212
  NS_LOG_DEBUG ("24");
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   213
  experiment = Experiment ("24mb");
2602
d9262bff6df2 add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2600
diff changeset
   214
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   215
                                "DataMode", String ("wifia-24mbs"));
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   216
  dataset = experiment.Run (wifi);
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   217
  gnuplot.AddDataset (dataset);
2149
6bf08d8a8eff plot the goodput for each data rate separately
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2115
diff changeset
   218
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   219
  NS_LOG_DEBUG ("18");
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   220
  experiment = Experiment ("18mb");
2602
d9262bff6df2 add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2600
diff changeset
   221
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   222
                                "DataMode", String ("wifia-18mbs"));
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   223
  dataset = experiment.Run (wifi);
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   224
  gnuplot.AddDataset (dataset);
2149
6bf08d8a8eff plot the goodput for each data rate separately
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2115
diff changeset
   225
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   226
  NS_LOG_DEBUG ("12");
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   227
  experiment = Experiment ("12mb");
2602
d9262bff6df2 add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2600
diff changeset
   228
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   229
                                "DataMode", String ("wifia-12mbs"));
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   230
  dataset = experiment.Run (wifi);
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   231
  gnuplot.AddDataset (dataset);
2149
6bf08d8a8eff plot the goodput for each data rate separately
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2115
diff changeset
   232
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   233
  NS_LOG_DEBUG ("9");
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   234
  experiment = Experiment ("9mb");
2602
d9262bff6df2 add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2600
diff changeset
   235
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   236
                                "DataMode", String ("wifia-9mbs"));
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   237
  dataset = experiment.Run (wifi);
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   238
  gnuplot.AddDataset (dataset);
2149
6bf08d8a8eff plot the goodput for each data rate separately
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2115
diff changeset
   239
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   240
  NS_LOG_DEBUG ("6");
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   241
  experiment = Experiment ("6mb");
2602
d9262bff6df2 add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2600
diff changeset
   242
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   243
                                "DataMode", String ("wifia-6mbs"));
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   244
  dataset = experiment.Run (wifi);
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   245
  gnuplot.AddDataset (dataset);
2149
6bf08d8a8eff plot the goodput for each data rate separately
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2115
diff changeset
   246
2152
5c6c0f580aca use packet sockets and generate all graphics
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2149
diff changeset
   247
  gnuplot.GenerateOutput (std::cout);
5c6c0f580aca use packet sockets and generate all graphics
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2149
diff changeset
   248
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   249
2149
6bf08d8a8eff plot the goodput for each data rate separately
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2115
diff changeset
   250
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   251
  gnuplot = Gnuplot ("rate-control.png");
2676
076b8636fea9 add missing prefix.
Federico Maguolo <maguolof@dei.unipd.it>
parents: 2662
diff changeset
   252
  Config::SetDefault ("ns3::WifiPhy::Standard", String ("holland"));
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   253
2149
6bf08d8a8eff plot the goodput for each data rate separately
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2115
diff changeset
   254
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   255
  NS_LOG_DEBUG ("arf");
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   256
  experiment = Experiment ("arf");
2602
d9262bff6df2 add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2600
diff changeset
   257
  wifi.SetRemoteStationManager ("ns3::ArfWifiManager");
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   258
  dataset = experiment.Run (wifi);
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   259
  gnuplot.AddDataset (dataset);
2149
6bf08d8a8eff plot the goodput for each data rate separately
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2115
diff changeset
   260
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   261
  NS_LOG_DEBUG ("aarf");
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   262
  experiment = Experiment ("aarf");
2602
d9262bff6df2 add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2600
diff changeset
   263
  wifi.SetRemoteStationManager ("ns3::AarfWifiManager");
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   264
  dataset = experiment.Run (wifi);
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   265
  gnuplot.AddDataset (dataset);
2079
673a34d2e3d7 use the gnuplot machinery to output a set of plots
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2075
diff changeset
   266
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   267
  NS_LOG_DEBUG ("ideal");
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   268
  experiment = Experiment ("ideal");
2602
d9262bff6df2 add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2600
diff changeset
   269
  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
2524
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   270
  dataset = experiment.Run (wifi);
db72c0e7743e port wifi model to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   271
  gnuplot.AddDataset (dataset);
2152
5c6c0f580aca use packet sockets and generate all graphics
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2149
diff changeset
   272
2079
673a34d2e3d7 use the gnuplot machinery to output a set of plots
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2075
diff changeset
   273
  gnuplot.GenerateOutput (std::cout);
1884
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   274
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   275
  return 0;
6056f112404c build wifi sample code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   276
}