Professional Documents
Culture Documents
Daniel Lertpratchya
Outline
• Supported Features
• Architecture
2
Wi-Fi Module Features
Wi-Fi Module Features
• DCF implementation (Basic + RTS/CTS)
• 802.11 a/b/g
• Channel models
• Mobility models
4
Wi-Fi Module
Architecture
Wi-Fi Module Architecture
• PHY layer model
6
Wi-Fi Module Architecture
Send (packet, dest, proto) ForwardUp
WifiNetDevice
Enqueue (packet, to) ForwardUp
WifiPhy
Send StartReceivePacket
WifiChannel
8
MAC Low
• Three components
• MacLow
• RTS/CTS/DATA/ACK transactions
• DcfManager
• Packet queue
• Fragmentation/Retransmissions
9
Wi-Fi Rate Adaptation
• Both low-latency and high-latency Rate Adaptation is supported
• OnoeWifiManager
• ConstantRateWifiManager
• IdealWifiManager
• AarfWifiManager
• AmrrWifiManager
10
Wi-Fi PHY
• Work at packet (frame) level
11
Synchronization Model
• Energy Detection only
• no AGC model
12
SNIR Model [1]
• Each TX attempt modeled with single power value
13
SNIR Calculation [1]
SNIR for packet B
Total Energy
Packet B
Packet A Packet C
14
Error Rate Models
• One 802.11b model
15
Using Wi-Fi in ns-3
Setting up Wi-Fi Simulations
• Nodes
• Wi-Fi
• Mobility
• Routing
• Internet stack
• Application
17
Decisions
• Wi-Fi Standard 802.11a/b/g
• QoS or non-QoS
• Infrastructure or ad hoc
• Rate control
• Routing
• Mobility model
18
Sample Code
NodeContainer c;
c.Create (2);
WifiHelper wifi;
wifi.SetStandard (WIFI_PHY_STANDARD_80211a);
19
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
// ns-3 supports RadioTap and Prism tracing extensions for 802.11
wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO);
YansWifiChannelHelper wifiChannel;
wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
wifiChannel.AddPropagationLoss ("ns3::LogDistancePropagationLossModel",
"Exponent", DoubleValue (3.0));
wifiPhy.SetChannel (wifiChannel.Create ());
// Enable PCAP
wifiPhy.EnablePcap ("wifi-adhoc", devices);
// Configure mobility
MobilityHelper mobility;
Ptr<ListPositionAllocator> posAlloc = CreateObject<ListPositionAllocator> ();
posAlloc->Add (Vector (0.0, 0.0, 0.0));
posAlloc->Add (Vector (5.0, 0.0, 0.0));
mobility.SetPositionAllocator (posAlloc);
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.Install (c);
20
Selecting Wi-Fi Standard
NodeContainer c;
c.Create (2);
WifiHelper wifi;
wifi.SetStandard (WIFI_PHY_STANDARD_80211a);
//
• Set to a non-QoS upper mac
Create WifiHelper
NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
WIFI_PHY_STANDARD_80211a
// Set Wi-Fi rate manager OFDM PHY 5GH
std::string phyMode ("OfdmRate54Mbps");
WIFI_PHY_STANDARD_80211b DSSS PHY and HR/DSSS PHY
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
WIFI_PHY_STANDARD_80211g"DataMode",StringValue EPR-OFDM PHY
(phyMode),
etc. "ControlMode",StringValue (phyMode));
21
QoS or non-QoS
NodeContainer c;
c.Create (2);
WifiHelper wifi;
wifi.SetStandard (WIFI_PHY_STANDARD_80211a);
22
Ad hoc or Infrastructure
NodeContainer c;
c.Create (2);
WifiHelper wifi;
wifi.SetStandard (WIFI_PHY_STANDARD_80211a);
23
wifi.SetStandard (WIFI_PHY_STANDARD_80211a);
Rate Manager
// Set it to adhoc mode
wifiMac.SetType ("ns3::AdhocWifiMac");
24
Rate Manager (cont.)
• For Non-unicast DATA
Config::SetDefault(“ns3::WifiRemoteStationManager::NonUnicastMode”,
StringValue (phyMode));
25
Rate Manager (cont.)
• Other interesting attributes
• RtsCtsThreshold
• FragmentationThreshold
26
WifiPhy
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
// ns-3 supports RadioTap and Prism tracing extensions for 802.11
wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO);
• Select ErrorRateModel here
YansWifiChannelHelper wifiChannel;
wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
• YansWifiPhyHelper::Default () is NistErrorRateModel
wifiChannel.AddPropagationLoss ("ns3::LogDistancePropagationLossModel",
"Exponent", DoubleValue (3.0));
wifiPhy.SetChannel (wifiChannel.Create ());
To change to devices
• NetDeviceContainer YansErrorRateModel, dowifiMac, c);
= wifi.Install (wifiPhy,
YansWifiPhyHelper::SetErrorRateModel (“ns3::YansErrorRateModel”);
// Configure mobility
MobilityHelper mobility;
Ptr<ListPositionAllocator> posAlloc = CreateObject<ListPositionAllocator> ();
• Nist/Yans ErrorRateModels are for ERP-OFDM and
posAlloc->Add (Vector (0.0, 0.0, 0.0));
posAlloc->Add (Vector (5.0, 0.0, 0.0));
OFDM, both models call DsssErrorRateModel
mobility.SetPositionAllocator (posAlloc);
automatically for DSSS
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.Install (c);
27
WifiPhy
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
// ns-3 supports RadioTap and Prism tracing extensions for 802.11
wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO);
YansWifiChannelHelper wifiChannel;
wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
• (Optional) set PCAP data link type
wifiChannel.AddPropagationLoss ("ns3::LogDistancePropagationLossModel",
"Exponent", DoubleValue (3.0));
wifiPhy.SetChannel (wifiChannel.Create ());
// Configure mobility
MobilityHelper mobility;
Ptr<ListPositionAllocator> posAlloc = CreateObject<ListPositionAllocator>
DLT_IEEE802_11 (default) 802.11 headers ();
posAlloc->Add (Vector (0.0, 0.0, 0.0));
DLT_PRISM_HEADER
posAlloc->Add Include Prism monitor mode info.
(Vector (5.0, 0.0, 0.0));
mobility.SetPositionAllocator (posAlloc);
DLT_IEEE802_11_RADIO
mobility.SetMobilityModel Include Radiotap link layer info.
("ns3::ConstantPositionMobilityModel");
mobility.Install (c);
28
29
signal and noise
30
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
WifiChannel (Loss/Delay)
// ns-3 supports RadioTap and Prism tracing extensions for 802.11
wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO);
YansWifiChannelHelper wifiChannel;
wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
wifiChannel.AddPropagationLoss ("ns3::LogDistancePropagationLossModel",
"Exponent", DoubleValue (3.0));
wifiPhy.SetChannel (wifiChannel.Create ());
31
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
// ns-3 supports RadioTap and Prism tracing extensions for 802.11
wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO);
YansWifiChannelHelper wifiChannel;
Wi-Fi Device
wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
wifiChannel.AddPropagationLoss ("ns3::LogDistancePropagationLossModel",
"Exponent", DoubleValue (3.0));
wifiPhy.SetChannel (wifiChannel.Create ());
// Enable PCAP
wifiPhy.EnablePcap ("wifi-adhoc", devices);
// Configure mobility
MobilityHelper mobility;
Ptr<ListPositionAllocator> posAlloc = CreateObject<ListPositionAllocator> ();
• Finally install the device on nodes
posAlloc->Add (Vector (0.0, 0.0, 0.0));
posAlloc->Add (Vector (5.0, 0.0, 0.0));
mobility.SetPositionAllocator (posAlloc);
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
• Enable PCAP output if needed
mobility.Install (c);
32
Mobility Model
• Initial position (partial list)
• List
• RandomRectangle
• Constant
33
"Exponent", DoubleValue (3.0));
wifiPhy.SetChannel (wifiChannel.Create ());
// Configure mobility
MobilityHelper mobility;
Ptr<ListPositionAllocator> posAlloc = CreateObject<ListPositionAllocator> ();
posAlloc->Add (Vector (0.0, 0.0, 0.0));
posAlloc->Add (Vector (5.0, 0.0, 0.0));
mobility.SetPositionAllocator (posAlloc);
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.Install (c);
• Here: ListPositionAllocator
• RandomRectanglePositionAllocator
• GridPositionAllocator
34
"Exponent", DoubleValue (3.0));
wifiPhy.SetChannel (wifiChannel.Create ());
// Configure mobility
MobilityHelper mobility;
Ptr<ListPositionAllocator> posAlloc = CreateObject<ListPositionAllocator> ();
posAlloc->Add (Vector (0.0, 0.0, 0.0));
posAlloc->Add (Vector (5.0, 0.0, 0.0));
mobility.SetPositionAllocator (posAlloc);
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.Install (c);
• Here: ConstantPositionMobilityModel
• RandomWalk2dMobilityModel
• RandomWaypointMobilityModel
35
Others…
• Internet stack
• Routing
• Application
36
Routing Protocols
• Ad-hoc routing protocol examples (IPv4 only):
• DSR
• AODV
• OLSR
37
Frequently Asked
Questions
Transmission Range
• Related questions:
39
Transmission Range
• Depends on many factors
• etc.
40
Transmission Range (cont.)
41
Changing Wi-Fi Mode
54Mbps 12Mbps
100
75
Probability
50
25
0
37.6 47.6 57.6 67.6 77.6 87.6 97.6 107.6 117.6 127.6 137.6 147.6 157.6
Distance (m)
42
Changing Frame Size
128 bytes 1920 bytes
100
75
Probability
50
25
0
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
Distance (m)
43
Simulation Setup
• Higher data rate = shorter range
44
Implications on Routing
45
Examples (Grid Network)
46
Propagation Loss Models
• Some propagation loss models have parameters
that depend on the channel frequency
47
Wi-Fi Rate Manager
• Multiple Wi-Fi rate managers are available
48
Setting up Applications
• Timing is very important in wireless simulations
49
Maximum “Application” Rate
• The maximum achievable “application” data rate is
not the same as the “Wi-Fi” rate due to:
• Timing (IFS)
• RTS/CTS/ACK
50
Mixed-mode Simulation
• E.g. timing
51
Interesting Examples
• examples/wireless/wifi-simple-adhoc.cc
• examples/wireless/wifi-simple-infra.cc
• examples/routing/manet-routing-compare.cc
52
Future Work to Expect in 2014
• A-MPDU
• 802.11n
53
References and other
interesting papers
1. M. Lacage, T. Henderson, “Yet Another Network Simulator,” Proc. 2006
Workshop on ns-2, 2006
3. http://www.nsnam.org/wiki/HOWTO_add_basic_rates_to_802.11
5. http://dsn.tm.kit.edu/english/ns3-physim.php
54