split examples, add examples, tweak test.py to minimize builds
This commit is contained in:
1
examples/csma/waf
vendored
Executable file
1
examples/csma/waf
vendored
Executable file
@@ -0,0 +1 @@
|
||||
exec "`dirname "$0"`"/../../waf "$@"
|
||||
29
examples/csma/wscript
Normal file
29
examples/csma/wscript
Normal file
@@ -0,0 +1,29 @@
|
||||
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
|
||||
|
||||
def build(bld):
|
||||
obj = bld.create_ns3_program('csma-one-subnet', ['csma', 'internet-stack'])
|
||||
obj.source = 'csma-one-subnet.cc'
|
||||
|
||||
obj = bld.create_ns3_program('csma-bridge', ['bridge', 'csma', 'internet-stack'])
|
||||
obj.source = 'csma-bridge.cc'
|
||||
|
||||
obj = bld.create_ns3_program('csma-bridge-one-hop', ['bridge', 'csma', 'internet-stack'])
|
||||
obj.source = 'csma-bridge-one-hop.cc'
|
||||
|
||||
obj = bld.create_ns3_program('csma-broadcast', ['csma', 'internet-stack'])
|
||||
obj.source = 'csma-broadcast.cc'
|
||||
|
||||
obj = bld.create_ns3_program('csma-packet-socket', ['csma', 'internet-stack'])
|
||||
obj.source = 'csma-packet-socket.cc'
|
||||
|
||||
obj = bld.create_ns3_program('csma-multicast', ['csma', 'internet-stack'])
|
||||
obj.source = 'csma-multicast.cc'
|
||||
|
||||
obj = bld.create_ns3_program('csma-star', ['csma', 'internet-stack'])
|
||||
obj.source = 'csma-star.cc'
|
||||
|
||||
obj = bld.create_ns3_program('csma-raw-ip-socket', ['csma', 'internet-stack'])
|
||||
obj.source = 'csma-raw-ip-socket.cc'
|
||||
|
||||
obj = bld.create_ns3_program('csma-ping', ['csma', 'internet-stack', 'v4ping'])
|
||||
obj.source = 'csma-ping.cc'
|
||||
1
examples/emulation/waf
vendored
Executable file
1
examples/emulation/waf
vendored
Executable file
@@ -0,0 +1 @@
|
||||
exec "`dirname "$0"`"/../../waf "$@"
|
||||
10
examples/emulation/wscript
Normal file
10
examples/emulation/wscript
Normal file
@@ -0,0 +1,10 @@
|
||||
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
|
||||
|
||||
def build(bld):
|
||||
env = bld.env_of_name('default')
|
||||
if env['ENABLE_EMU']:
|
||||
obj = bld.create_ns3_program('emu-udp-echo', ['emu', 'internet-stack'])
|
||||
obj.source = 'emu-udp-echo.cc'
|
||||
|
||||
obj = bld.create_ns3_program('emu-ping', ['emu', 'internet-stack'])
|
||||
obj.source = 'emu-ping.cc'
|
||||
1
examples/error-model/waf
vendored
Executable file
1
examples/error-model/waf
vendored
Executable file
@@ -0,0 +1 @@
|
||||
exec "`dirname "$0"`"/../../waf "$@"
|
||||
5
examples/error-model/wscript
Normal file
5
examples/error-model/wscript
Normal file
@@ -0,0 +1,5 @@
|
||||
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
|
||||
|
||||
def build(bld):
|
||||
obj = bld.create_ns3_program('simple-error-model', ['point-to-point', 'internet-stack'])
|
||||
obj.source = 'simple-error-model.cc'
|
||||
1
examples/flowmon/waf
vendored
Executable file
1
examples/flowmon/waf
vendored
Executable file
@@ -0,0 +1 @@
|
||||
exec "`dirname "$0"`"/../../waf "$@"
|
||||
4
examples/flowmon/wscript
Normal file
4
examples/flowmon/wscript
Normal file
@@ -0,0 +1,4 @@
|
||||
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
|
||||
|
||||
def build(bld):
|
||||
pass
|
||||
1
examples/ipv6/waf
vendored
Executable file
1
examples/ipv6/waf
vendored
Executable file
@@ -0,0 +1 @@
|
||||
exec "`dirname "$0"`"/../../waf "$@"
|
||||
17
examples/ipv6/wscript
Normal file
17
examples/ipv6/wscript
Normal file
@@ -0,0 +1,17 @@
|
||||
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
|
||||
|
||||
def build(bld):
|
||||
obj = bld.create_ns3_program('icmpv6-redirect', ['csma', 'internet-stack'])
|
||||
obj.source = 'icmpv6-redirect.cc'
|
||||
|
||||
obj = bld.create_ns3_program('ping6', ['csma', 'internet-stack'])
|
||||
obj.source = 'ping6.cc'
|
||||
|
||||
obj = bld.create_ns3_program('radvd', ['csma', 'internet-stack'])
|
||||
obj.source = 'radvd.cc'
|
||||
|
||||
obj = bld.create_ns3_program('radvd-two-prefix', ['csma', 'internet-stack'])
|
||||
obj.source = 'radvd-two-prefix.cc'
|
||||
|
||||
obj = bld.create_ns3_program('test-ipv6', ['point-to-point', 'internet-stack'])
|
||||
obj.source = 'test-ipv6.cc'
|
||||
1
examples/mesh/waf
vendored
Executable file
1
examples/mesh/waf
vendored
Executable file
@@ -0,0 +1 @@
|
||||
exec "`dirname "$0"`"/../../waf "$@"
|
||||
5
examples/mesh/wscript
Normal file
5
examples/mesh/wscript
Normal file
@@ -0,0 +1,5 @@
|
||||
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
|
||||
|
||||
def build(bld):
|
||||
obj = bld.create_ns3_program('mesh', ['core', 'simulator', 'mobility', 'wifi', 'mesh'])
|
||||
obj.source = 'mesh.cc'
|
||||
1
examples/naming/waf
vendored
Executable file
1
examples/naming/waf
vendored
Executable file
@@ -0,0 +1 @@
|
||||
exec "`dirname "$0"`"/../../waf "$@"
|
||||
5
examples/naming/wscript
Normal file
5
examples/naming/wscript
Normal file
@@ -0,0 +1,5 @@
|
||||
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
|
||||
|
||||
def build(bld):
|
||||
obj = bld.create_ns3_program('object-names', ['core', 'simulator', 'csma', 'internet-stack'])
|
||||
obj.source = 'object-names.cc'
|
||||
1
examples/realtime/waf
vendored
Executable file
1
examples/realtime/waf
vendored
Executable file
@@ -0,0 +1 @@
|
||||
exec "`dirname "$0"`"/../../waf "$@"
|
||||
5
examples/realtime/wscript
Normal file
5
examples/realtime/wscript
Normal file
@@ -0,0 +1,5 @@
|
||||
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
|
||||
|
||||
def build(bld):
|
||||
obj = bld.create_ns3_program('realtime-udp-echo', ['csma', 'internet-stack'])
|
||||
obj.source = 'realtime-udp-echo.cc'
|
||||
1
examples/routing/waf
vendored
Executable file
1
examples/routing/waf
vendored
Executable file
@@ -0,0 +1 @@
|
||||
exec "`dirname "$0"`"/../../waf "$@"
|
||||
46
examples/routing/wscript
Normal file
46
examples/routing/wscript
Normal file
@@ -0,0 +1,46 @@
|
||||
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
|
||||
|
||||
def build(bld):
|
||||
obj = bld.create_ns3_program('dynamic-global-routing',
|
||||
['point-to-point', 'csma', 'internet-stack', 'global-routing'])
|
||||
obj.source = 'dynamic-global-routing.cc'
|
||||
|
||||
obj = bld.create_ns3_program('static-routing-slash32',
|
||||
['point-to-point', 'internet-stack', 'global-routing'])
|
||||
obj.source = 'static-routing-slash32.cc'
|
||||
|
||||
obj = bld.create_ns3_program('global-routing-slash32',
|
||||
['point-to-point', 'internet-stack', 'global-routing'])
|
||||
obj.source = 'global-routing-slash32.cc'
|
||||
|
||||
obj = bld.create_ns3_program('global-injection-slash32',
|
||||
['point-to-point', 'internet-stack', 'global-routing'])
|
||||
obj.source = 'global-injection-slash32.cc'
|
||||
|
||||
obj = bld.create_ns3_program('simple-global-routing',
|
||||
['point-to-point', 'internet-stack', 'global-routing'])
|
||||
obj.source = 'simple-global-routing.cc'
|
||||
|
||||
obj = bld.create_ns3_program('simple-alternate-routing',
|
||||
['point-to-point', 'internet-stack', 'global-routing'])
|
||||
obj.source = 'simple-alternate-routing.cc'
|
||||
|
||||
obj = bld.create_ns3_program( 'mixed-global-routing',
|
||||
['point-to-point', 'internet-stack', 'global-routing' , 'csma-cd'])
|
||||
obj.source = 'mixed-global-routing.cc'
|
||||
|
||||
obj = bld.create_ns3_program('simple-point-to-point-olsr',
|
||||
['point-to-point', 'internet-stack', 'olsr'])
|
||||
obj.source = 'simple-point-to-point-olsr.cc'
|
||||
|
||||
obj = bld.create_ns3_program('nix-simple',
|
||||
['point-to-point', 'internet-stack', 'nix-vector-routing'])
|
||||
obj.source = 'nix-simple.cc'
|
||||
|
||||
obj = bld.create_ns3_program('nms-p2p-nix',
|
||||
['point-to-point', 'internet-stack', 'nix-vector-routing'])
|
||||
obj.source = 'nms-p2p-nix.cc'
|
||||
|
||||
obj = bld.create_ns3_program('simple-routing-ping6',
|
||||
['csma', 'internet-stack'])
|
||||
obj.source = 'simple-routing-ping6.cc'
|
||||
1
examples/tap/waf
vendored
Executable file
1
examples/tap/waf
vendored
Executable file
@@ -0,0 +1 @@
|
||||
exec "`dirname "$0"`"/../../waf "$@"
|
||||
8
examples/tap/wscript
Normal file
8
examples/tap/wscript
Normal file
@@ -0,0 +1,8 @@
|
||||
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
|
||||
|
||||
def build(bld):
|
||||
env = bld.env_of_name('default')
|
||||
if env['ENABLE_TAP']:
|
||||
obj = bld.create_ns3_program('tap-wifi-dumbbell',
|
||||
['wifi', 'csma', 'point-to-point', 'tap-bridge', 'internet-stack'])
|
||||
obj.source = 'tap-wifi-dumbbell.cc'
|
||||
1
examples/tcp/waf
vendored
Executable file
1
examples/tcp/waf
vendored
Executable file
@@ -0,0 +1 @@
|
||||
exec "`dirname "$0"`"/../../waf "$@"
|
||||
22
examples/tcp/wscript
Normal file
22
examples/tcp/wscript
Normal file
@@ -0,0 +1,22 @@
|
||||
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
|
||||
|
||||
def build(bld):
|
||||
obj = bld.create_ns3_program('tcp-large-transfer',
|
||||
['point-to-point', 'internet-stack'])
|
||||
obj.source = 'tcp-large-transfer.cc'
|
||||
|
||||
obj = bld.create_ns3_program('tcp-nsc-lfn',
|
||||
['point-to-point', 'internet-stack'])
|
||||
obj.source = 'tcp-nsc-lfn.cc'
|
||||
|
||||
obj = bld.create_ns3_program('tcp-nsc-zoo',
|
||||
['csma', 'internet-stack'])
|
||||
obj.source = 'tcp-nsc-zoo.cc'
|
||||
|
||||
obj = bld.create_ns3_program('tcp-star-server',
|
||||
['point-to-point', 'internet-stack'])
|
||||
obj.source = 'tcp-star-server.cc'
|
||||
|
||||
obj = bld.create_ns3_program('star',
|
||||
['point-to-point', 'internet-stack'])
|
||||
obj.source = 'star.cc'
|
||||
1
examples/tunneling/waf
vendored
Executable file
1
examples/tunneling/waf
vendored
Executable file
@@ -0,0 +1 @@
|
||||
exec "`dirname "$0"`"/../../waf "$@"
|
||||
6
examples/tunneling/wscript
Normal file
6
examples/tunneling/wscript
Normal file
@@ -0,0 +1,6 @@
|
||||
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
|
||||
|
||||
def build(bld):
|
||||
obj = bld.create_ns3_program('virtual-net-device', ['point-to-point', 'internet-stack', 'global-routing',
|
||||
'virtual-net-device'])
|
||||
obj.source = 'virtual-net-device.cc'
|
||||
1
examples/tutorial/waf
vendored
Executable file
1
examples/tutorial/waf
vendored
Executable file
@@ -0,0 +1 @@
|
||||
exec "`dirname "$0"`"/../../waf "$@"
|
||||
14
examples/tutorial/wscript
Normal file
14
examples/tutorial/wscript
Normal file
@@ -0,0 +1,14 @@
|
||||
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
|
||||
|
||||
def build(bld):
|
||||
obj = bld.create_ns3_program('hello-simulator')
|
||||
obj.source = 'hello-simulator.cc'
|
||||
|
||||
obj = bld.create_ns3_program('first', ['core', 'simulator', 'point-to-point', 'internet-stack'])
|
||||
obj.source = 'first.cc'
|
||||
|
||||
obj = bld.create_ns3_program('second', ['core', 'simulator', 'point-to-point', 'csma', 'internet-stack'])
|
||||
obj.source = 'second.cc'
|
||||
|
||||
obj = bld.create_ns3_program('third', ['core', 'simulator', 'point-to-point', 'csma', 'wifi', 'internet-stack'])
|
||||
obj.source = 'third.cc'
|
||||
1
examples/udp/waf
vendored
Executable file
1
examples/udp/waf
vendored
Executable file
@@ -0,0 +1 @@
|
||||
exec "`dirname "$0"`"/../../waf "$@"
|
||||
5
examples/udp/wscript
Normal file
5
examples/udp/wscript
Normal file
@@ -0,0 +1,5 @@
|
||||
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
|
||||
|
||||
def build(bld):
|
||||
obj = bld.create_ns3_program('udp-echo', ['csma', 'internet-stack'])
|
||||
obj.source = 'udp-echo.cc'
|
||||
1
examples/wireless/waf
vendored
Executable file
1
examples/wireless/waf
vendored
Executable file
@@ -0,0 +1 @@
|
||||
exec "`dirname "$0"`"/../../waf "$@"
|
||||
239
examples/wireless/wifi-simple-adhoc-grid.cc
Normal file
239
examples/wireless/wifi-simple-adhoc-grid.cc
Normal file
@@ -0,0 +1,239 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2009 University of Washington
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
// This program configures a grid (default 5x5) of nodes on an
|
||||
// 802.11b physical layer, with
|
||||
// 802.11b NICs in adhoc mode, and by default, sends one packet of 1000
|
||||
// (application) bytes to node 1.
|
||||
//
|
||||
// The default layout is like this, on a 2-D grid.
|
||||
//
|
||||
// n20 n21 n22 n23 n24
|
||||
// n15 n16 n17 n18 n19
|
||||
// n10 n11 n12 n13 n14
|
||||
// n5 n6 n7 n8 n9
|
||||
// n0 n1 n2 n3 n4
|
||||
//
|
||||
// the layout is affected by the parameters given to GridPositionAllocator;
|
||||
// by default, GridWidth is 5 and numNodes is 25..
|
||||
//
|
||||
// There are a number of command-line options available to control
|
||||
// the default behavior. The list of available command-line options
|
||||
// can be listed with the following command:
|
||||
// ./waf --run "scratch/wifi-simple-adhoc-grid --help"
|
||||
//
|
||||
// Note that all ns-3 attributes (not just the ones exposed in the below
|
||||
// script) can be changed at command line; see the ns-3 documentation.
|
||||
//
|
||||
// For instance, for this configuration, the physical layer will
|
||||
// stop successfully receiving packets when distance increases beyond
|
||||
// the default of 500m.
|
||||
// To see this effect, try running:
|
||||
//
|
||||
// ./waf --run "scratch/wifi-simple-adhoc --distance=500"
|
||||
// ./waf --run "scratch/wifi-simple-adhoc --distance=1000"
|
||||
// ./waf --run "scratch/wifi-simple-adhoc --distance=1500"
|
||||
//
|
||||
// The source node and sink node can be changed like this:
|
||||
//
|
||||
// ./waf --run "scratch/wifi-simple-adhoc --sourceNode=20 --sinkNode=10"
|
||||
//
|
||||
// This script can also be helpful to put the Wifi layer into verbose
|
||||
// logging mode; this command will turn on all wifi logging:
|
||||
//
|
||||
// ./waf --run "scratch/wifi-simple-adhoc-grid --verbose=1"
|
||||
//
|
||||
// By default, trace file writing is off-- to enable it, try:
|
||||
// ./waf --run "scratch/wifi-simple-adhoc-grid --tracing=1"
|
||||
//
|
||||
// When you are done tracing, you will notice many pcap trace files
|
||||
// in your directory. If you have tcpdump installed, you can try this:
|
||||
//
|
||||
// tcpdump -r wifi-simple-adhoc-grid-0-0.pcap -nn -tt
|
||||
//
|
||||
|
||||
#include "ns3/core-module.h"
|
||||
#include "ns3/common-module.h"
|
||||
#include "ns3/node-module.h"
|
||||
#include "ns3/helper-module.h"
|
||||
#include "ns3/mobility-module.h"
|
||||
#include "ns3/contrib-module.h"
|
||||
#include "ns3/wifi-module.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("WifiSimpleAdhocGrid");
|
||||
|
||||
using namespace ns3;
|
||||
|
||||
void ReceivePacket (Ptr<Socket> socket)
|
||||
{
|
||||
NS_LOG_UNCOND ("Received one packet!");
|
||||
}
|
||||
|
||||
static void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize,
|
||||
uint32_t pktCount, Time pktInterval )
|
||||
{
|
||||
if (pktCount > 0)
|
||||
{
|
||||
socket->Send (Create<Packet> (pktSize));
|
||||
Simulator::Schedule (pktInterval, &GenerateTraffic,
|
||||
socket, pktSize,pktCount-1, pktInterval);
|
||||
}
|
||||
else
|
||||
{
|
||||
socket->Close ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
std::string phyMode ("wifib-1mbs");
|
||||
double distance = 500; // m
|
||||
uint32_t packetSize = 1000; // bytes
|
||||
uint32_t numPackets = 1;
|
||||
uint32_t numNodes = 25; // by default, 5x5
|
||||
uint32_t sinkNode = 0;
|
||||
uint32_t sourceNode = 24;
|
||||
double interval = 1.0; // seconds
|
||||
bool verbose = false;
|
||||
bool tracing = false;
|
||||
|
||||
CommandLine cmd;
|
||||
|
||||
cmd.AddValue ("phyMode", "Wifi Phy mode", phyMode);
|
||||
cmd.AddValue ("distance", "distance (m)", distance);
|
||||
cmd.AddValue ("packetSize", "size of application packet sent", packetSize);
|
||||
cmd.AddValue ("numPackets", "number of packets generated", numPackets);
|
||||
cmd.AddValue ("interval", "interval (seconds) between packets", interval);
|
||||
cmd.AddValue ("verbose", "turn on all WifiNetDevice log components", verbose);
|
||||
cmd.AddValue ("tracing", "turn on ascii and pcap tracing", tracing);
|
||||
cmd.AddValue ("numNodes", "number of nodes", numNodes);
|
||||
cmd.AddValue ("sinkNode", "Receiver node number", sinkNode);
|
||||
cmd.AddValue ("sourceNode", "Sender node number", sourceNode);
|
||||
|
||||
cmd.Parse (argc, argv);
|
||||
// Convert to time object
|
||||
Time interPacketInterval = Seconds (interval);
|
||||
|
||||
// disable fragmentation for frames below 2200 bytes
|
||||
Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2200"));
|
||||
// turn off RTS/CTS for frames below 2200 bytes
|
||||
Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2200"));
|
||||
// Fix non-unicast data rate to be the same as that of unicast
|
||||
Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",
|
||||
StringValue (phyMode));
|
||||
|
||||
NodeContainer c;
|
||||
c.Create (numNodes);
|
||||
|
||||
// The below set of helpers will help us to put together the wifi NICs we want
|
||||
WifiHelper wifi;
|
||||
if (verbose)
|
||||
{
|
||||
wifi.EnableLogComponents (); // Turn on all Wifi logging
|
||||
}
|
||||
|
||||
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
|
||||
// This is one parameter that matters when using FixedRssLossModel
|
||||
// set it to zero; otherwise, gain will be added
|
||||
wifiPhy.Set ("RxGain", DoubleValue (-10) );
|
||||
// ns-3 support RadioTap and Prism tracing extensions for 802.11b
|
||||
wifiPhy.SetPcapFormat (YansWifiPhyHelper::PCAP_FORMAT_80211_RADIOTAP);
|
||||
|
||||
YansWifiChannelHelper wifiChannel ;
|
||||
wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
|
||||
wifiChannel.AddPropagationLoss ("ns3::FriisPropagationLossModel");
|
||||
wifiPhy.SetChannel (wifiChannel.Create ());
|
||||
|
||||
// Add a non-QoS upper mac, and disable rate control
|
||||
NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
|
||||
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
|
||||
"DataMode",StringValue(phyMode),
|
||||
"ControlMode",StringValue(phyMode));
|
||||
// Set it to adhoc mode
|
||||
wifiMac.SetType ("ns3::AdhocWifiMac");
|
||||
NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c);
|
||||
|
||||
MobilityHelper mobility;
|
||||
mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
|
||||
"MinX", DoubleValue (0.0),
|
||||
"MinY", DoubleValue (0.0),
|
||||
"DeltaX", DoubleValue (distance),
|
||||
"DeltaY", DoubleValue (distance),
|
||||
"GridWidth", UintegerValue (5),
|
||||
"LayoutType", StringValue ("RowFirst"));
|
||||
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
|
||||
mobility.Install (c);
|
||||
|
||||
// Enable OLSR
|
||||
OlsrHelper olsr;
|
||||
Ipv4StaticRoutingHelper staticRouting;
|
||||
|
||||
Ipv4ListRoutingHelper list;
|
||||
list.Add (staticRouting, 0);
|
||||
list.Add (olsr, 10);
|
||||
|
||||
InternetStackHelper internet;
|
||||
internet.SetRoutingHelper (list);
|
||||
internet.Install (c);
|
||||
|
||||
Ipv4AddressHelper ipv4;
|
||||
NS_LOG_INFO ("Assign IP Addresses.");
|
||||
ipv4.SetBase ("10.1.1.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer i = ipv4.Assign (devices);
|
||||
|
||||
TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory");
|
||||
Ptr<Socket> recvSink = Socket::CreateSocket (c.Get (0), tid);
|
||||
InetSocketAddress local = InetSocketAddress (Ipv4Address::GetAny (), 80);
|
||||
recvSink->Bind (local);
|
||||
recvSink->SetRecvCallback (MakeCallback (&ReceivePacket));
|
||||
|
||||
Ptr<Socket> source = Socket::CreateSocket (c.Get (sourceNode), tid);
|
||||
InetSocketAddress remote = InetSocketAddress (i.GetAddress (sinkNode, 0), 80);
|
||||
source->Connect (remote);
|
||||
|
||||
if (tracing == true)
|
||||
{
|
||||
wifiPhy.EnablePcap ("wifi-simple-adhoc-grid", devices);
|
||||
std::ofstream ascii;
|
||||
ascii.open ("wifi-simple-adhoc-grid.tr");
|
||||
YansWifiPhyHelper::EnableAsciiAll (ascii);
|
||||
// To do-- enable an IP-level trace that shows forwarding events only
|
||||
}
|
||||
|
||||
// Give OLSR time to converge-- 30 seconds perhaps
|
||||
Simulator::Schedule (Seconds (30.0), &GenerateTraffic,
|
||||
source, packetSize, numPackets, interPacketInterval);
|
||||
|
||||
// Output what we are doing
|
||||
NS_LOG_UNCOND ("Testing from node " << sourceNode << " to " << sinkNode << " with grid distance " << distance);
|
||||
|
||||
Simulator::Stop (Seconds (32.0));
|
||||
Simulator::Run ();
|
||||
Simulator::Destroy ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
198
examples/wireless/wifi-simple-adhoc.cc
Normal file
198
examples/wireless/wifi-simple-adhoc.cc
Normal file
@@ -0,0 +1,198 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2009 The Boeing Company
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
// This script configures two nodes on an 802.11b physical layer, with
|
||||
// 802.11b NICs in adhoc mode, and by default, sends one packet of 1000
|
||||
// (application) bytes to the other node. The physical layer is configured
|
||||
// to receive at a fixed RSS (regardless of the distance and transmit
|
||||
// power); therefore, changing position of the nodes has no effect.
|
||||
//
|
||||
// There are a number of command-line options available to control
|
||||
// the default behavior. The list of available command-line options
|
||||
// can be listed with the following command:
|
||||
// ./waf --run "scratch/wifi-simple-adhoc --help"
|
||||
//
|
||||
// For instance, for this configuration, the physical layer will
|
||||
// stop successfully receiving packets when rss drops below -97 dBm.
|
||||
// To see this effect, try running:
|
||||
//
|
||||
// ./waf --run "scratch/wifi-simple-adhoc --rss=-97 --numPackets=20"
|
||||
// ./waf --run "scratch/wifi-simple-adhoc --rss=-98 --numPackets=20"
|
||||
// ./waf --run "scratch/wifi-simple-adhoc --rss=-99 --numPackets=20"
|
||||
//
|
||||
// Note that all ns-3 attributes (not just the ones exposed in the below
|
||||
// script) can be changed at command line; see the documentation.
|
||||
//
|
||||
// This script can also be helpful to put the Wifi layer into verbose
|
||||
// logging mode; this command will turn on all wifi logging:
|
||||
//
|
||||
// ./waf --run "scratch/wifi-simple-adhoc --verbose=1"
|
||||
//
|
||||
// When you are done, you will notice two pcap trace files in your directory.
|
||||
// If you have tcpdump installed, you can try this:
|
||||
//
|
||||
// tcpdump -r wifi-simple-adhoc-0-0.pcap -nn -tt
|
||||
//
|
||||
|
||||
#include "ns3/core-module.h"
|
||||
#include "ns3/common-module.h"
|
||||
#include "ns3/node-module.h"
|
||||
#include "ns3/helper-module.h"
|
||||
#include "ns3/mobility-module.h"
|
||||
#include "ns3/contrib-module.h"
|
||||
#include "ns3/wifi-module.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("WifiSimpleAdhoc");
|
||||
|
||||
using namespace ns3;
|
||||
|
||||
void ReceivePacket (Ptr<Socket> socket)
|
||||
{
|
||||
NS_LOG_UNCOND ("Received one packet!");
|
||||
}
|
||||
|
||||
static void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize,
|
||||
uint32_t pktCount, Time pktInterval )
|
||||
{
|
||||
if (pktCount > 0)
|
||||
{
|
||||
socket->Send (Create<Packet> (pktSize));
|
||||
Simulator::Schedule (pktInterval, &GenerateTraffic,
|
||||
socket, pktSize,pktCount-1, pktInterval);
|
||||
}
|
||||
else
|
||||
{
|
||||
socket->Close ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
std::string phyMode ("wifib-1mbs");
|
||||
double rss = -80; // -dBm
|
||||
uint32_t packetSize = 1000; // bytes
|
||||
uint32_t numPackets = 1;
|
||||
double interval = 1.0; // seconds
|
||||
bool verbose = false;
|
||||
|
||||
CommandLine cmd;
|
||||
|
||||
cmd.AddValue ("phyMode", "Wifi Phy mode", phyMode);
|
||||
cmd.AddValue ("rss", "received signal strength", rss);
|
||||
cmd.AddValue ("packetSize", "size of application packet sent", packetSize);
|
||||
cmd.AddValue ("numPackets", "number of packets generated", numPackets);
|
||||
cmd.AddValue ("interval", "interval (seconds) between packets", interval);
|
||||
cmd.AddValue ("verbose", "turn on all WifiNetDevice log components", verbose);
|
||||
|
||||
cmd.Parse (argc, argv);
|
||||
// Convert to time object
|
||||
Time interPacketInterval = Seconds (interval);
|
||||
|
||||
// disable fragmentation for frames below 2200 bytes
|
||||
Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2200"));
|
||||
// turn off RTS/CTS for frames below 2200 bytes
|
||||
Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2200"));
|
||||
// Fix non-unicast data rate to be the same as that of unicast
|
||||
Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",
|
||||
StringValue (phyMode));
|
||||
|
||||
NodeContainer c;
|
||||
c.Create (2);
|
||||
|
||||
// The below set of helpers will help us to put together the wifi NICs we want
|
||||
WifiHelper wifi;
|
||||
if (verbose)
|
||||
{
|
||||
wifi.EnableLogComponents (); // Turn on all Wifi logging
|
||||
}
|
||||
wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
|
||||
|
||||
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
|
||||
// This is one parameter that matters when using FixedRssLossModel
|
||||
// set it to zero; otherwise, gain will be added
|
||||
wifiPhy.Set ("RxGain", DoubleValue (0) );
|
||||
// ns-3 support RadioTap and Prism tracing extensions for 802.11b
|
||||
wifiPhy.SetPcapFormat (YansWifiPhyHelper::PCAP_FORMAT_80211_RADIOTAP);
|
||||
|
||||
YansWifiChannelHelper wifiChannel ;
|
||||
wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
|
||||
// The below FixedRssLossModel will cause the rss to be fixed regardless
|
||||
// of the distance between the two stations, and the transmit power
|
||||
wifiChannel.AddPropagationLoss ("ns3::FixedRssLossModel","Rss",DoubleValue(rss));
|
||||
wifiPhy.SetChannel (wifiChannel.Create ());
|
||||
|
||||
// Add a non-QoS upper mac, and disable rate control
|
||||
NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
|
||||
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
|
||||
"DataMode",StringValue(phyMode),
|
||||
"ControlMode",StringValue(phyMode));
|
||||
// Set it to adhoc mode
|
||||
wifiMac.SetType ("ns3::AdhocWifiMac");
|
||||
NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c);
|
||||
|
||||
// Note that with FixedRssLossModel, the positions below are not
|
||||
// used for received signal strength.
|
||||
MobilityHelper mobility;
|
||||
Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
|
||||
positionAlloc->Add (Vector (0.0, 0.0, 0.0));
|
||||
positionAlloc->Add (Vector (5.0, 0.0, 0.0));
|
||||
mobility.SetPositionAllocator (positionAlloc);
|
||||
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
|
||||
mobility.Install (c);
|
||||
|
||||
InternetStackHelper internet;
|
||||
internet.Install (c);
|
||||
|
||||
Ipv4AddressHelper ipv4;
|
||||
NS_LOG_INFO ("Assign IP Addresses.");
|
||||
ipv4.SetBase ("10.1.1.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer i = ipv4.Assign (devices);
|
||||
|
||||
TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory");
|
||||
Ptr<Socket> recvSink = Socket::CreateSocket (c.Get (0), tid);
|
||||
InetSocketAddress local = InetSocketAddress (Ipv4Address::GetAny (), 80);
|
||||
recvSink->Bind (local);
|
||||
recvSink->SetRecvCallback (MakeCallback (&ReceivePacket));
|
||||
|
||||
Ptr<Socket> source = Socket::CreateSocket (c.Get (1), tid);
|
||||
InetSocketAddress remote = InetSocketAddress (Ipv4Address ("255.255.255.255"), 80);
|
||||
source->Connect (remote);
|
||||
|
||||
// Tracing
|
||||
wifiPhy.EnablePcap ("wifi-simple-adhoc", devices);
|
||||
|
||||
// Output what we are doing
|
||||
NS_LOG_UNCOND ("Testing " << numPackets << " packets sent with receiver rss " << rss );
|
||||
|
||||
Simulator::Schedule (Seconds (1.0), &GenerateTraffic,
|
||||
source, packetSize, numPackets, interPacketInterval);
|
||||
|
||||
Simulator::Run ();
|
||||
Simulator::Destroy ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
212
examples/wireless/wifi-simple-infra.cc
Normal file
212
examples/wireless/wifi-simple-infra.cc
Normal file
@@ -0,0 +1,212 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2009 The Boeing Company
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
// This script configures two nodes on an 802.11b physical layer, with
|
||||
// 802.11b NICs in infrastructure mode, and by default, the station sends
|
||||
// one packet of 1000 (application) bytes to the access point. The
|
||||
// physical layer is configured
|
||||
// to receive at a fixed RSS (regardless of the distance and transmit
|
||||
// power); therefore, changing position of the nodes has no effect.
|
||||
//
|
||||
// There are a number of command-line options available to control
|
||||
// the default behavior. The list of available command-line options
|
||||
// can be listed with the following command:
|
||||
// ./waf --run "scratch/wifi-simple-infra --help"
|
||||
//
|
||||
// For instance, for this configuration, the physical layer will
|
||||
// stop successfully receiving packets when rss drops below -97 dBm.
|
||||
// To see this effect, try running:
|
||||
//
|
||||
// ./waf --run "scratch/wifi-simple-infra --rss=-97 --numPackets=20"
|
||||
// ./waf --run "scratch/wifi-simple-infra --rss=-98 --numPackets=20"
|
||||
// ./waf --run "scratch/wifi-simple-infra --rss=-99 --numPackets=20"
|
||||
//
|
||||
// Note that all ns-3 attributes (not just the ones exposed in the below
|
||||
// script) can be changed at command line; see the documentation.
|
||||
//
|
||||
// This script can also be helpful to put the Wifi layer into verbose
|
||||
// logging mode; this command will turn on all wifi logging:
|
||||
//
|
||||
// ./waf --run "scratch/wifi-simple-infra --verbose=1"
|
||||
//
|
||||
// When you are done, you will notice two pcap trace files in your directory.
|
||||
// If you have tcpdump installed, you can try this:
|
||||
//
|
||||
// tcpdump -r wifi-simple-infra-0-0.pcap -nn -tt
|
||||
//
|
||||
|
||||
#include "ns3/core-module.h"
|
||||
#include "ns3/common-module.h"
|
||||
#include "ns3/node-module.h"
|
||||
#include "ns3/helper-module.h"
|
||||
#include "ns3/mobility-module.h"
|
||||
#include "ns3/contrib-module.h"
|
||||
#include "ns3/wifi-module.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("WifiSimpleInfra");
|
||||
|
||||
using namespace ns3;
|
||||
|
||||
void ReceivePacket (Ptr<Socket> socket)
|
||||
{
|
||||
NS_LOG_UNCOND ("Received one packet!");
|
||||
}
|
||||
|
||||
static void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize,
|
||||
uint32_t pktCount, Time pktInterval )
|
||||
{
|
||||
if (pktCount > 0)
|
||||
{
|
||||
socket->Send (Create<Packet> (pktSize));
|
||||
Simulator::Schedule (pktInterval, &GenerateTraffic,
|
||||
socket, pktSize,pktCount-1, pktInterval);
|
||||
}
|
||||
else
|
||||
{
|
||||
socket->Close ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
std::string phyMode ("wifib-1mbs");
|
||||
double rss = -80; // -dBm
|
||||
uint32_t packetSize = 1000; // bytes
|
||||
uint32_t numPackets = 1;
|
||||
double interval = 1.0; // seconds
|
||||
bool verbose = false;
|
||||
|
||||
CommandLine cmd;
|
||||
|
||||
cmd.AddValue ("phyMode", "Wifi Phy mode", phyMode);
|
||||
cmd.AddValue ("rss", "received signal strength", rss);
|
||||
cmd.AddValue ("packetSize", "size of application packet sent", packetSize);
|
||||
cmd.AddValue ("numPackets", "number of packets generated", numPackets);
|
||||
cmd.AddValue ("interval", "interval (seconds) between packets", interval);
|
||||
cmd.AddValue ("verbose", "turn on all WifiNetDevice log components", verbose);
|
||||
|
||||
cmd.Parse (argc, argv);
|
||||
// Convert to time object
|
||||
Time interPacketInterval = Seconds (interval);
|
||||
|
||||
// disable fragmentation for frames below 2200 bytes
|
||||
Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2200"));
|
||||
// turn off RTS/CTS for frames below 2200 bytes
|
||||
Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2200"));
|
||||
// Fix non-unicast data rate to be the same as that of unicast
|
||||
Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",
|
||||
StringValue (phyMode));
|
||||
|
||||
NodeContainer c;
|
||||
c.Create (2);
|
||||
|
||||
// The below set of helpers will help us to put together the wifi NICs we want
|
||||
WifiHelper wifi;
|
||||
if (verbose)
|
||||
{
|
||||
wifi.EnableLogComponents (); // Turn on all Wifi logging
|
||||
}
|
||||
wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
|
||||
|
||||
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
|
||||
// This is one parameter that matters when using FixedRssLossModel
|
||||
// set it to zero; otherwise, gain will be added
|
||||
wifiPhy.Set ("RxGain", DoubleValue (0) );
|
||||
// ns-3 support RadioTap and Prism tracing extensions for 802.11b
|
||||
wifiPhy.SetPcapFormat (YansWifiPhyHelper::PCAP_FORMAT_80211_RADIOTAP);
|
||||
|
||||
YansWifiChannelHelper wifiChannel ;
|
||||
wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
|
||||
// The below FixedRssLossModel will cause the rss to be fixed regardless
|
||||
// of the distance between the two stations, and the transmit power
|
||||
wifiChannel.AddPropagationLoss ("ns3::FixedRssLossModel","Rss",DoubleValue(rss));
|
||||
wifiPhy.SetChannel (wifiChannel.Create ());
|
||||
|
||||
// Add a non-QoS upper mac, and disable rate control
|
||||
NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
|
||||
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
|
||||
"DataMode",StringValue(phyMode),
|
||||
"ControlMode",StringValue(phyMode));
|
||||
|
||||
// Setup the rest of the upper mac
|
||||
Ssid ssid = Ssid ("wifi-default");
|
||||
// setup sta.
|
||||
wifiMac.SetType ("ns3::NqstaWifiMac",
|
||||
"Ssid", SsidValue (ssid),
|
||||
"ActiveProbing", BooleanValue (false));
|
||||
NetDeviceContainer staDevice = wifi.Install (wifiPhy, wifiMac, c.Get(0));
|
||||
NetDeviceContainer devices = staDevice;
|
||||
// setup ap.
|
||||
wifiMac.SetType ("ns3::NqapWifiMac", "Ssid", SsidValue (ssid),
|
||||
"BeaconGeneration", BooleanValue (true),
|
||||
"BeaconInterval", TimeValue (Seconds (2.5)));
|
||||
NetDeviceContainer apDevice = wifi.Install (wifiPhy, wifiMac, c.Get(1));
|
||||
devices.Add (apDevice);
|
||||
|
||||
// Note that with FixedRssLossModel, the positions below are not
|
||||
// used for received signal strength.
|
||||
MobilityHelper mobility;
|
||||
Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
|
||||
positionAlloc->Add (Vector (0.0, 0.0, 0.0));
|
||||
positionAlloc->Add (Vector (5.0, 0.0, 0.0));
|
||||
mobility.SetPositionAllocator (positionAlloc);
|
||||
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
|
||||
mobility.Install (c);
|
||||
|
||||
InternetStackHelper internet;
|
||||
internet.Install (c);
|
||||
|
||||
Ipv4AddressHelper ipv4;
|
||||
NS_LOG_INFO ("Assign IP Addresses.");
|
||||
ipv4.SetBase ("10.1.1.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer i = ipv4.Assign (devices);
|
||||
|
||||
TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory");
|
||||
Ptr<Socket> recvSink = Socket::CreateSocket (c.Get (0), tid);
|
||||
InetSocketAddress local = InetSocketAddress (Ipv4Address::GetAny (), 80);
|
||||
recvSink->Bind (local);
|
||||
recvSink->SetRecvCallback (MakeCallback (&ReceivePacket));
|
||||
|
||||
Ptr<Socket> source = Socket::CreateSocket (c.Get (1), tid);
|
||||
InetSocketAddress remote = InetSocketAddress (Ipv4Address ("255.255.255.255"), 80);
|
||||
source->Connect (remote);
|
||||
|
||||
// Tracing
|
||||
wifiPhy.EnablePcap ("wifi-simple-infra", devices);
|
||||
|
||||
// Output what we are doing
|
||||
NS_LOG_UNCOND ("Testing " << numPackets << " packets sent with receiver rss " << rss );
|
||||
|
||||
Simulator::Schedule (Seconds (1.0), &GenerateTraffic,
|
||||
source, packetSize, numPackets, interPacketInterval);
|
||||
|
||||
Simulator::Stop (Seconds (30.0));
|
||||
Simulator::Run ();
|
||||
Simulator::Destroy ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
259
examples/wireless/wifi-simple-interference.cc
Normal file
259
examples/wireless/wifi-simple-interference.cc
Normal file
@@ -0,0 +1,259 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2009 The Boeing Company
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
//
|
||||
// This script configures three nodes on an 802.11b physical layer, with
|
||||
// 802.11b NICs in adhoc mode. There is a transmitter, receiver, and
|
||||
// interferer. The transmitter sends one packet to the receiver and
|
||||
// the receiver receives it with a certain configurable RSS (by default,
|
||||
// -80 dBm). The interferer does not do carrier sense and also sends
|
||||
// the packet to interfere with the primary packet. The channel model
|
||||
// is clear channel.
|
||||
//
|
||||
// Therefore, at the receiver, the reception looks like this:
|
||||
//
|
||||
// ------------------time---------------->
|
||||
// t0
|
||||
//
|
||||
// |------------------------------------|
|
||||
// | |
|
||||
// | primary received frame (time t0) |
|
||||
// | |
|
||||
// |------------------------------------|
|
||||
//
|
||||
//
|
||||
// t1
|
||||
// |-----------------------------------|
|
||||
// | |
|
||||
// | interfering frame (time t1) |
|
||||
// | |
|
||||
// |-----------------------------------|
|
||||
//
|
||||
// The orientation is:
|
||||
// n2 ---------> n0 <---------- n1
|
||||
// interferer receiver transmitter
|
||||
//
|
||||
// The configurable parameters are:
|
||||
// - Prss (primary rss) (-80 dBm default)
|
||||
// - Irss (interfering rss) (-95 dBm default)
|
||||
// - delta (microseconds, (t1-t0), may be negative, default 0)
|
||||
// - PpacketSize (primary packet size) (bytes, default 1000)
|
||||
// - IpacketSize (interferer packet size) (bytes, default 1000)
|
||||
//
|
||||
// For instance, for this configuration, the interfering frame arrives
|
||||
// at -90 dBm with a time offset of 3.2 microseconds:
|
||||
//
|
||||
// ./waf --run "scratch/wifi-simple-interference --Irss=-90 --delta=3.2"
|
||||
//
|
||||
// Note that all ns-3 attributes (not just the ones exposed in the below
|
||||
// script) can be changed at command line; see the documentation.
|
||||
//
|
||||
// This script can also be helpful to put the Wifi layer into verbose
|
||||
// logging mode; this command will turn on all wifi logging:
|
||||
//
|
||||
// ./waf --run "scratch/wifi-simple-interference --verbose=1"
|
||||
//
|
||||
// When you are done, you will notice a pcap trace file in your directory.
|
||||
// If you have tcpdump installed, you can try this:
|
||||
//
|
||||
// tcpdump -r wifi-simple-interference-0-0.pcap -nn -tt
|
||||
// reading from file wifi-simple-interference-0-0.pcap, link-type IEEE802_11_RADIO (802.11 plus BSD radio information header)
|
||||
// 10.008704 10008704us tsft 1.0 Mb/s 2437 MHz (0x00c0) -80dB signal -98dB noise IP 10.1.1.2.49153 > 10.1.1.255.80: UDP, length 1000
|
||||
//
|
||||
// Next, try this command and look at the tcpdump-- you should see two packets
|
||||
// that are no longer interfering:
|
||||
// ./waf --run "wifi-simple-interference --delta=30000"
|
||||
|
||||
#include "ns3/core-module.h"
|
||||
#include "ns3/common-module.h"
|
||||
#include "ns3/node-module.h"
|
||||
#include "ns3/helper-module.h"
|
||||
#include "ns3/mobility-module.h"
|
||||
#include "ns3/contrib-module.h"
|
||||
#include "ns3/wifi-module.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("WifiSimpleInterference");
|
||||
|
||||
using namespace ns3;
|
||||
|
||||
void ReceivePacket (Ptr<Socket> socket)
|
||||
{
|
||||
Address addr;
|
||||
socket->GetSockName (addr);
|
||||
InetSocketAddress iaddr = InetSocketAddress::ConvertFrom (addr);
|
||||
NS_LOG_UNCOND ("Received one packet! Socket: " << iaddr.GetIpv4 () << " port: " << iaddr.GetPort ());
|
||||
}
|
||||
|
||||
static void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize,
|
||||
uint32_t pktCount, Time pktInterval )
|
||||
{
|
||||
if (pktCount > 0)
|
||||
{
|
||||
socket->Send (Create<Packet> (pktSize));
|
||||
Simulator::Schedule (pktInterval, &GenerateTraffic,
|
||||
socket, pktSize,pktCount-1, pktInterval);
|
||||
}
|
||||
else
|
||||
{
|
||||
socket->Close ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
// LogComponentEnable ("InterferenceHelper", LOG_LEVEL_ALL);
|
||||
|
||||
std::string phyMode ("wifib-1mbs");
|
||||
double Prss = -80; // -dBm
|
||||
double Irss = -95; // -dBm
|
||||
double delta = 0; // microseconds
|
||||
uint32_t PpacketSize = 1000; // bytes
|
||||
uint32_t IpacketSize = 1000; // bytes
|
||||
bool verbose = false;
|
||||
|
||||
// these are not command line arguments for this version
|
||||
uint32_t numPackets = 1;
|
||||
double interval = 1.0; // seconds
|
||||
double startTime = 10.0; // seconds
|
||||
double distanceToRx = 100.0; // meters
|
||||
|
||||
double offset = 91; // This is a magic number used to set the
|
||||
// transmit power, based on other configuration
|
||||
CommandLine cmd;
|
||||
|
||||
cmd.AddValue ("phyMode", "Wifi Phy mode", phyMode);
|
||||
cmd.AddValue ("Prss", "Intended primary received signal strength (dBm)", Prss);
|
||||
cmd.AddValue ("Irss", "Intended interfering received signal strength (dBm)", Irss);
|
||||
cmd.AddValue ("delta", "time offset (microseconds) for interfering signal", delta);
|
||||
cmd.AddValue ("PpacketSize", "size of application packet sent", PpacketSize);
|
||||
cmd.AddValue ("IpacketSize", "size of interfering packet sent", IpacketSize);
|
||||
cmd.AddValue ("verbose", "turn on all WifiNetDevice log components", verbose);
|
||||
|
||||
cmd.Parse (argc, argv);
|
||||
// Convert to time object
|
||||
Time interPacketInterval = Seconds (interval);
|
||||
|
||||
// disable fragmentation for frames below 2200 bytes
|
||||
Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2200"));
|
||||
// turn off RTS/CTS for frames below 2200 bytes
|
||||
Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("2200"));
|
||||
// Fix non-unicast data rate to be the same as that of unicast
|
||||
Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",
|
||||
StringValue (phyMode));
|
||||
|
||||
NodeContainer c;
|
||||
c.Create (3);
|
||||
|
||||
// The below set of helpers will help us to put together the wifi NICs we want
|
||||
WifiHelper wifi;
|
||||
if (verbose)
|
||||
{
|
||||
wifi.EnableLogComponents (); // Turn on all Wifi logging
|
||||
}
|
||||
wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
|
||||
|
||||
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
|
||||
// This is one parameter that matters when using FixedRssLossModel
|
||||
// set it to zero; otherwise, gain will be added
|
||||
wifiPhy.Set ("RxGain", DoubleValue (0) );
|
||||
wifiPhy.Set ("CcaMode1Threshold", DoubleValue (0.0) );
|
||||
|
||||
// ns-3 support RadioTap and Prism tracing extensions for 802.11b
|
||||
wifiPhy.SetPcapFormat (YansWifiPhyHelper::PCAP_FORMAT_80211_RADIOTAP);
|
||||
|
||||
YansWifiChannelHelper wifiChannel ;
|
||||
wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
|
||||
wifiChannel.AddPropagationLoss ("ns3::LogDistancePropagationLossModel");
|
||||
wifiPhy.SetChannel (wifiChannel.Create ());
|
||||
|
||||
// Add a non-QoS upper mac, and disable rate control
|
||||
NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
|
||||
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
|
||||
"DataMode",StringValue(phyMode),
|
||||
"ControlMode",StringValue(phyMode));
|
||||
// Set it to adhoc mode
|
||||
wifiMac.SetType ("ns3::AdhocWifiMac");
|
||||
NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c.Get (0));
|
||||
// This will disable these sending devices from detecting a signal
|
||||
// so that they do not backoff
|
||||
wifiPhy.Set ("EnergyDetectionThreshold", DoubleValue (0.0) );
|
||||
wifiPhy.Set ("TxGain", DoubleValue (offset + Prss) );
|
||||
devices.Add (wifi.Install (wifiPhy, wifiMac, c.Get (1)));
|
||||
wifiPhy.Set ("TxGain", DoubleValue (offset + Irss) );
|
||||
devices.Add (wifi.Install (wifiPhy, wifiMac, c.Get (2)));
|
||||
|
||||
// Note that with FixedRssLossModel, the positions below are not
|
||||
// used for received signal strength.
|
||||
MobilityHelper mobility;
|
||||
Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
|
||||
positionAlloc->Add (Vector (0.0, 0.0, 0.0));
|
||||
positionAlloc->Add (Vector (distanceToRx, 0.0, 0.0));
|
||||
positionAlloc->Add (Vector (-1*distanceToRx, 0.0, 0.0));
|
||||
mobility.SetPositionAllocator (positionAlloc);
|
||||
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
|
||||
mobility.Install (c);
|
||||
|
||||
InternetStackHelper internet;
|
||||
internet.Install (c);
|
||||
|
||||
Ipv4AddressHelper ipv4;
|
||||
NS_LOG_INFO ("Assign IP Addresses.");
|
||||
ipv4.SetBase ("10.1.1.0", "255.255.255.0");
|
||||
Ipv4InterfaceContainer i = ipv4.Assign (devices);
|
||||
|
||||
TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory");
|
||||
Ptr<Socket> recvSink = Socket::CreateSocket (c.Get (0), tid);
|
||||
InetSocketAddress local = InetSocketAddress (Ipv4Address("10.1.1.1"), 80);
|
||||
recvSink->Bind (local);
|
||||
recvSink->SetRecvCallback (MakeCallback (&ReceivePacket));
|
||||
|
||||
Ptr<Socket> source = Socket::CreateSocket (c.Get (1), tid);
|
||||
InetSocketAddress remote = InetSocketAddress (Ipv4Address ("255.255.255.255"), 80);
|
||||
source->Connect (remote);
|
||||
|
||||
// Interferer will send to a different port; we will not see a
|
||||
// "Received packet" message
|
||||
Ptr<Socket> interferer = Socket::CreateSocket (c.Get (2), tid);
|
||||
InetSocketAddress interferingAddr = InetSocketAddress (Ipv4Address ("255.255.255.255"), 49000);
|
||||
interferer->Connect (interferingAddr);
|
||||
|
||||
// Tracing
|
||||
wifiPhy.EnablePcap ("wifi-simple-interference", devices.Get (0));
|
||||
|
||||
// Output what we are doing
|
||||
NS_LOG_UNCOND ("Primary packet RSS=" << Prss << " dBm and interferer RSS=" << Irss << " dBm at time offset=" << delta << " ms");
|
||||
|
||||
Simulator::Schedule (Seconds (startTime), &GenerateTraffic,
|
||||
source, PpacketSize, numPackets, interPacketInterval);
|
||||
|
||||
Simulator::Schedule (Seconds (startTime + delta/1000000.0), &GenerateTraffic,
|
||||
interferer, IpacketSize, numPackets, interPacketInterval);
|
||||
|
||||
Simulator::Run ();
|
||||
Simulator::Destroy ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
36
examples/wireless/wscript
Normal file
36
examples/wireless/wscript
Normal file
@@ -0,0 +1,36 @@
|
||||
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
|
||||
|
||||
def build(bld):
|
||||
obj = bld.create_ns3_program('mixed-wireless', ['core', 'simulator', 'mobility', 'wifi', 'point-to-point',
|
||||
'internet-stack'])
|
||||
obj.source = 'mixed-wireless.cc'
|
||||
|
||||
obj = bld.create_ns3_program('wifi-adhoc', ['core', 'simulator', 'mobility', 'wifi'])
|
||||
obj.source = 'wifi-adhoc.cc'
|
||||
|
||||
obj = bld.create_ns3_program('wifi-clear-channel-cmu', ['core', 'simulator', 'mobility', 'wifi'])
|
||||
obj.source = 'wifi-clear-channel-cmu.cc'
|
||||
|
||||
obj = bld.create_ns3_program('wifi-ap', ['core', 'simulator', 'mobility', 'wifi'])
|
||||
obj.source = 'wifi-ap.cc'
|
||||
|
||||
obj = bld.create_ns3_program('wifi-wired-bridging', ['core', 'simulator', 'mobility', 'wifi', 'csma', 'helper', 'bridge'])
|
||||
obj.source = 'wifi-wired-bridging.cc'
|
||||
|
||||
obj = bld.create_ns3_program('simple-wifi-frame-aggregation', ['core', 'simulator', 'mobility', 'wifi'])
|
||||
obj.source = 'simple-wifi-frame-aggregation.cc'
|
||||
|
||||
obj = bld.create_ns3_program('multirate', ['core', 'simulator', 'mobility', 'wifi'])
|
||||
obj.source = 'multirate.cc'
|
||||
|
||||
obj = bld.create_ns3_program('wifi-simple-adhoc', ['core', 'simulator', 'mobility', 'wifi'])
|
||||
obj.source = 'wifi-simple-adhoc.cc'
|
||||
|
||||
obj = bld.create_ns3_program('wifi-simple-adhoc-grid', ['core', 'simulator', 'mobility', 'wifi'])
|
||||
obj.source = 'wifi-simple-adhoc-grid.cc'
|
||||
|
||||
obj = bld.create_ns3_program('wifi-simple-infra', ['core', 'simulator', 'mobility', 'wifi'])
|
||||
obj.source = 'wifi-simple-infra.cc'
|
||||
|
||||
obj = bld.create_ns3_program('wifi-simple-interference', ['core', 'simulator', 'mobility', 'wifi'])
|
||||
obj.source = 'wifi-simple-interference.cc'
|
||||
218
examples/wscript
218
examples/wscript
@@ -1,205 +1,21 @@
|
||||
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
|
||||
|
||||
def build(bld):
|
||||
obj = bld.create_ns3_program('hello-simulator')
|
||||
obj.source = 'hello-simulator.cc'
|
||||
|
||||
obj = bld.create_ns3_program('first',
|
||||
['core', 'simulator', 'point-to-point', 'internet-stack'])
|
||||
obj.source = 'first.cc'
|
||||
|
||||
obj = bld.create_ns3_program('second',
|
||||
['core', 'simulator', 'point-to-point', 'csma', 'internet-stack'])
|
||||
obj.source = 'second.cc'
|
||||
|
||||
obj = bld.create_ns3_program('third',
|
||||
['core', 'simulator', 'point-to-point', 'csma', 'wifi', 'internet-stack'])
|
||||
obj.source = 'third.cc'
|
||||
|
||||
obj = bld.create_ns3_program('object-names',
|
||||
['core', 'simulator', 'csma', 'internet-stack'])
|
||||
obj.source = 'object-names.cc'
|
||||
|
||||
obj = bld.create_ns3_program('mixed-wireless',
|
||||
['core', 'simulator', 'mobility', 'wifi', 'point-to-point', 'internet-stack'])
|
||||
obj.source = 'mixed-wireless.cc'
|
||||
|
||||
obj = bld.create_ns3_program('dynamic-global-routing',
|
||||
['point-to-point', 'csma', 'internet-stack', 'global-routing'])
|
||||
obj.source = 'dynamic-global-routing.cc'
|
||||
|
||||
obj = bld.create_ns3_program('static-routing-slash32',
|
||||
['point-to-point', 'internet-stack', 'global-routing'])
|
||||
obj.source = 'static-routing-slash32.cc'
|
||||
|
||||
obj = bld.create_ns3_program('global-routing-slash32',
|
||||
['point-to-point', 'internet-stack', 'global-routing'])
|
||||
obj.source = 'global-routing-slash32.cc'
|
||||
|
||||
obj = bld.create_ns3_program('global-injection-slash32',
|
||||
['point-to-point', 'internet-stack', 'global-routing'])
|
||||
obj.source = 'global-injection-slash32.cc'
|
||||
|
||||
obj = bld.create_ns3_program('simple-global-routing',
|
||||
['point-to-point', 'internet-stack', 'global-routing'])
|
||||
obj.source = 'simple-global-routing.cc'
|
||||
|
||||
obj = bld.create_ns3_program('virtual-net-device',
|
||||
['point-to-point', 'internet-stack', 'global-routing', 'virtual-net-device'])
|
||||
obj.source = 'virtual-net-device.cc'
|
||||
|
||||
obj = bld.create_ns3_program('simple-alternate-routing',
|
||||
['point-to-point', 'internet-stack', 'global-routing'])
|
||||
obj.source = 'simple-alternate-routing.cc'
|
||||
|
||||
obj = bld.create_ns3_program('simple-error-model',
|
||||
['point-to-point', 'internet-stack'])
|
||||
obj.source = 'simple-error-model.cc'
|
||||
|
||||
obj = bld.create_ns3_program('csma-one-subnet',
|
||||
['csma', 'internet-stack'])
|
||||
obj.source = 'csma-one-subnet.cc'
|
||||
|
||||
obj = bld.create_ns3_program('csma-bridge',
|
||||
['bridge', 'csma', 'internet-stack'])
|
||||
obj.source = 'csma-bridge.cc'
|
||||
|
||||
obj = bld.create_ns3_program('csma-bridge-one-hop',
|
||||
['bridge', 'csma', 'internet-stack'])
|
||||
obj.source = 'csma-bridge-one-hop.cc'
|
||||
|
||||
obj = bld.create_ns3_program('udp-echo',
|
||||
['csma', 'internet-stack'])
|
||||
obj.source = 'udp-echo.cc'
|
||||
|
||||
obj = bld.create_ns3_program('realtime-udp-echo',
|
||||
['csma', 'internet-stack'])
|
||||
obj.source = 'realtime-udp-echo.cc'
|
||||
|
||||
obj = bld.create_ns3_program('csma-broadcast',
|
||||
['csma', 'internet-stack'])
|
||||
obj.source = 'csma-broadcast.cc'
|
||||
|
||||
obj = bld.create_ns3_program('csma-packet-socket',
|
||||
['csma', 'internet-stack'])
|
||||
obj.source = 'csma-packet-socket.cc'
|
||||
|
||||
obj = bld.create_ns3_program('csma-multicast',
|
||||
['csma', 'internet-stack'])
|
||||
obj.source = 'csma-multicast.cc'
|
||||
|
||||
obj = bld.create_ns3_program( 'mixed-global-routing',
|
||||
['point-to-point', 'internet-stack', 'global-routing' , 'csma-cd'])
|
||||
obj.source = 'mixed-global-routing.cc'
|
||||
|
||||
obj = bld.create_ns3_program('simple-point-to-point-olsr',
|
||||
['point-to-point', 'internet-stack', 'olsr'])
|
||||
obj.source = 'simple-point-to-point-olsr.cc'
|
||||
|
||||
obj = bld.create_ns3_program('nix-simple',
|
||||
['point-to-point', 'internet-stack', 'nix-vector-routing'])
|
||||
obj.source = 'nix-simple.cc'
|
||||
|
||||
obj = bld.create_ns3_program('nms-p2p-nix',
|
||||
['point-to-point', 'internet-stack', 'nix-vector-routing'])
|
||||
obj.source = 'nms-p2p-nix.cc'
|
||||
|
||||
obj = bld.create_ns3_program('tcp-large-transfer',
|
||||
['point-to-point', 'internet-stack'])
|
||||
obj.source = 'tcp-large-transfer.cc'
|
||||
|
||||
obj = bld.create_ns3_program('tcp-nsc-lfn',
|
||||
['point-to-point', 'internet-stack'])
|
||||
obj.source = 'tcp-nsc-lfn.cc'
|
||||
|
||||
obj = bld.create_ns3_program('tcp-nsc-zoo',
|
||||
['csma', 'internet-stack'])
|
||||
obj.source = 'tcp-nsc-zoo.cc'
|
||||
|
||||
obj = bld.create_ns3_program('tcp-star-server',
|
||||
['point-to-point', 'internet-stack'])
|
||||
obj.source = 'tcp-star-server.cc'
|
||||
|
||||
obj = bld.create_ns3_program('star',
|
||||
['point-to-point', 'internet-stack'])
|
||||
obj.source = 'star.cc'
|
||||
|
||||
obj = bld.create_ns3_program('csma-star',
|
||||
['csma', 'internet-stack'])
|
||||
obj.source = 'csma-star.cc'
|
||||
|
||||
obj = bld.create_ns3_program('wifi-adhoc',
|
||||
['core', 'simulator', 'mobility', 'wifi'])
|
||||
obj.source = 'wifi-adhoc.cc'
|
||||
|
||||
obj = bld.create_ns3_program('wifi-clear-channel-cmu',
|
||||
['core', 'simulator', 'mobility', 'wifi'])
|
||||
obj.source = 'wifi-clear-channel-cmu.cc'
|
||||
|
||||
obj = bld.create_ns3_program('wifi-ap',
|
||||
['core', 'simulator', 'mobility', 'wifi'])
|
||||
obj.source = 'wifi-ap.cc'
|
||||
|
||||
obj = bld.create_ns3_program('mesh',
|
||||
['core', 'simulator', 'mobility', 'wifi', 'mesh'])
|
||||
obj.source = 'mesh.cc'
|
||||
|
||||
bld.add_subdirs('stats')
|
||||
|
||||
obj = bld.create_ns3_program('wifi-wired-bridging',
|
||||
['core', 'simulator', 'mobility', 'wifi',
|
||||
'csma', 'helper', 'bridge'])
|
||||
obj.source = 'wifi-wired-bridging.cc'
|
||||
|
||||
obj = bld.create_ns3_program('csma-raw-ip-socket',
|
||||
['csma', 'internet-stack'])
|
||||
obj.source = 'csma-raw-ip-socket.cc'
|
||||
|
||||
obj = bld.create_ns3_program('csma-ping',
|
||||
['csma', 'internet-stack', 'v4ping'])
|
||||
obj.source = 'csma-ping.cc'
|
||||
|
||||
obj = bld.create_ns3_program('test-ipv6',
|
||||
['point-to-point', 'internet-stack'])
|
||||
obj.source = 'test-ipv6.cc'
|
||||
|
||||
obj = bld.create_ns3_program('ping6',
|
||||
['csma', 'internet-stack'])
|
||||
obj.source = 'ping6.cc'
|
||||
|
||||
obj = bld.create_ns3_program('simple-routing-ping6',
|
||||
['csma', 'internet-stack'])
|
||||
obj.source = 'simple-routing-ping6.cc'
|
||||
|
||||
obj = bld.create_ns3_program('icmpv6-redirect',
|
||||
['csma', 'internet-stack'])
|
||||
obj.source = 'icmpv6-redirect.cc'
|
||||
|
||||
obj = bld.create_ns3_program('radvd',
|
||||
['csma', 'internet-stack'])
|
||||
obj.source = 'radvd.cc'
|
||||
|
||||
obj = bld.create_ns3_program('radvd-two-prefix',
|
||||
['csma', 'internet-stack'])
|
||||
obj.source = 'radvd-two-prefix.cc'
|
||||
|
||||
env = bld.env_of_name('default')
|
||||
if env['ENABLE_EMU']:
|
||||
obj = bld.create_ns3_program('emu-udp-echo', ['emu', 'internet-stack'])
|
||||
obj.source = 'emu-udp-echo.cc'
|
||||
|
||||
obj = bld.create_ns3_program('emu-ping', ['emu', 'internet-stack'])
|
||||
obj.source = 'emu-ping.cc'
|
||||
|
||||
if env['ENABLE_TAP']:
|
||||
obj = bld.create_ns3_program('tap-wifi-dumbbell',
|
||||
['wifi', 'csma', 'point-to-point', 'tap-bridge', 'internet-stack'])
|
||||
obj.source = 'tap-wifi-dumbbell.cc'
|
||||
|
||||
obj = bld.create_ns3_program('simple-wifi-frame-aggregation',
|
||||
['core', 'simulator', 'mobility', 'wifi'])
|
||||
obj.source = 'simple-wifi-frame-aggregation.cc'
|
||||
|
||||
obj = bld.create_ns3_program('multirate',
|
||||
['core', 'simulator', 'mobility', 'wifi'])
|
||||
obj.source = 'multirate.cc'
|
||||
if env['ENABLE_EXAMPLES']:
|
||||
bld.add_subdirs('csma')
|
||||
bld.add_subdirs('emulation')
|
||||
bld.add_subdirs('error-model')
|
||||
bld.add_subdirs('flowmon')
|
||||
bld.add_subdirs('ipv6')
|
||||
bld.add_subdirs('mesh')
|
||||
bld.add_subdirs('naming')
|
||||
bld.add_subdirs('realtime')
|
||||
bld.add_subdirs('routing')
|
||||
bld.add_subdirs('stats')
|
||||
bld.add_subdirs('tap')
|
||||
bld.add_subdirs('tcp')
|
||||
bld.add_subdirs('tunneling')
|
||||
bld.add_subdirs('tutorial')
|
||||
bld.add_subdirs('udp')
|
||||
bld.add_subdirs('wireless')
|
||||
|
||||
@@ -11,4 +11,4 @@ def may_run(env, options):
|
||||
else:
|
||||
return "Python bindings not available."
|
||||
|
||||
pyscript = os.path.join('examples', 'csma-bridge.py')
|
||||
pyscript = os.path.join('examples/csma', 'csma-bridge.py')
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
|
||||
|
||||
def build(bld):
|
||||
env = bld.env_of_name('default')
|
||||
if not env['ENABLE_EXAMPLES']:
|
||||
return;
|
||||
|
||||
obj = bld.create_ns3_program('main-attribute-value')
|
||||
obj.source = 'main-attribute-value.cc'
|
||||
|
||||
|
||||
@@ -209,7 +209,7 @@ WifiInterferenceTestCase::WifiSimpleInterference (std::string phyMode,double Prs
|
||||
|
||||
Config::Connect ("/NodeList/0/DeviceList/0/$ns3::WifiNetDevice/Phy/$ns3::YansWifiPhy/EndSync", MakeCallback (&WifiInterferenceTestCase::PrintEndSync, this));
|
||||
// Tracing
|
||||
wifiPhy.EnablePcap ("wifi-simple-interference", devices.Get (0));
|
||||
// wifiPhy.EnablePcap ("wifi-simple-interference", devices.Get (0));
|
||||
|
||||
Simulator::Schedule (Seconds (startTime), &GenerateTraffic,
|
||||
source, PpacketSize, numPackets, interPacketInterval);
|
||||
|
||||
182
test.py
182
test.py
@@ -43,10 +43,17 @@ interesting_config_items = [
|
||||
"NS3_MODULE_PATH",
|
||||
"ENABLE_NSC",
|
||||
"ENABLE_REAL_TIME",
|
||||
"ENABLE_EXAMPLES",
|
||||
]
|
||||
|
||||
ENABLE_NSC = False
|
||||
ENABLE_REAL_TIME = False
|
||||
ENABLE_EXAMPLES = True
|
||||
|
||||
#
|
||||
# If the user has constrained us to run certain kinds of tests, we can tell waf
|
||||
# to only build
|
||||
core_kinds = ["bvt", "core", "system", "unit"]
|
||||
|
||||
#
|
||||
# A list of examples to run as smoke tests just to ensure that they remain
|
||||
@@ -57,51 +64,76 @@ ENABLE_REAL_TIME = False
|
||||
# hardcoded.
|
||||
#
|
||||
example_tests = [
|
||||
("csma-bridge", "True"),
|
||||
("csma-bridge-one-hop", "True"),
|
||||
("csma-broadcast", "True"),
|
||||
("csma-multicast", "True"),
|
||||
("csma-one-subnet", "True"),
|
||||
("csma-packet-socket", "True"),
|
||||
("csma-ping", "True"),
|
||||
("csma-raw-ip-socket", "True"),
|
||||
("csma-star", "True"),
|
||||
("dynamic-global-routing", "True"),
|
||||
("first", "True"),
|
||||
("global-injection-slash32", "True"),
|
||||
("global-routing-slash32", "True"),
|
||||
("hello-simulator", "True"),
|
||||
("icmpv6-redirect", "True"),
|
||||
("mesh", "True"),
|
||||
("mixed-global-routing", "True"),
|
||||
("mixed-wireless", "True"),
|
||||
("multirate", "False"), # takes forever to run
|
||||
("nix-simple", "True"),
|
||||
("nms-p2p-nix", "False"), # takes forever to run
|
||||
("object-names", "True"),
|
||||
("ping6", "True"),
|
||||
("radvd", "True"),
|
||||
("radvd-two-prefix", "True"),
|
||||
("realtime-udp-echo", "ENABLE_REAL_TIME == True"),
|
||||
("second", "True"),
|
||||
("simple-alternate-routing", "True"),
|
||||
("simple-error-model", "True"),
|
||||
("simple-global-routing", "True"),
|
||||
("simple-point-to-point-olsr", "True"),
|
||||
("simple-routing-ping6", "True"),
|
||||
("simple-wifi-frame-aggregation", "True"),
|
||||
("star", "True"),
|
||||
("static-routing-slash32", "True"),
|
||||
("tcp-large-transfer", "True"),
|
||||
("tcp-nsc-zoo", "ENABLE_NSC == True"),
|
||||
("tcp-star-server", "True"),
|
||||
("test-ipv6", "True"),
|
||||
("third", "True"),
|
||||
("udp-echo", "True"),
|
||||
("virtual-net-device", "True"),
|
||||
("wifi-adhoc", "False"), # takes forever to run
|
||||
("wifi-ap --verbose=0", "True"), # don't let it spew
|
||||
("wifi-wired-bridging", "True"),
|
||||
("csma/csma-bridge", "True"),
|
||||
("csma/csma-bridge-one-hop", "True"),
|
||||
("csma/csma-broadcast", "True"),
|
||||
("csma/csma-multicast", "True"),
|
||||
("csma/csma-one-subnet", "True"),
|
||||
("csma/csma-packet-socket", "True"),
|
||||
("csma/csma-ping", "True"),
|
||||
("csma/csma-raw-ip-socket", "True"),
|
||||
("csma/csma-star", "True"),
|
||||
|
||||
("emulation/emu-ping", "False"),
|
||||
("emulation/emu-udp-echo", "False"),
|
||||
|
||||
("error-model/simple-error-model", "True"),
|
||||
|
||||
("ipv6/icmpv6-redirect", "True"),
|
||||
("ipv6/ping6", "True"),
|
||||
("ipv6/radvd", "True"),
|
||||
("ipv6/radvd-two-prefix", "True"),
|
||||
("ipv6/test-ipv6", "True"),
|
||||
|
||||
("mesh/mesh", "True"),
|
||||
|
||||
("naming/object-names", "True"),
|
||||
|
||||
("realtime/realtime-udp-echo", "ENABLE_REAL_TIME == True"),
|
||||
|
||||
("routing/dynamic-global-routing", "True"),
|
||||
("routing/global-injection-slash32", "True"),
|
||||
("routing/global-routing-slash32", "True"),
|
||||
("routing/mixed-global-routing", "True"),
|
||||
("routing/nix-simple", "True"),
|
||||
("routing/nms-p2p-nix", "False"), # Takes too long to run
|
||||
("routing/simple-alternate-routing", "True"),
|
||||
("routing/simple-global-routing", "True"),
|
||||
("routing/simple-point-to-point-olsr", "True"),
|
||||
("routing/simple-routing-ping6", "True"),
|
||||
("routing/static-routing-slash32", "True"),
|
||||
|
||||
("stats/wifi-example-sim", "True"),
|
||||
|
||||
("tap/tap-wifi-dumbbell", "False"), # Requires manual configuration
|
||||
|
||||
("tcp/star", "True"),
|
||||
("tcp/tcp-star-server", "True"),
|
||||
("tcp/tcp-large-transfer", "True"),
|
||||
("tcp/tcp-nsc-lfn", "ENABLE_NSC == True"),
|
||||
("tcp/tcp-nsc-zoo", "ENABLE_NSC == True"),
|
||||
("tcp/tcp-star-server", "True"),
|
||||
|
||||
("tunneling/virtual-net-device", "True"),
|
||||
|
||||
("tutorial/first", "True"),
|
||||
("tutorial/hello-simulator", "True"),
|
||||
("tutorial/second", "True"),
|
||||
("tutorial/third", "True"),
|
||||
|
||||
("udp/udp-echo", "True"),
|
||||
|
||||
("wireless/mixed-wireless", "True"),
|
||||
("wireless/multirate", "False"), # Takes too long to run
|
||||
("wireless/simple-wifi-frame-aggregation", "True"),
|
||||
("wireless/wifi-adhoc", "False"), # Takes too long to run
|
||||
("wireless/wifi-ap --verbose=0", "True"), # Don't let it spew to stdout
|
||||
("wireless/wifi-clear-channel-cmu", "False"), # Requires specific hardware
|
||||
("wireless/wifi-simple-adhoc", "True"),
|
||||
("wireless/wifi-simple-adhoc-grid", "True"),
|
||||
("wireless/wifi-simple-infra", "True"),
|
||||
("wireless/wifi-simple-interference", "True"),
|
||||
("wireless/wifi-wired-bridging", "True"),
|
||||
]
|
||||
|
||||
#
|
||||
@@ -667,10 +699,28 @@ class worker_thread(threading.Thread):
|
||||
def run_tests():
|
||||
#
|
||||
# Run waf to make sure that everything is built, configured and ready to go
|
||||
# unless we are explicitly told not to.
|
||||
# unless we are explicitly told not to. We want to be careful about causing
|
||||
# our users pain while waiting for extraneous stuff to compile and link, so
|
||||
# we allow users that know what they''re doing to not invoke waf at all.
|
||||
#
|
||||
if options.nowaf == False:
|
||||
proc = subprocess.Popen("./waf", shell=True)
|
||||
if not options.nowaf:
|
||||
|
||||
#
|
||||
# If the user is running the "kinds" or "list" options, there is an
|
||||
# implied dependency on the test-runner since we call that program
|
||||
# if those options are selected. We will exit after processing those
|
||||
# options, so if we see them, we can safely only build the test-runner.
|
||||
#
|
||||
# If the user has constrained us to running only a particular type of
|
||||
# file, we can only ask waf to build what we know will be necessary.
|
||||
# For example, if the user only wants to run BVT tests, we only have
|
||||
# to build the test-runner and can ignore all of the examples.
|
||||
#
|
||||
if options.kinds or options.list or (len(options.constrain) and options.constrain in core_kinds):
|
||||
proc = subprocess.Popen("./waf --target=test-runner", shell=True)
|
||||
else:
|
||||
proc = subprocess.Popen("./waf", shell=True)
|
||||
|
||||
proc.communicate()
|
||||
|
||||
#
|
||||
@@ -746,9 +796,10 @@ def run_tests():
|
||||
# This translates into allowing the following options with respect to the
|
||||
# suites
|
||||
#
|
||||
# ./test,py: run all of the suites
|
||||
# ./test,py: run all of the suites and examples
|
||||
# ./test.py --constrain=core: run all of the suites of all kinds
|
||||
# ./test.py --constrain=unit: run all unit suites
|
||||
# ./test,py --suite=some-test-suite: run the single suite
|
||||
# ./test,py --suite=some-test-suite: run a single suite
|
||||
# ./test,py --example=udp-echo: run no test suites
|
||||
# ./test,py --suite=some-suite --example=some-example: run the single suite
|
||||
#
|
||||
@@ -873,7 +924,7 @@ def run_tests():
|
||||
#
|
||||
# ./test,py: run all of the examples
|
||||
# ./test.py --constrain=unit run no examples
|
||||
# ./test.py --constrain=example run all of the examples
|
||||
# ./test.py --constrain=example run all of the examples
|
||||
# ./test,py --suite=some-test-suite: run no examples
|
||||
# ./test,py --example=some-example: run the single example
|
||||
# ./test,py --suite=some-suite --example=some-example: run the single example
|
||||
@@ -883,22 +934,23 @@ def run_tests():
|
||||
#
|
||||
if len(options.suite) == 0 and len(options.example) == 0:
|
||||
if len(options.constrain) == 0 or options.constrain == "example":
|
||||
for test, condition in example_tests:
|
||||
if eval(condition) == True:
|
||||
job = Job()
|
||||
job.set_is_example(True)
|
||||
job.set_display_name(test)
|
||||
job.set_tmp_file_name("")
|
||||
job.set_cwd(TMP_TRACES_DIR)
|
||||
job.set_basedir(os.getcwd())
|
||||
job.set_shell_command("examples/%s" % test)
|
||||
if ENABLE_EXAMPLES:
|
||||
for test, condition in example_tests:
|
||||
if eval(condition) == True:
|
||||
job = Job()
|
||||
job.set_is_example(True)
|
||||
job.set_display_name(test)
|
||||
job.set_tmp_file_name("")
|
||||
job.set_cwd(TMP_TRACES_DIR)
|
||||
job.set_basedir(os.getcwd())
|
||||
job.set_shell_command("examples/%s" % test)
|
||||
|
||||
if options.verbose:
|
||||
print "Queue %s" % test
|
||||
if options.verbose:
|
||||
print "Queue %s" % test
|
||||
|
||||
input_queue.put(job)
|
||||
jobs = jobs + 1
|
||||
total_tests = total_tests + 1
|
||||
input_queue.put(job)
|
||||
jobs = jobs + 1
|
||||
total_tests = total_tests + 1
|
||||
|
||||
elif len(options.example):
|
||||
#
|
||||
|
||||
@@ -133,10 +133,11 @@ main (int argc, char *argv[])
|
||||
// enum defined in test.h converted to lower case.
|
||||
//
|
||||
std::cout << " bvt: Build Verification Tests (to see if build completed successfully)" << std::endl;
|
||||
std::cout << " unit: Unit Tests (within modules to check basic functionality)" << std::endl;
|
||||
std::cout << " system: System Tests (spans modules to check integration of modules)" << std::endl;
|
||||
std::cout << " core: Run all TestSuite-based tests (exclude examples)" << std::endl;
|
||||
std::cout << " example: Examples (to see if example programs run successfully)" << std::endl;
|
||||
std::cout << " performance: Performance Tests (check to see if the system is as fast as expected)" << std::endl;
|
||||
std::cout << " system: System Tests (spans modules to check integration of modules)" << std::endl;
|
||||
std::cout << " unit: Unit Tests (within modules to check basic functionality)" << std::endl;
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -153,9 +154,10 @@ main (int argc, char *argv[])
|
||||
TestSuite *suite = TestRunner::GetTestSuite (i);
|
||||
|
||||
//
|
||||
// Filter the tests listed by type if requested.
|
||||
// Filter the tests listed by type if requested. The special typeName
|
||||
// "core" means any TestSuite.
|
||||
//
|
||||
if (haveType)
|
||||
if (haveType && typeName != "core")
|
||||
{
|
||||
TestSuite::TestType type = suite->GetTestType ();
|
||||
if (typeName == "bvt" && type != TestSuite::BVT)
|
||||
|
||||
28
wscript
28
wscript
@@ -173,6 +173,13 @@ def set_options(opt):
|
||||
help=('Use sudo to setup suid bits on ns3 executables.'),
|
||||
dest='enable_sudo', action='store_true',
|
||||
default=False)
|
||||
opt.add_option('--enable-examples',
|
||||
help=('Build the ns-3 examples and samples.'),
|
||||
dest='enable_examples', action='store_true',
|
||||
default=True)
|
||||
opt.add_option('--disable-examples',
|
||||
help=('Do not build the ns-3 examples and samples.'),
|
||||
dest='enable_examples', action='store_false')
|
||||
opt.add_option('--regression',
|
||||
help=("Enable regression testing; only used for the 'check' target"),
|
||||
default=False, dest='regression', action="store_true")
|
||||
@@ -324,6 +331,16 @@ def configure(conf):
|
||||
|
||||
conf.report_optional_feature("ENABLE_SUDO", "Use sudo to set suid bit", env['ENABLE_SUDO'], why_not_sudo)
|
||||
|
||||
if Options.options.enable_examples:
|
||||
env['ENABLE_EXAMPLES'] = True
|
||||
why_not_examples = "defaults to enabled"
|
||||
else:
|
||||
env['ENABLE_EXAMPLES'] = False
|
||||
why_not_examples = "option --disable-examples selected"
|
||||
|
||||
conf.report_optional_feature("ENABLE_EXAMPLES", "Build examples and samples", env['ENABLE_EXAMPLES'],
|
||||
why_not_examples)
|
||||
|
||||
# we cannot pull regression traces without mercurial
|
||||
conf.find_program('hg', var='MERCURIAL')
|
||||
|
||||
@@ -482,7 +499,9 @@ def build(bld):
|
||||
|
||||
# process subfolders from here
|
||||
bld.add_subdirs('src')
|
||||
bld.add_subdirs('samples utils examples')
|
||||
bld.add_subdirs('samples')
|
||||
bld.add_subdirs('utils')
|
||||
bld.add_subdirs('examples')
|
||||
|
||||
add_scratch_programs(bld)
|
||||
|
||||
@@ -564,7 +583,12 @@ def build(bld):
|
||||
if not regression_traces:
|
||||
raise Utils.WafError("Cannot run regression tests: reference traces directory not given"
|
||||
" (--with-regression-traces configure option)")
|
||||
regression.run_regression(bld, regression_traces)
|
||||
|
||||
if env['ENABLE_EXAMPLES'] == True:
|
||||
regression.run_regression(bld, regression_traces)
|
||||
else:
|
||||
raise Utils.WafError("Cannot run regression tests: building the ns-3 examples is not enabled"
|
||||
" (regression tests are based on examples)")
|
||||
|
||||
# if Options.options.check:
|
||||
# Options.options.compile_targets += ',run-tests'
|
||||
|
||||
Reference in New Issue
Block a user