View | Details | Raw Unified | Return to bug 2050
Collapse All | Expand All

(-)310a9f28531d (+162 lines)
Added Link Here 
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
 * Copyright (c) 2015 Sébastien Deronne
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License version 2 as
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
 *
18
 * Author: Sébastien Deronne <sebastien.deronne@gmail.com>
19
 */
20
21
#include "ns3/core-module.h"
22
#include "ns3/network-module.h"
23
#include "ns3/applications-module.h"
24
#include "ns3/wifi-module.h"
25
#include "ns3/mobility-module.h"
26
#include "ns3/ipv4-global-routing-helper.h"
27
#include "ns3/internet-module.h"
28
29
//This is a simple example in order to show how 802.11n MPDU aggregation feature works.
30
//
31
//Network topology:
32
//
33
//  Wifi 192.168.1.0
34
//
35
//         AP
36
//    *    *
37
//    |    |
38
//    n2   n3
39
//
40
//Packets in this simulation aren't marked with a QosTag so they are considered
41
//belonging to BestEffort Access Class (AC_BE).
42
43
using namespace ns3;
44
45
NS_LOG_COMPONENT_DEFINE ("SimpleMpduAggregation");
46
47
int main (int argc, char *argv[])
48
{
49
  uint32_t payloadSize = 1472; //bytes
50
  uint64_t simulationTime = 10; //seconds
51
  bool enableRts = 0;
52
    
53
  CommandLine cmd;
54
  cmd.AddValue("payloadSize", "Payload size in bytes", payloadSize);
55
  cmd.AddValue("enableRts", "Enable RTS/CTS", enableRts);
56
  cmd.AddValue("simulationTime", "Simulation time in seconds", simulationTime);
57
  cmd.Parse (argc, argv);
58
59
  std::cout << "nMPDU" << "\t\tThroughput (Mbit/s)" << '\n';
60
    
61
  for (int i = 0 ; i <= 6; i++)
62
  {
63
    uint32_t nMpdu = std::pow(2,i);
64
      
65
    if(!enableRts)
66
      Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("999999"));
67
    else
68
      Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("0"));
69
     
70
    Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("990000"));
71
72
    NodeContainer wifiStaNode;
73
    wifiStaNode.Create (1);
74
    NodeContainer wifiApNode;
75
    wifiApNode.Create(1);
76
77
    YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
78
    YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
79
    phy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO);
80
    phy.SetChannel (channel.Create());
81
82
    WifiHelper wifi = WifiHelper::Default ();
83
    wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
84
    wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue("OfdmRate65MbpsBW20MHz"), "ControlMode", StringValue("OfdmRate6_5MbpsBW20MHz"));
85
    HtWifiMacHelper mac = HtWifiMacHelper::Default ();
86
87
    Ssid ssid = Ssid ("simple-mpdu-aggregation");
88
    mac.SetType ("ns3::StaWifiMac",
89
                 "Ssid", SsidValue (ssid),
90
                 "ActiveProbing", BooleanValue (false));
91
92
    if (nMpdu > 1) mac.SetBlockAckThresholdForAc (AC_BE, 2);
93
94
    mac.SetMpduAggregatorForAc (AC_BE,"ns3::MpduStandardAggregator",
95
                                      "MaxAmpduSize", UintegerValue (nMpdu*(payloadSize+100)));
96
  
97
    NetDeviceContainer staDevice;
98
    staDevice = wifi.Install (phy, mac, wifiStaNode);
99
100
    mac.SetType ("ns3::ApWifiMac",
101
                 "Ssid", SsidValue (ssid),
102
                 "BeaconInterval", TimeValue (MicroSeconds(102400)),
103
                 "BeaconGeneration", BooleanValue (true));
104
105
    if (nMpdu > 1) mac.SetBlockAckThresholdForAc (AC_BE, 2);
106
107
    mac.SetMpduAggregatorForAc (AC_BE,"ns3::MpduStandardAggregator",
108
                                      "MaxAmpduSize", UintegerValue (nMpdu*(payloadSize+100)));
109
110
    NetDeviceContainer apDevice;
111
    apDevice = wifi.Install (phy, mac, wifiApNode);
112
113
    MobilityHelper mobility;
114
    Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
115
116
    positionAlloc->Add (Vector (0.0, 0.0, 0.0));
117
    positionAlloc->Add (Vector (1.0, 0.0, 0.0));
118
    mobility.SetPositionAllocator (positionAlloc);
119
120
    mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
121
122
    mobility.Install (wifiApNode);
123
    mobility.Install (wifiStaNode);
124
125
    InternetStackHelper stack;
126
    stack.Install (wifiApNode);
127
    stack.Install (wifiStaNode);
128
129
    Ipv4AddressHelper address;
130
131
    address.SetBase ("192.168.1.0", "255.255.255.0");
132
    Ipv4InterfaceContainer StaInterface;
133
    StaInterface = address.Assign (staDevice);
134
    Ipv4InterfaceContainer ApInterface;
135
    ApInterface = address.Assign (apDevice);
136
      
137
    UdpServerHelper myServer (9);
138
    ApplicationContainer serverApp = myServer.Install (wifiStaNode.Get (0));
139
    serverApp.Start (Seconds (0.0));
140
    serverApp.Stop (Seconds (simulationTime+1));
141
      
142
    UdpClientHelper myClient (StaInterface.GetAddress (0), 9);
143
    myClient.SetAttribute ("MaxPackets", UintegerValue (4294967295));
144
    myClient.SetAttribute ("Interval", TimeValue (Time ("0.00002"))); //packets/s
145
    myClient.SetAttribute ("PacketSize", UintegerValue (payloadSize));
146
              
147
    ApplicationContainer clientApp = myClient.Install (wifiApNode.Get (0));
148
    clientApp.Start (Seconds (1.0));
149
    clientApp.Stop (Seconds (simulationTime+1));
150
      
151
    Simulator::Stop (Seconds (simulationTime+1));
152
153
    Simulator::Run ();
154
    Simulator::Destroy ();
155
      
156
    uint32_t totalPacketsThrough = DynamicCast<UdpServer>(serverApp.Get (0))->GetReceived ();
157
    double throughput = totalPacketsThrough*payloadSize*8/(simulationTime*1000000.0);
158
159
      std::cout << nMpdu << "\t\t" << throughput << '\n';
160
  }
161
  return 0;
162
}
(-)310a9f28531d (+149 lines)
Added Link Here 
1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
 * Copyright (c) 2009 MIRKO BANCHI
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License version 2 as 
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
 *
18
 * Author: Mirko Banchi <mk.banchi@gmail.com>
19
 */
20
#include "ns3/core-module.h"
21
#include "ns3/network-module.h"
22
#include "ns3/applications-module.h"
23
#include "ns3/wifi-module.h"
24
#include "ns3/mobility-module.h"
25
#include "ns3/ipv4-global-routing-helper.h"
26
#include "ns3/internet-module.h"
27
28
//This is a simple example in order to show how 802.11n frame aggregation feature (A-MSDU) works.
29
//
30
//Network topology:
31
// 
32
//  Wifi 192.168.1.0
33
// 
34
//             AP
35
//   *    *    *
36
//   |    |    |
37
//   n1   n2   n3 
38
//
39
//Packets in this simulation aren't marked with a QosTag so they are considered
40
//belonging to BestEffort Access Class (AC_BE).
41
42
using namespace ns3;
43
44
NS_LOG_COMPONENT_DEFINE ("SimpleWifiFrameAggregation");
45
46
int main (int argc, char *argv[])
47
{
48
  //LogComponentEnable ("EdcaTxopN", LOG_LEVEL_DEBUG);
49
  LogComponentEnable ("MsduAggregator", LOG_LEVEL_INFO);
50
  LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO);
51
  LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO);
52
53
  uint32_t nWifi = 1;
54
  CommandLine cmd;
55
  cmd.AddValue ("nWifi", "Number of wifi STA devices", nWifi);
56
  cmd.Parse (argc,argv);
57
58
  NodeContainer wifiNodes;
59
  wifiNodes.Create (2);
60
  NodeContainer wifiApNode;
61
  wifiApNode.Create (1);
62
 
63
  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
64
  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
65
  phy.SetChannel (channel.Create ());
66
67
  WifiHelper wifi = WifiHelper::Default ();
68
  QosWifiMacHelper mac = QosWifiMacHelper::Default ();
69
  wifi.SetRemoteStationManager ("ns3::AarfWifiManager", "FragmentationThreshold", UintegerValue (2500));
70
71
  Ssid ssid = Ssid ("ns-3-802.11n");
72
  mac.SetType ("ns3::StaWifiMac",
73
               "Ssid", SsidValue (ssid),
74
               "ActiveProbing", BooleanValue (false));
75
  mac.SetMsduAggregatorForAc (AC_BE, "ns3::MsduStandardAggregator", 
76
                              "MaxAmsduSize", UintegerValue (3839));
77
78
  NetDeviceContainer staDevices;
79
  staDevices = wifi.Install (phy, mac, wifiNodes);
80
81
  mac.SetType ("ns3::ApWifiMac",
82
               "Ssid", SsidValue (ssid));
83
  mac.SetMsduAggregatorForAc (AC_BE, "ns3::MsduStandardAggregator", 
84
                              "MaxAmsduSize", UintegerValue (7935));
85
86
  NetDeviceContainer apDevice;
87
  apDevice = wifi.Install (phy, mac, wifiApNode);
88
 
89
  /* Setting mobility model */
90
  MobilityHelper mobility;
91
92
  mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
93
                                 "MinX", DoubleValue (0.0),
94
                                 "MinY", DoubleValue (0.0),
95
                                 "DeltaX", DoubleValue (5.0),
96
                                 "DeltaY", DoubleValue (10.0),
97
                                 "GridWidth", UintegerValue (3),
98
                                 "LayoutType", StringValue ("RowFirst"));
99
100
  mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel",
101
                             "Bounds", RectangleValue (Rectangle (-50, 50, -50, 50)));
102
  mobility.Install (wifiNodes);
103
104
  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
105
  mobility.Install (wifiApNode);
106
107
  /* Internet stack*/
108
  InternetStackHelper stack;
109
  stack.Install (wifiApNode);
110
  stack.Install (wifiNodes);
111
112
  Ipv4AddressHelper address;
113
114
  address.SetBase ("192.168.1.0", "255.255.255.0");
115
  Ipv4InterfaceContainer wifiNodesInterfaces;
116
  Ipv4InterfaceContainer apNodeInterface;
117
118
  wifiNodesInterfaces = address.Assign (staDevices);
119
  apNodeInterface = address.Assign (apDevice);
120
121
  /* Setting applications */
122
  UdpEchoServerHelper echoServer (9);
123
124
  ApplicationContainer serverApps = echoServer.Install (wifiNodes.Get (1));
125
  serverApps.Start (Seconds (1.0));
126
  serverApps.Stop (Seconds (10.0));
127
128
  UdpEchoClientHelper echoClient (wifiNodesInterfaces.GetAddress (1), 9);
129
  echoClient.SetAttribute ("MaxPackets", UintegerValue (3));
130
  echoClient.SetAttribute ("Interval", TimeValue (Seconds (0.000001)));
131
  echoClient.SetAttribute ("PacketSize", UintegerValue (1500));
132
133
  ApplicationContainer clientApps = 
134
    echoClient.Install (wifiNodes.Get (0));
135
  clientApps.Start (Seconds (2.0));
136
  clientApps.Stop (Seconds (10.0));
137
138
  Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
139
140
  Simulator::Stop (Seconds (10.0));
141
142
  phy.EnablePcap ("test-802.11n", 
143
                  wifiNodes.Get (nWifi - 1)->GetId (), 0);
144
145
  Simulator::Run ();
146
  Simulator::Destroy ();
147
148
  return 0;
149
}
(-)a/examples/wireless/simple-wifi-frame-aggregation.cc (-149 lines)
Removed Link Here 
1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
 * Copyright (c) 2009 MIRKO BANCHI
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License version 2 as 
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
 *
18
 * Author: Mirko Banchi <mk.banchi@gmail.com>
19
 */
20
#include "ns3/core-module.h"
21
#include "ns3/network-module.h"
22
#include "ns3/applications-module.h"
23
#include "ns3/wifi-module.h"
24
#include "ns3/mobility-module.h"
25
#include "ns3/ipv4-global-routing-helper.h"
26
#include "ns3/internet-module.h"
27
28
//This is a simple example in order to show how 802.11n frame aggregation feature (A-MSDU) works.
29
//
30
//Network topology:
31
// 
32
//  Wifi 192.168.1.0
33
// 
34
//             AP
35
//   *    *    *
36
//   |    |    |
37
//   n1   n2   n3 
38
//
39
//Packets in this simulation aren't marked with a QosTag so they are considered
40
//belonging to BestEffort Access Class (AC_BE).
41
42
using namespace ns3;
43
44
NS_LOG_COMPONENT_DEFINE ("SimpleWifiFrameAggregation");
45
46
int main (int argc, char *argv[])
47
{
48
  //LogComponentEnable ("EdcaTxopN", LOG_LEVEL_DEBUG);
49
  LogComponentEnable ("MsduAggregator", LOG_LEVEL_INFO);
50
  LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO);
51
  LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO);
52
53
  uint32_t nWifi = 1;
54
  CommandLine cmd;
55
  cmd.AddValue ("nWifi", "Number of wifi STA devices", nWifi);
56
  cmd.Parse (argc,argv);
57
58
  NodeContainer wifiNodes;
59
  wifiNodes.Create (2);
60
  NodeContainer wifiApNode;
61
  wifiApNode.Create (1);
62
 
63
  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
64
  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
65
  phy.SetChannel (channel.Create ());
66
67
  WifiHelper wifi = WifiHelper::Default ();
68
  QosWifiMacHelper mac = QosWifiMacHelper::Default ();
69
  wifi.SetRemoteStationManager ("ns3::AarfWifiManager", "FragmentationThreshold", UintegerValue (2500));
70
71
  Ssid ssid = Ssid ("ns-3-802.11n");
72
  mac.SetType ("ns3::StaWifiMac",
73
               "Ssid", SsidValue (ssid),
74
               "ActiveProbing", BooleanValue (false));
75
  mac.SetMsduAggregatorForAc (AC_BE, "ns3::MsduStandardAggregator", 
76
                              "MaxAmsduSize", UintegerValue (3839));
77
78
  NetDeviceContainer staDevices;
79
  staDevices = wifi.Install (phy, mac, wifiNodes);
80
81
  mac.SetType ("ns3::ApWifiMac",
82
               "Ssid", SsidValue (ssid));
83
  mac.SetMsduAggregatorForAc (AC_BE, "ns3::MsduStandardAggregator", 
84
                              "MaxAmsduSize", UintegerValue (7935));
85
86
  NetDeviceContainer apDevice;
87
  apDevice = wifi.Install (phy, mac, wifiApNode);
88
 
89
  /* Setting mobility model */
90
  MobilityHelper mobility;
91
92
  mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
93
                                 "MinX", DoubleValue (0.0),
94
                                 "MinY", DoubleValue (0.0),
95
                                 "DeltaX", DoubleValue (5.0),
96
                                 "DeltaY", DoubleValue (10.0),
97
                                 "GridWidth", UintegerValue (3),
98
                                 "LayoutType", StringValue ("RowFirst"));
99
100
  mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel",
101
                             "Bounds", RectangleValue (Rectangle (-50, 50, -50, 50)));
102
  mobility.Install (wifiNodes);
103
104
  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
105
  mobility.Install (wifiApNode);
106
107
  /* Internet stack*/
108
  InternetStackHelper stack;
109
  stack.Install (wifiApNode);
110
  stack.Install (wifiNodes);
111
112
  Ipv4AddressHelper address;
113
114
  address.SetBase ("192.168.1.0", "255.255.255.0");
115
  Ipv4InterfaceContainer wifiNodesInterfaces;
116
  Ipv4InterfaceContainer apNodeInterface;
117
118
  wifiNodesInterfaces = address.Assign (staDevices);
119
  apNodeInterface = address.Assign (apDevice);
120
121
  /* Setting applications */
122
  UdpEchoServerHelper echoServer (9);
123
124
  ApplicationContainer serverApps = echoServer.Install (wifiNodes.Get (1));
125
  serverApps.Start (Seconds (1.0));
126
  serverApps.Stop (Seconds (10.0));
127
128
  UdpEchoClientHelper echoClient (wifiNodesInterfaces.GetAddress (1), 9);
129
  echoClient.SetAttribute ("MaxPackets", UintegerValue (3));
130
  echoClient.SetAttribute ("Interval", TimeValue (Seconds (0.000001)));
131
  echoClient.SetAttribute ("PacketSize", UintegerValue (1500));
132
133
  ApplicationContainer clientApps = 
134
    echoClient.Install (wifiNodes.Get (0));
135
  clientApps.Start (Seconds (2.0));
136
  clientApps.Stop (Seconds (10.0));
137
138
  Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
139
140
  Simulator::Stop (Seconds (10.0));
141
142
  phy.EnablePcap ("test-802.11n", 
143
                  wifiNodes.Get (nWifi - 1)->GetId (), 0);
144
145
  Simulator::Run ();
146
  Simulator::Destroy ();
147
148
  return 0;
149
}
(-)a/examples/wireless/wscript (-2 / +2 lines)
 Lines 22-29    Link Here 
22
    obj = bld.create_ns3_program('wifi-wired-bridging', ['internet', 'mobility', 'wifi', 'csma', 'bridge', 'applications'])
22
    obj = bld.create_ns3_program('wifi-wired-bridging', ['internet', 'mobility', 'wifi', 'csma', 'bridge', 'applications'])
23
    obj.source = 'wifi-wired-bridging.cc'
23
    obj.source = 'wifi-wired-bridging.cc'
24
24
25
    obj = bld.create_ns3_program('simple-wifi-frame-aggregation', ['internet', 'mobility', 'wifi', 'applications'])
25
    obj = bld.create_ns3_program('simple-msdu-aggregation', ['internet', 'mobility', 'wifi', 'applications'])
26
    obj.source = 'simple-wifi-frame-aggregation.cc'
26
    obj.source = 'simple-msdu-aggregation.cc'
27
27
28
    obj = bld.create_ns3_program('multirate', ['internet', 'mobility', 'wifi', 'stats', 'flow-monitor', 'olsr', 'applications', 'point-to-point'])
28
    obj = bld.create_ns3_program('multirate', ['internet', 'mobility', 'wifi', 'stats', 'flow-monitor', 'olsr', 'applications', 'point-to-point'])
29
    obj.source = 'multirate.cc'
29
    obj.source = 'multirate.cc'

Return to bug 2050