Presentation is loading. Please wait.

Presentation is loading. Please wait.

Session 7. Wireless LAN in ns-3

Similar presentations


Presentation on theme: "Session 7. Wireless LAN in ns-3"— Presentation transcript:

1 Session 7. Wireless LAN in ns-3
윤강진 Multimedia & Wireless Networking Laboratory, SNU

2 Contents IEEE 802.11 Wireless LAN Wireless LAN in NS-3 Mobility Model
Example 1 Rate Adaptation Algorithm NS-3 Structures – Rate Adaptation Example 2

3 IEEE Wireless LAN

4 IEEE 802.11 Wireless LAN Popular for enterprise, home, “hot-spot”
Enables (indoor) wireless and mobile high-speed networking “Wireless Ethernet” with comparable speed Supports up to 600 Mbps within ~100 m range Runs at unlicensed bands at 2.4 GHz and 5 GHz Emerging extensions operate at 50~700 MHz (TV white space), 900 MHz, 3.65 GHz (Satellite band), 60 GHz, etc. MAC and PHY layer technology

5 IEEE 802.11 Standard Overview
Layers 1 and 2 One MAC and multiple PHYs Application TCP IP LLC MAC PHY 1 2 3 4 7 Layer 802.11 802.2 2.4 GHz MAC DS IR FH .11a OFDM 5 GHz .11b CCK .11n OFDM .11ac OFDM 2.4 & 5 GHz In 2009 In 2014 5 GHz In 1999 In 1999 In 2003 .11g OFDM

6 IEEE 802.11 Architecture Infrastructure mode Internet Ad hoc mode
Infrastructure Basic Service Set  BSS An access point (AP) and multiple stations (STAs) Every transmission is with AP; no peer-to-peer communication Ad hoc mode Independent Basic Service Set  IBSS Multiple stations (STAs), and no AP Peer-to-peer communication only Internet AP hub, switch or router AP BSS 1 BSS 2

7 Layer Interactions Datagram vs. LPDU vs. MPDU (MAC frame) vs. PPDU (PHY frame)

8 Channels, Association 802.11b/g/n: 2.4GHz-2.485GHz spectrum
13 (in case of Korea) or 11 (in case of Taiwan and USA) channels w/ 5 MHz gap AP admin chooses frequency for AP Interference possible: Channel can be same as that chosen by neighboring AP! STA: Must associate with an AP Scans channels, listening for beacon frames containing AP’s name (SSID) and MAC address Selects AP to associate with May perform authentication Will typically run DHCP to get IP address in AP’s subnet

9 IEEE : Multiple Access Avoid collisions: 2+ nodes transmitting at same time 802.11: CSMA - sense before transmitting Don’t collide with ongoing transmission by other node 802.11: No collision detection! Difficult to receive (sense collisions) when transmitting due to weak received signals (fading) Can’t sense all collisions in any case: hidden terminal, fading Goal: Avoid collisions: CSMA/C(ollision)A(voidance) A B C A’s signal strength space C’s signal

10 Distributed Coordination Function(DCF)
Carrier Sense Multiple Access with Collision Avoidance (CSMA/CA) similar to IEEE Ethernet CSMA/CD

11 Enhanced Distributed Channel Access (EDCA)
Prioritized channel access EDCA queues Channel access function for each AC AC_VO > AC_VI > AC_BE > AC_BK

12 Avoiding collisions (more)
idea: allow sender to “reserve” channel rather than random access of data frames: avoid collisions of long data frames sender first transmits small request-to-send (RTS) packets to BS using CSMA RTSs may still collide with each other (but they’re short) BS broadcasts clear-to-send CTS in response to RTS CTS heard by all nodes sender transmits data frame other stations defer transmissions avoid data frame collisions completely using small reservation packets!

13 Collision Avoidance: RTS-CTS exchange
B AP RTS(A) RTS(B) reservation collision RTS(A) CTS(A) DATA (A) ACK(A) defer time

14 IEEE 802.11 Frame Format frame seq # duration of reserved
transmission time (RTS/CTS) frame control duration address 1 2 4 3 payload CRC 6 seq Type From AP Subtype To More frag WEP data Power mgt Retry Rsvd Protocol version 2 4 1 frame type (RTS, CTS, ACK, data)

15 Wireless LAN in NS-3

16 Overview of WiFi Model NS-3 provides models for 802.11
WifiNetDevice models a wireless network interface NS-3 supports basic DCF with infrastructure and ad hoc modes 802.11a, b and g physical layers QoS-based EDCA and queueing extensions of e various propagation loss models including Nakagami, Rayleigh, Friis, LogDistance, FixedRss, Random various rate control algorithms including Aarf, Arf, Cara, Onoe, Rraa, ConstantRate, and Minstrel 802.11s (mesh)

17 Overview of WiFi Model Four levels of models PHY layer model
ns3::WifiPhy MAC low models ns3::MacLow Takes care of RTS/CTS/DATA/ACK transmission ns3::DcfManager, ns3::DcfState Implements DCF and EDCAF function ns3::DcaTxop, ns3::EdcaTxopN Handles packet queue, packet fragmentation, retransmission MAC high models ns3::RegularWifiMac ns3::ApWifiMac, ns3::StaWifiMac, ns3::AdhocWifiMac Rate control algorithms ns3::WifiRemoteStationManager

18 Overview of WiFi Model

19 Using the WifiNetDevice
Useful helpers to provide Wifi API #include <wifi-net-device.h> Hold together all WiFi-related objects ns3::WifiChannel ns3::WifiPhy ns3::WifiMac ns3::WifiRemoteStationManager

20 Useful Helpers YansWifiChannelHelper YansWifiPhyHelper
Create a WiFi channel with a default propagation loss and propagation delay model YansWifiPhyHelper Create PHY objects appropriate for the YansWifiChannel NqosWifiMacHelper and QosWifiMacHelper Create instances of WifiMac WifiHelper Create WifiNetDevices including WifiRemoteStationManager, WifiMac, WifiPhy (connected to the WifiChannel)

21 YansWifiChannelHelper
ns3::YansWifiChannelHelper Class Reference manage and create wifi channel objects for the yans model. The intent of this class is to make it easy to create a channel object which implements the yans channel model. The yans channel model is described in "Yet Another Network Simulator", 

22 YansWifiPhyHelper ns3::YansWifiPhyHelper Class Reference
Make it easy to create and manage PHY objects for the yans model. The yans PHY model is described in "Yet Another Network Simulator", The Pcap and ascii traces generated by the EnableAscii and EnablePcap methods defined in this class correspond to PHY-level traces and come to us via WifiPhyHelper

23 QosWifiMacHelper Create QoS-enable MAC layers for a ns3::WifiNetDevice

24 NqosWifiMacHelper Create non QoS-enable MAC layers for a ns3::WifiNetDevice

25 WifiHelper ns3::WifiHelper::WifiHelper( ) 

26 WiFi PHY Model The PHY layer implements a single model in the ns3::WifiPhy class WifiPhy interacts with WifiChannel PropagationDelayModel ConstantSpeedPropagationDelayModel RandomPropagationDelayModel PropagationLossModel RandomPropagationLossModel FriisPropagationLossModel LogDistancePropagationLossModel JakesPropagationLossModel CompositePropagationLossModel PHY Model is based on the paper [1] [1] M.Lacage, T.R.Henderson, ”Yet Another Network Simulator,” in Proc. WNS2, Pisa, Italy, 2006.

27 YansWifiChannel ns3::YansWifiChannel Class Reference
#include <yans-wifi-channel.h> A Yans wifi channel This wifi channel implements the propagation model described in "Yet Another Network Simulator", ( This class is expected to be used in tandem with the ns3::YansWifiPhy class and contains a ns3::PropagationLossModel and ans3::PropagationDelayModel. By default, no propagation models are set so, it is the caller's responsibility to set them before using the channel.

28 SNIR function over time
YansWifiPhy ns3::YansWifiPhy Class Reference #include <yans-wifi-phy.h> PHY layer model Attributes EnergyDetectionThreshold CcaMode1Threshold TxGain RxGain TxPowerLevels TxPowerEnd TxPowerStart RxNoiseFigure State ChannelSwitchDelay ChannelNumber SNIR function over time

29 YansWifiPhy SINR Model in NS-3

30 WiFi MAC Model Following MAC functions are implemented in NS-3
Packet fragmentation and defragmentation Use of the RTS/CTS Rate control algorithm Connection and disconnection to and from an AP MAC transmission queue Beacon generation MSDU aggregation Block Acknowledgement etc. Following MAC functions are not implemented yet HCCA, TXOP, A-MPDU, Power saving, Handoff, etc.

31 WiFi MAC Model MAC low models MAC high models ns3::MacLow
takes care of RTS/CTS/DATA/ACK transmission ns3::DcfManager, ns3::DcfState implements DCF and EDCAF function ns3::DcaTxop, ns3::EdcaTxopN handles packet queue, packet fragmentation, retransmission MAC high models ns3::RegularWifiMac handles common MAC operations ns3::ApWifiMac, ns3::StaWifiMac, ns3::AdhocWifiMac implements AP, STA, ad hoc MAC

32 MAC Low Models Transmission flow DcaTxop::Queue()
: enqueues a packet in the packet queue DcfManager::RequestAccess() : determines whether the channel is busy or not DcaTxop::NotifyAccessGranted() : if channel is idle, forwards the packet to MacLow after fragmenting if needed MacLow::StartTransmission() : forwards the packet to YansWifiPhy

33 WiFi Transmission Flow

34 WiFi Tx Flow How to transmit a packet (from MAC to PHY)
(Assuming QoS data packet without error) MAC contains a pointer of PHY (direct access) Set txVector using WifiRemoteStationManager (m_stationManager)  MacLow has a station pointer MacLow has a YansWifiPhy pointer

35 YansWifiPhy does not have MacLow pointer
WiFi Rx Flow How to receive a packet (from PHY to MAC) (Assuming QoS data packet without error) PHY does not have a pointer of MAC (callback) YansWifiPhy does not have MacLow pointer

36 MAC Low Models Reception flow Retransmission flow MacLow::ReceiveOk()
: Schedules ACK or CTS frame, and Callback MacRxMiddle::Receive() when a data packet is received MacRxMiddle::Receive() : Forward the packet to the higher MAC after defragmenting if needed Retransmission flow MacLow::ReceiveError() : Calls DcaTxop::MissedAck() DcaTxop::MissedAck() : Update backoff and restart channel access request

37 MAC High Models ns3::ApWifiMac ns3::StaWifiMac ns3::AdhocWifiMac
Generates beacon and manages association Attributes BeaconInterval BeaconGeneration ns3::StaWifiMac Handles association state ProbeRequestTimeout AssocRequestTimeout MaxMissedBeacons ActiveProbing ns3::AdhocWifiMac Operates without association

38 WifiRemoteStationManager
ns3::WifiRemoteStationManager class Control the transmission rate and retry counter Attributes IsLowLatency MaxSsrc MaxSlrc rtsCtsThreshold ns3::UintegerValue / uint32_t / 2346 FragmentationThreshold NonUnicastMode

39 Mobility Model

40 Mobility in NS-3 ns3::MobilityHelper
Helper class used to assign positions and mobility models to nodes ns3::MobilityHelper::SetPositionAllocator ns3::MobilityHelper::SetMobilityModel

41 Position Allocator ns3::PositionAllocator Class Reference
Allocate a set of positions. The allocation strategy is implemented in subclasses. GridPositionAllocator ListPositionAllocator RandomBoxPositionAllocator RandomDiscPositionAllocator RandomRectanglePositionAllocator UniformDiscPositionAllocator

42 Mobility Model ConstantAccelerationMobilityModel
ConstantPositionMobilityModel ConstantVelocityMobilityModel GaussMarkovMobilityModel HierarchicalMobilityModel RandomDirection2dMobilityModel RandomWalk2dMobilityModel RandomWaypointMobilityModel SteadyStateRandomWaypointMobilityModel WaypointMobilityModel

43 Mobility Usage Example
MobilityHelper mobility; mobility.SetMobilityModel(“ns3::ConstantPositionMobilityModel”); mobility.Install (wifiApNode); wifiApNode.Get(0)->GetObject<MobilityModel>()->SetPosition(Vector(0.0,0.0,0.0)); mobility.SetPositionAllocator(“ns3::RandomDiscPositionAllocator”, “X”, DoubleValue(0.0), “Y”,DoubleValue(0.0), “Rho”, StringValue(“Uniform:0:20”)); mobility.SetMobilityModel(“ns3::RandomWalk2MobilityModel”, “Bounds”, RectangleValue(Rectangle(-50,50,-50,50))); mobility.Install (wifiStaNodes);

44 Example 1

45 Simulation Example Topology
Results with various number of fixed stations in right side DataRate = 50Mbps All station use ARF rate adaptation PacketSize: 200 Bytes, 1000 Bytes RtsCtsThreshold: 0, 2000 Bytes All the UDP traffics

46 WiFi Simulation Code (1/4)
#include "ns3/core-module.h" #include "ns3/point-to-point-module.h" #include "ns3/network-module.h" #include "ns3/applications-module.h" #include "ns3/wifi-module.h" #include "ns3/mobility-module.h" #include "ns3/csma-module.h" #include "ns3/internet-module.h" using namespace ns3; NS_LOG_COMPONENT_DEFINE (" session7_ex1"); class MyApp : public Application { public: MyApp (); virtual ~MyApp(); void Setup (Ptr<Socket> socket, Address address, uint32_t packetSize, uint32_t nPackets, DataRate dataRate); private: virtual void StartApplication (void); virtual void StopApplication (void); void ScheduleTx (void); void SendPacket (void); Ptr<Socket> m_socket; Address m_peer; uint32_t m_packetSize; uint32_t m_nPackets; DataRate m_dataRate; EventId m_sendEvent; bool m_running; uint32_t m_packetsSent; }; MyApp::MyApp () : m_socket (0), m_peer (), m_packetSize (0), m_nPackets (0), m_dataRate (0), m_sendEvent (), m_running (false), m_packetsSent (0) { } MyApp::~MyApp() m_socket = 0; void MyApp::Setup (Ptr<Socket> socket, Address address, uint32_t packetSize, uint32_t nPackets, DataRate dataRate) m_socket = socket; m_peer = address; m_packetSize = packetSize; m_nPackets = nPackets; m_dataRate = dataRate; MyApp::StartApplication (void) m_running = true; m_packetsSent = 0; m_socket->Bind (); m_socket->Connect (m_peer); SendPacket ();

47 WiFi Simulation Code (2/4)
void MyApp::StopApplication (void) { m_running = false; if (m_sendEvent.IsRunning ()) Simulator::Cancel (m_sendEvent); } if (m_socket) m_socket->Close (); MyApp::SendPacket (void) Ptr<Packet> packet = Create<Packet> (m_packetSize); m_socket->Send (packet); if (++m_packetsSent < m_nPackets) ScheduleTx (); MyApp::ScheduleTx (void) if (m_running) Time tNext (Seconds (m_packetSize * 8 / static_cast<double> (m_dataRate.GetBitRate ()))); m_sendEvent = Simulator::Schedule (tNext, &MyApp::SendPacket, this); } } uint32_t data = 0; static void RxCnt (Ptr<const Packet> p, const Address &a) { data = data + p->GetSize(); //NS_LOG_UNCOND (Simulator::Now ().GetSeconds () << "\t" << data); } int main (int argc, char *argv[]) int nWifi = 3; int16_t pktSize=1000; uint16_t thre=0; CommandLine cmd; cmd.AddValue ("nWifi", "Number of wifi STA devices", nWifi); cmd.AddValue ("pktSize", "Size of UDP packet", pktSize); cmd.AddValue ("thre", "RTC/CTS threshold", thre); cmd.Parse (argc,argv); NodeContainer wifiStaNodes; wifiStaNodes.Create (nWifi); NodeContainer wifiApNode; wifiApNode.Create (1);

48 WiFi Simulation Code (3/4)
YansWifiChannelHelper channel = YansWifiChannelHelper::Default (); YansWifiPhyHelper phy = YansWifiPhyHelper::Default (); phy.SetChannel (channel.Create ()); WifiHelper wifi = WifiHelper::Default (); wifi.SetRemoteStationManager ("ns3::ArfWifiManager", "RtsCtsThreshold", UintegerValue (thre) ); NqosWifiMacHelper mac = NqosWifiMacHelper::Default (); Ssid ssid = Ssid ("ns-3-ssid"); mac.SetType ("ns3::StaWifiMac", "Ssid", SsidValue (ssid), "ActiveProbing", BooleanValue (false)); NetDeviceContainer staDevices; staDevices = wifi.Install (phy, mac, wifiStaNodes); mac.SetType ("ns3::ApWifiMac", "Ssid", SsidValue (ssid)); NetDeviceContainer apDevices; apDevices = wifi.Install (phy, mac, wifiApNode); MobilityHelper mobility; mobility.SetMobilityModel (ns3::ConstantPositionMobilityModel"); mobility.Install (wifiStaNodes); mobility.Install (wifiApNode); for ( int i = 0; i<nWifi; i++){ wifiStaNodes.Get(i)->GetObject<MobilityModel>() ->SetPosition(Vector( (i>0)*5.0 + i*5.0, 0.0, 0.0)); } InternetStackHelper stack; stack.Install (wifiApNode); stack.Install (wifiStaNodes); Ipv4AddressHelper address; address.SetBase (" ", " "); Ipv4InterfaceContainer wifiApInterface; Ipv4InterfaceContainer wifiStaInterfaces; wifiApInterface = address.Assign (apDevices); wifiStaInterfaces = address.Assign (staDevices); uint16_t port = 20803;

49 WiFi Simulation Code (4/4)
PacketSinkHelper udpsink ("ns3::UdpSocketFactory", Address (InetSocketAddress (Ipv4Address::GetAny (), port))); ApplicationContainer udpapp = udpsink.Install (wifiApNode.Get (0)); udpapp.Start (Seconds (0.0)); udpapp.Stop (Seconds (7.0)); Ptr<Socket> udpsocket[5]; Ptr<MyApp> udpflow[5] = CreateObject<MyApp> (); for (int j = 0; j < nWifi ; j++){ udpsocket[j] = Socket::CreateSocket (wifiStaNodes.Get (j), UdpSocketFactory::GetTypeId ()); udpflow[j] ->Setup (udpsocket[j], Address (InetSocketAddress (wifiApInterface.GetAddress (0), port)), pktSize, , DataRate ("50Mbps")); wifiStaNodes.Get (j)->AddApplication (udpflow[j]); udpflow[j]->SetStartTime (Seconds (1.0)); udpflow[j]->SetStopTime (Seconds (6.0)); } Ipv4GlobalRoutingHelper::PopulateRoutingTables (); udpapp.Get(0)->TraceConnectWithoutContext ("Rx", MakeCallback(&RxCnt)); Simulator::Stop (Seconds (7.0)); phy.EnablePcap (" session5_ex2 ", apDevices.Get (0)); Simulator::Run (); Simulator::Destroy (); NS_LOG_UNCOND("#. of STAs= " << nWifi << ", PacketSize= "<< pktSize << ", RtsCtsThreshold= "<< thre << " => Throughput= "<< (double)data*8/1000/1000/5 <<"Mbps");

50 Simulation Example Simulation result

51 Rate Adaptation Algorithm

52 How to Select the Rate? Modulation and Coding Scheme (MCS)
Modulation type: BPSK, QPSK, 16-QAM, 64-QAM,… Coding rate: 1/2, 3/4, 2/3, 5/6, ... E.g., n (w/ 20 MHz channel and 800 ns guard interval) MCS index Tx rate (Mbps) Modulation Coding Rate 6.5 BPSK 1/2 1 13 QPSK 2 19.5 3/4 3 26 16-QAM 4 39 5 52 64-QAM 2/3 6 58.5 7 65 5/6

53 Rate Adaptation Adapts the MCS for varying SNR
Efficiency vs. Robustness tradeoff Higher rate can transmit faster at the cost of lower reliability Fading, shadowing, and mobility make the channel variation

54 How to Know the Channel Condition?
Loss-based (sampling) rate adaptation Open loop approach # of successful transmission, loss statistics, … ARF, AARF, CARA, SampleRate, and RRAA SNR-based rate adaptation Closed or open loop approach Measured SNR RBAR and CHARM

55 ARF Algorithm (1/2) Auto Rate Fallback (ARF) is the first commercial implementation that exploits multi-rate capability Senders use history of previous transmission error rates to select future transmission rates If no errors, increase the data rate If errors, decrease the data rate Achieves performance gain over plain

56 ARF Algorithm (2/2) If two consecutive ACK frames are not received correctly, the second retry and subsequent transmissions are done at a lower rate and a timer is started When the number of successfully received ACKs reaches 10 or the timer goes off, a probe frame is sent at the next higher rate However, if an ACK is NOT received for this frame, the rate is lowered back and the timer is restarted

57 AARF Algorithm Problem of ARF The essence of Adaptive ARF (AARF)
ARF tries constantly (every 10 successfully transmitted consecutive packet) to use a higher rate to be able to channel condition changes The essence of Adaptive ARF (AARF) To avoid the scenario described above, AARF increases the threshold used to decide when to increase the current rate from 10 to 20, 40, 80 When the probing packet fails, it switches back immediately to the previous lower rate, but it also multiplies by two the number of consecutive successful transmissions required to switch to a higher rate

58 ARF vs. AARF

59 Channel Error vs. Collision Error
Solution for the channel error The transmitter should decrease the transmission rate Solution for the collision error The transmitter should not decrease the rate upon collision losses Decreasing rate increases the collision probability! We need a scheme to handle this collision errors

60 CARA Algorithm Procedure of Collision Aware Rate Adaptation (CARA)
ARF-based rate adaptation Data frame transmitted without RTS/CTS If the transmission fails, RTS/CTS exchange is activated for the next retransmission If this retransmission fails, then the rate is lowered Transmission failure after RTS/CTS must be due to channel errors If retransmission is successful, stay at same rate and send next frame without RTS/CTS

61 ARF vs. CARA

62 RRAA Algorithm Robust Rate Adaptation Algorithm (RRAA) Goals
Improve the throughput performance Robust against various dynamics Three components: Loss estimation Rate change Adaptive RTS filter

63 Loss Estimation Instead of single probe frame, RRAA uses a loss estimation window and computes the estimated loss ratio over the window Uses upper and lower loss threshold for each rate and estimated loss ratio to decide when to switch rates

64 Adaptive RTS Filter Selective use of RTS/CTS. RTSwindow (RTSwnd)
Window is increased by one when last frame lost without RTS (potentially due to a collision) When the last frame was lost with RTS or succeeded without RTS, RTSwnd is halved (assume no collision involved)

65 Receiver-Based AutoRate (RBAR) Algorithm
Not compliant Receivers control sender’s transmission rate RTS and CTS are modified to contain the information on size and rate Uses analysis of RTS reception (RSSI) to estimate SNR and send choice back to sender in CTS Receiver picks rate based on a priori SNR thresholds

66 SNR-Based Rate Adaptation
Who measure the SNR of the link? RTS/CTS: RBAR ACK Channel reciprocity Who select the transmission rate? The transmitter The receiver

67 NS-3 Structures – Rate Adaptation

68 Rate Selection WifiTxVector class TxVector in 802.11 Consists of,
Transmission PHY rate Transmission power level The maximum number of retransmission Guard interval index Number of stream Number of stream in beamforming STBC index Managed in WifiRemoteStationManager

69 Rate Selection WifiRemoteStationManager
Each station has its own station manager Manages txVector based on MacLow Default: ARF Others AARF, AMRR, CARA Minstrel, Onoe, RRAA Constant, Ideal

70 Rate Selection Flow of getting transmission rate
SendDataPacket (void) in MacLow Calls GetDataTxVector (m_currentPacket, &m_currentHdr) in MacLow m_stationManager->GetDataTxVector (to, hdr, packet, size) in WifiRemoteStationManager Whenever WifiRemoteStationManager receives the transmission result of a packet, it updates rate parameter based on designated algorithm Success: ReportDataOk (…)  increase the transmission PHY rate for next packet possibly (m_rate++) Failure: ReportDataFailed (…)  decrease the transmission PHY rate for next packet possibly (m_rate--)

71 Rate Adaptation in NS-3 Wifi Model provides a set of Rate control algorithms ns3::ArfWifiManager ns3::AarfcdWifiManager ns3::AarfWifiManager ns3::AmrrWifiManager ns3::CaraWifiManager ns3::RraaWifiManager ns3::IdealWifiManager ns3::OnoeWifiManager ns3::MinstrelWifiManager ns3::ConstantRateWifiManager In this lecture, we use some rate adaptation schemes

72 ARF Rate Control Algorithm
Ns3::ArfWifiManager This implementation differs from the initial description in that it uses a packet-based timer rather than a time-based timer Attributes Config::SetDefault (“ns3::ArfWifiManager::TimerThreshold”, UintegerValue (15)); TimerThreshold: The 'timer' threshold in the ARF algorithm. Set with class: ns3::UintegerValue Underlying type: uint32_t 0: Initial value: 15 SuccessThreshold: The minimum number of sucessfull transmissions to try a new rate. Initial value: 10

73 AARF Rate Control Algorithm
Ns3::AarfWifiManager Attributes Config::SetDefault (“ns3::AarfWifiManager::SuccessK, DoubleValue (2)); SuccessK: Multiplication factor for the success threshold in the AARF algorithm. Set with class: ns3::DoubleValue Initial value: 2 TimerK: Multiplication factor for the timer threshold in the AARF algorithm. MaxSuccessThreshold: Maximum value of the success threshold in the AARF algorithm. Set with class: ns3::UintegerValue Initial value: 60

74 Attributes for AARF Attributes
MinTimerThreshold: The minimum value for the 'timer' threshold in the AARF algorithm. Set with class: ns3::UintegerValue Initial value: 15 MinSuccessThreshold: The minimum value for the success threshold in the AARF algorithm. Initial value: 10

75 CARA Rate Control Algorithm
ns3::CaraWifiManager Attributes Config::SetDefault (“ns3::CaraWifiManager::ProbeThreshold”, UintegerValue (1)); ProbeThreshold: The number of consecutive transmissions failure to activate the RTS probe. Set with class: ns3::UintegerValue Initial value: 1 FailureThreshold: The number of consecutive transmissions failure to decrease the rate. Initial value: 2 SuccessThreshold: The minimum number of successfull transmissions to try a new rate. Initial value: 10 Timeout: The 'timer' in the CARA algorithm Initial value: 15

76 ns3::MinstrelWifiManager
Chooses the best rate based on loss statistics Popular rate control algorithm Bug fix Current problem: globally uses a variable “m_nsupported” which indicates the number of supported rates Should fix to use individually

77 Ideal Rate Control Algorithm
SNR-based rate adaptation An 'ideal' rate control algorithm similar to RBAR in spirit Every station keeps track of the signal-to-noise ratio (SNR) of every packet received and sends back this SNR to the original transmitter by an out-of-band mechanism Each transmitter keeps track of the last SNR sent back by a receiver and uses it to pick a transmission mode based on a set of SNR thresholds built from a target Bit Error Rate (BER) and transmission mode-specific SNR/BER curves

78 ns3::IdealWifiManager
Attributes Config::SetDefault (“ns3::IdealWifiManager::BerThreshold”, DoubleValue (1e-05)); BerThreshold: The maximum Bit Error Rate acceptable at any transmission mode Set with class: ns3::DoubleValue Underlying type: double e+308: e+308 Initial value: 1e-05

79 Wifi Channel Wifi Channel Helper YansWifiChannelHelper Static channel
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); YansWifiChannelHelper wifiChannel; wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel"); Static channel wifiChannel.AddPropagationLoss ("ns3::LogDistancePropagationLossModel"); Dynamic channel wifiChannel.AddPropagationLoss ("ns3::JakesPropagationLossModel"); Config::SetDefault ("ns3::JakesPropagationLossModel::DopplerFreq", DoubleValue(1)); Channel setting wifiPhy.SetChannel (wifiChannel.Create ());

80 Static Channel Log distance propagation loss model
Path loss without Rayleigh fading wifiChannel.AddPropagationLoss ("ns3::LogDistancePropagationLossModel");

81 Dynamic Channel Log distance model + jakes models
Path loss with Rayleigh fading wifiChannel.AddPropagationLoss ("ns3:: JakesPropagationLossModel "); Config::SetDefault ("ns3::JakesPropagationLossModel::DopplerFreq", DoubleValue(1));

82 Optimal Rate Selection
JakesPropagationLossModel Doppler velocity 1.0 m/s LogDistancePropagationLossModel Pathloss exponent 4

83 Rate Adaptation Setting
Wifi Helper WifiHelper wifi; wifi.SetRemoteStationManager ("ns3::ArfWifiManager"); wifi.SetRemoteStationManager ("ns3::AarfWifiManager"); wifi.SetRemoteStationManager ("ns3::CaraWifiManager"); wifi.SetRemoteStationManager ("ns3::RraaWifiManager"); wifi.SetRemoteStationManager ("ns3::IdealWifiManager");

84 Mobility Model Mobility Helper MobilityHelper mobility;
Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> (); positionAlloc->Add (Vector (0.0, 0.0, 0.0)); positionAlloc->Add (Vector (30.0, 0.0, 0.0)); mobility.SetPositionAllocator (positionAlloc); mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); mobility.Install (c);

85 Example 2

86 Simulation Example Topology
Results with various number of fixed stations in right side DataRate = 25 Mbps All station use ARF, AARF, CARA, Ideal rate adaptation PacketSize: 200 Bytes, 1000 Bytes RtsCtsThreshold: 1500 Bytes All the UDP traffics

87 WiFi Simulation Code (1/3)
#include <string> #include <iostream> #include <fstream> #include "ns3/core-module.h" #include "ns3/point-to-point-module.h" #include "ns3/network-module.h" #include "ns3/applications-module.h" #include "ns3/wifi-module.h" #include "ns3/mobility-module.h" #include "ns3/csma-module.h" #include "ns3/internet-module.h" using namespace ns3; uint32_t data=0; static void RxCnt (Ptr<const Packet> p, const Address &a) { data = data + p->GetSize(); //NS_LOG_UNCOND (Simulator::Now ().GetSeconds () << "\t" << data); } void PrintResults(char *fout, int nSta, int ra_idx, double thpt) { std::ofstream out; out.open(fout,std::ios::app); out << std::fixed; out << std::showpoint; out.precision(6); out << "nSta\t" << nSta << "\traIndex\t" << ra_idx << "\tthpt\t" << thpt << "\tMbps" << std::endl; out.close(); } char fout[255]; int main (int argc, char *argv[]) int nSta = 1; int ra_idx = 0; std::string raName; CommandLine cmd; cmd.AddValue("nSTA", "number of stations", nSta); cmd.AddValue("ra_idx", "rate adaptation algorithm index", ra_idx); cmd.Parse (argc, argv); sprintf(fout, "./raIdx_%d.txt", ra_idx); NodeContainer ApNode; ApNode.Create (1); NodeContainer StaNodes; StaNodes.Create (nSta); NodeContainer c; c.Add (ApNode); c.Add (StaNodes);

88 WiFi Simulation Code (2/3)
WifiHelper wifi; wifi.SetStandard (WIFI_PHY_STANDARD_80211a); YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO); YansWifiChannelHelper wifiChannel ; wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel"); wifiChannel.AddPropagationLoss ("ns3::JakesPropagationLossModel"); wifiChannel.AddPropagationLoss ("ns3::LogDistancePropagationLossModel"); Config::SetDefault("ns3::JakesProcess::DopplerFrequencyHz", DoubleValue(50/3)); wifiPhy.SetChannel (wifiChannel.Create ()); switch(ra_idx) { case 0: raName = "ARF"; wifi.SetRemoteStationManager ("ns3::ArfWifiManager"); break; case 1: raName = "AARF"; wifi.SetRemoteStationManager ("ns3::AarfWifiManager"); break; case 2 raName = "CARA"; wifi.SetRemoteStationManager ("ns3::CaraWifiManager"); break; case 3: raName = "IDEAL"; wifi.SetRemoteStationManager ("ns3::IdealWifiManager"); default: NS_LOG_UNCOND("Invalid rate idx"); } NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); Ssid ssid = Ssid ("wifi-default"); wifiMac.SetType ("ns3::StaWifiMac","Ssid", SsidValue (ssid), "ActiveProbing", BooleanValue (false)); NetDeviceContainer staDevice = wifi.Install (wifiPhy, wifiMac, StaNodes); wifiMac.SetType ("ns3::ApWifiMac", "Ssid", SsidValue (ssid)); NetDeviceContainer apDevice = wifi.Install (wifiPhy, wifiMac, ApNode.Get(0)); NetDeviceContainer devices; devices.Add (apDevice); devices.Add (staDevice); MobilityHelper mobility;

89 WiFi Simulation Code (3/3)
Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> (); positionAlloc->Add (Vector (0.0, 0.0, 0.0)); positionAlloc->Add (Vector (30.0, 0.0, 0.0)); positionAlloc->Add (Vector (0.0, 30.0, 0.0)); positionAlloc->Add (Vector (-30.0, 0.0, 0.0)); positionAlloc->Add (Vector (0.0, -30.0, 0.0)); positionAlloc->Add (Vector (0.0, 0.0, 30.0)); mobility.SetPositionAllocator (positionAlloc); mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); mobility.Install (c); InternetStackHelper internet; internet.Install (c); Ipv4AddressHelper ipv4; ipv4.SetBase (" ", " "); ipv4.Assign (devices); uint16_t port = 9; PacketSinkHelper sink ("ns3::UdpSocketFactory", Address (InetSocketAddress (Ipv4Address::GetAny (), port))); ApplicationContainer app; app = sink.Install (ApNode.Get (0)); app.Start (Seconds (0.0)); app.Get(0)->TraceConnectWithoutContext ("Rx", MakeCallback(&RxCnt)); OnOffHelper onoff ("ns3::UdpSocketFactory", Address (InetSocketAddress (Ipv4Address (" "), port))); onoff.SetAttribute ("OnTime", StringValue("ns3::ConstantRandomVariable[Constant=1]")); onoff.SetAttribute ("OffTime", StringValue("ns3::ConstantRandomVariable[Constant=0]")); onoff.SetAttribute ("DataRate", StringValue ("25Mbps")); onoff.SetAttribute ("PacketSize", UintegerValue (1500)); for(int i=0; i<nSta; i++) { app = onoff.Install (StaNodes.Get (i)); app.Start (Seconds (1.0)); app.Stop (Seconds (3.0)); } wifiPhy.SetPcapDataLinkType(YansWifiPhyHelper::DLT_IEEE802_11_RADIO); wifiPhy.EnablePcap ("session7_ex2", devices); Simulator::Stop (Seconds (3.5)); Simulator::Run (); Simulator::Destroy (); NS_LOG_UNCOND( raName << " " << "nSta" << nSta<< " "<< (double)data*8/1000/1000/2 << " Mbps"); PrintResults(fout, nSta, ra_idx, (double)data*8/1000/1000/2); return 0;

90 Simulation Example Simulation result

91 In-class Assignment Topology
Make the topology with wireless topology helpers like below Make results with various number of fixed stations Each UDP traffic rate = 50 Mbps Destination of all traffic is AP All stations use ARF or CARA rate adaptation We want to see the total throughput as the number of UDP generators (STA) varies in various simulation environment Simulation environment (9 possible combinations) PacketSize: 200, 1000, and 2000 Bytes RtsCtsThreshold (in ARF): 0, 2000 Bytes

92 References Computer Networking: A Top Down Approach 5th edition, Jim Kurose, Keith Ross, Addison-Wesley, April, 2009 NS-3 Doxygen, NS-3 manual, NS-3 tutorial,

93 References A. Kamerman and L. Monteban, “WaveLAN-II: A High-Performance Wireless LAN for the Unlicensed Band,” Bell Lab Technical Journal, Vol. 2, No. 3, pp , 1997. M. Lacage, M.H. Manshaei, and T. Turletti, “IEEE Rate Adaptation: A Practical Approach,” in Proc. ACM MSWiM, Venezia, Italy, Oct J. Kim, S. Kim, S. Choi, and D. Qiao, "CARA: Collision-Aware Rate Adaptation for IEEE WLANs," in Proc. IEEE INFOCOM, Barcelona, Spain, April 2006. S. H. Y. Wong, H. Yang, S. Lu, and V. Bharghavan, “Robust rate adaptation for wireless networks,” in Proc. ACM MobiCom, Los Angeles, California, USA, Sep G. Holland, N. Vaidya, and P. Bahl, “A Rate-Adaptive MAC Protocol for Multihop Wireless Networks,” in Proc. ACM MobiCom, Rome, Italy, July 2001.

94 Thank You !


Download ppt "Session 7. Wireless LAN in ns-3"

Similar presentations


Ads by Google