Citation
User based quality of service for 802.11 networks via dynamic control of the 802.11E EDCA MAC

Material Information

Title:
User based quality of service for 802.11 networks via dynamic control of the 802.11E EDCA MAC
Creator:
Padden, Joseph
Place of Publication:
Denver, CO
Publisher:
University of Colorado Denver
Publication Date:
Language:
English

Subjects

Subjects / Keywords:
Wireless LANs -- Security measures ( lcsh )
Roaming (Telecommunication) ( lcsh )
IEEE 802.11 (Standard) ( lcsh )
IEEE 802.11 (Standard) ( fast )
Roaming (Telecommunication) ( fast )
Wireless LANs -- Security measures ( fast )

Notes

Abstract:
The ubiquity of IEEE 802.11 based Wi-Fi networks has thrust them into new and creative service delivery use cases. It is well known that the Distributed Coordination Function (DCF), which governs channel access in Wi-Fi networks, provides equiprobable channel access to each client in the network. In addition, Wi-Fi clients support a wide range of physical layer transmission rates ranging from 1 Mbps to over 600Mbps. These two characteristics can lead to a condition of airtime unfairness in which lower rate clients receive a majority of the shared channel resource. In such a scenario, both the aggregate network throughput, and the individual throughput of higher rate clients can be limited by the inefficient use of channel airtime by lower rate clients. The 802.11e quality of service mechanisms employed in current Wi-Fi networks have not been updated or adapted to address the airtime fairness problem. This paper explores the mechanisms defined in 802.11e intended to provide application layer quality of service (QoS). In particular, the scope of this analysis is limited to a use case defined as a single radio serving two Wi-Fi networks. This paper will discuss successes and failures of some previous attempts to adapt and improve upon the principals defined in the 802.11e Enhanced Distributed Channel Access (EDCA) definition. Finally, this paper presents a new control algorithm that provides proportional throughput fairness via dynamic control of the EDCA parameter sets for two networks. It is shown that for a relatively small number of clients, the new method provides a good trade off between performance and complexity, while maintaining nearly universal device support.
General Note:
Department of Electrical Engineering
Statement of Responsibility:
Padden, Joseph

Record Information

Source Institution:
Auraria Library
Holding Location:
Auraria Library
Rights Management:
All applicable rights reserved by the source institution and holding location.

Downloads

This item is only available as the following downloads:


Full Text

PAGE 1

USER BASED QUALITY OF SERVICE FOR 802.11 NETWORKS VIA DYNAMIC CONTROL OF THE 802.11E EDCA MAC by JOSEPH PADDEN B.S. Mechanical Engineering, University of Colorado, 2004 A thesis submitted to the Faculty of the Graduate School of the University of Colorado in partial fulfillment of the requirements for the degree of Master of Science Electrical Engineering 2013

PAGE 2

ii This thesis for the Master of Science degree by Joseph Padden has been approved for the Electrical Engineering Department by Miloje Radenkovic, Chair Jaedo Park Yiming Deng Novemb er 11 2013

PAGE 3

iii Padden, Joseph (M.S., Electrical Engineering ) User Based Quality of Service for 802.11 Networks via Dynamic C ontrol of the 802.11e EDCA MAC. Thesis directed by Professor Miloje Radenkovic. AB STRACT The ubiquity of IEEE 802.11 based Wi Fi networks has thrust them into new and creative service delivery use cases. It is well known that the Distributed Coordination Function (DCF) which governs channel access in Wi Fi networks provides equiprobab le channel access to each client in the network. In addition, Wi Fi client s support a wide range of physical layer transmission rates ranging from 1 Mbps to over 600Mbps These two characteristics can lead to a condition of airtime unfairness in which lower rate client s receive a majority of the shared channel resource. In such a scenario, both the aggregate network throughput, and the individual throughput of higher rate client s can be limited by the i nefficient use of channel airtime by lower rate client s. The 802.11e quality of service mechanisms employed in current Wi Fi networks have not been updated or adapted to address the airtime fairness problem. This paper explore s the mechanisms defined in 80 2.11e intended to provide application layer quality of service (QoS). In particular, the scope of this analysis is limited to a use case defined as a single radio serving two Wi Fi networks. This paper will discuss successes and failures of some previous a ttempts to adapt and improve upon the principals defined in the 802.11e Enhanced Distributed Channel Access (EDCA) definition. Finally, this paper presents a new control alg orithm that provides proportional throughput fairness via dynamic control of the ED CA parameter set s for two networks It is shown that for a relatively small

PAGE 4

iv number of client s the new method provides a good trade off betwe en performance and complexity, while maintaining near ly universal device support. The form and content of this ab stract are approved. I recommend its publication. Approved: Miloje Radenkovic

PAGE 5

v TABLE OF CONTENTS CHAPTER !" INTRODUCTION ................................ ................................ ................................ ....... 1 # Physical Layer Background ................................ ................................ ........... 2 # Media Access Control Layer Background ................................ ..................... 6 # !!" QUALITY OF SERVICE IN WI FI NETWORKS ................................ .................. 10 # Motivation for Quality of S ervice ................................ ................................ 10 # Spectrum Crunch ................................ ................................ ..................... 10 # DCF Performance ................................ ................................ .................... 11 # Airtime Fairness and Throughput ................................ ........................... 12 # Airtime Fairness Simulation and Testing Results ................................ ........ 14 # NS 3 Simulation ................................ ................................ ...................... 14 # Device Testing ................................ ................................ ........................ 18 # Current QoS Mechanisms ................................ ................................ ............ 20 # 802.11e MAC Enhancements for Quality of Service ........................... 20 # Wi Fi MultiMedia ................................ ................................ ................... 21 # Current Wi Fi QoS Shortcomings ................................ ........................... 23 # !!!" USER BASED QOS IN WI FI NETWORKS ................................ .......................... 25 # Probability Analyses of the 802.11e EDCA ................................ ................ 25 # Collision Probability ................................ ................................ ............... 25 # Channel Access Probability per Network ................................ ............... 29 # Approaches to Optimizing Wi Fi QoS ................................ ........................ 33 #

PAGE 6

vi Idle Sense ................................ ................................ ................................ 33 # Link MTU Modulation ................................ ................................ ............ 34 # CWmin Adaptation ................................ ................................ ................. 36 # Proposed CWmin Adaptation Algorithm ................................ ..................... 38 # CWmin Adaptation ................................ ................................ ................. 38 # Network Client Count Ratio ................................ ................................ .... 39 # Physical Layer Link Rate ................................ ................................ ........ 39 # Control Algorithm ................................ ................................ ................... 40 # Testing Results ................................ ................................ ............................. 41 # Algorithm Optimizations ................................ ................................ ........ 47 # !$" CONCLUSION ................................ ................................ ................................ ......... 49 # REFERENCES ................................ ................................ ................................ .......... 50 # APPENDIX ................................ ................................ ................................ ............... 52 # A: Device Data ................................ ................................ ................................ .. 52 # B: NS 3 Simul ation Code ................................ ................................ .................. 54 # C: Airtime Analysis Python Script ................................ ................................ .... 59 # D: OpenWrt Router Configuration ................................ ................................ .... 62 # E: OpenWrt Dynamic CWmin Implementation Code ................................ ....... 65 # F: MATLAB Analysis Code ................................ ................................ ............ 104 #

PAGE 7

vii LIST OF FIGURES FIGURE %" Simple Residential Site Plan ................................ ................................ ................... 5 # &" DCF IFS relationship ................................ ................................ ............................... 8 # '" Contention access to the channel ................................ ................................ ............. 8 # (" Simulated Network Topology ................................ ................................ ............... 16 # )" 802.11g Throughput with Near vs. Far Client ................................ ....................... 16 # *" Cumulative Airtime for Distance Interval of 0 m and 110 m ................................ 17 # +" Device Testing Topology ................................ ................................ ...................... 18 # ," Throughput Related to Edge User Distance ................................ .......................... 19 # -" WMM CMSA/CA and AC Parameter Relationship ................................ ............. 22 # %." Collision Probability vs. Client Count for Various CWmin Values ..................... 28 # %%" Channel Access Probability for Networks vs CWmin(public) .............................. 30 # %&" Probability of Channel Access Ratio Surface and Contour ................................ ... 32 # %'" Throughput Test: {1,1} Private (Near) vs. Public (Far) ................................ ........ 44 # %(" Throughput Test: {1,2} Private (Near) vs. Public (Far) ................................ ........ 45 # %)" Throughput Test: Private Joins During Public Session ................................ ......... 46 # %*" CWmin Adaptation vs. Time for Private Late Join Test ................................ ....... 47 #

PAGE 8

viii LIST OF TABLES TABLE %" Free Space Transmission Loss of an Isotropic Radiator ................................ ......... 3 # &" ITU Indoor Propagation Model Loss at 2.4 and 5 GHz ................................ .......... 4 # '" DCF Timing Parameter Definitions ................................ ................................ ........ 7 #

PAGE 9

1 CHAPTER I INTRODUCTION Internet service providers (ISPs) are increasingly offering IEEE 802.11 based Wi Fi services to customers. The proliferation of Wi Fi enabled devices and the demand for ubiquitous connectivity has driven the ISPs to explore new and creative ways to increas e their service coverage footprint. One new approach, referred to as "Community Wi Fi involves the deployment of customer premise modems (cable, DSL, or fiber) with an embedded Wi Fi radio. Two or more networks (SSIDs) are b roadcast from this single radi o. One SSID is a private network for the home or business users while the remaining SSIDs are public network s for anyone near the residence or business to use. This approach enables ISPs to leverage their installed equipment base to further extend their co verage area. Many current and future deployments of Community Wi Fi plan to use a single radio configured to act as multiple virtual access points [1 0 ]. In fact the number of deployed Community Wi Fi devices is currently in the millions globally. Despite the wide adoption of this deployment model, this approach comes with inherent risks. This paper will focus on this use case as a basis for exploring 802.11 based Wi Fi network channel access method s This paper is organized as follows. Chapter I provides background on the operation and theory behind the IEEE 802.11 channel access method called the Distribution C oordination Function (DCF). C hapter II look s at the 802.11e channel access modification s to the DCF and analyze s their shortcomings for adequately managing resources in the community Wi Fi use case. Chapter III review s and analyze s previous attempts to improve upon the 802.11e QoS mechanisms. In addition, a new

PAGE 10

2 resource control algorithm is presented that is particularly suited to the Community Wi F i use case. Chapter IV concludes the paper. Physical Layer Background All wireless transmissions are subject to Free Space Path Loss. This path loss (also known as isotropic spreading loss) represents the most basic and fundamental transmission loss mode l. The free space loss of an isotropic radiator is given by: !"# $ where is distance in meters, is wavelength in meters, f is frequency in Hz and is speed of light in meters per second. In the community Wi Fi use case, the distance between the transmitter and the receiver will generally be less than 100 feet. Because of this, the Free Space Loss equation above will suffice as a first order approximation of the propagation characteristics for outdoor users. FreeSpacePathLoss =20 Log 4 d =20 Log 4 df c

PAGE 11

3 Table 1 shows the free space loss at 2.4 and 5 GHz. Table 1 : Free Space Transmission Loss of an Isotropic Radiator DISTANCE (FEET) DISTANCE (METERS) 2.4 GHZ LOSS (DB) 5 GHZ LOSS (DB) %&% $ $ '(&( ')&' )&) $ $ ')&" +*&' "%&* $ $ +*&" +,&+ *)&' $ ,&" $ +,&" )'&+ %*&, $ "( $ )(&( ))&' )+&) $ *( $ ))&" -*&' "%"&* $ '( $ -*&" -,&+ ".)&, $ )( $ -+&) ,*&( %*, $ "(( $ -,&" ,'&+ For indoor users, the signal propagation model commonly used is the ITU indoor model [11]. This propagation model was developed for a frequency range that includes the 2.4 GHz and 5 GHz bands used by most current Wi Fi networks. Based on this model, propagation loss is given by: !*# $ where L total is loss in dB, f is frequency in MHz, N is the distance loss coeff icient, d is distance from the AP to the client in meters, and Lf ( n ) is the floor loss penetration factor for n floors. In this model, the loss due to wall penetration and in room objects is included in the distance loss coefficient. For residential con struction, i.e. wood wall structure, the distance loss coefficient is given as 28. Table 2 below shows the indoor L total =20 log 10 ( f )+ N log 10 ( d )+ L f ( n ) 28

PAGE 12

4 propagation loss given by (2) assuming a single level (n=0) home similar to Figure 1 below. Table 2 : ITU Indoor Propagation Model Loss at 2.4 and 5 GHz DISTANCE (FEET) DISTANCE (METERS) 2.4 GHZ LOSS (DB) 5 GHZ LOSS (DB) %&% $ $ %.&) '-&% )&) $ $ ',&( ++&"%&* $ $ +)&+ )'&" *)&' $ $ )'&. -*&) %*&, $ "( $ )-&) -+&% A common way to predict wireless coverage area is using a link budget model. In such a model, all power gains and losses are accounted for between the transmitter and the receiver. The resulting model predicts the maximum propagation loss tolerated by a functioning wireless link. For a Wi Fi client, one p ossible link budget model is given by: !%# $ where !"#$!%&& !"!#$ is the maximum tolerated propagation loss, !" is the AP transmit power, !" is the transmitter antenna gain, !" is the transmitter loss, !" is the receiver antenna gain, !" is the receiver loss, !" is the receiver minimum sensitivity of the client, and is miscellaneous loss. All values are in dB. The maximum link budget of a common Wi Fi link is approximately 110 dB from Tx chip to Rx chip. This is based on the following assumptions: LinkLoss total = P tx + G tx + L tx + G rx + L rx P rx + L m

PAGE 13

5 1. Both the transmitter and the receiver are using omnidirectional antennas with 1 dB gain. 2. The transmitter is transmitting at 20 dBm. 3. The receiver minimum threshold is 88 dBm. 4. Transmitter and receiver loss es are zero (ideal). 5. Miscellaneous loss is zero (ideal). ( See Appendix A for collected device data supporting the above assumptions. ) Given the above link budget data and the above propagation models given by (2) and (3), it can be seen that customer devices inside the house will see average link loss on the order of 40 to 70 dB in ideal conditions. If the indoor and outdoor models are concatenated, however, it can be seen that the outdoor customer devices will see average link loss on the order of 105 to 115 dB based on the dimensions presented in Figure 1. Note that the floor plan in Figure 1 is composed of dimensions that could also apply to a small business location such as a coffee shop, restaurant, small medical or law office, etc. Figure 1 Simple Residential Site Plan Living Room Bedroom 1 Bedroom 2 Kitchen Entry ~4m from AP to Front wall ~4-6 m from house to sidewalk or street

PAGE 14

6 The above discussion is based on the stated assumptions that are in some cases idealized. Regardless, it is clear that in the application of the Community Wi Fi use case in a residential or small business setting, a large portion of users at the sidewalk or in the street will be at the edge of the coverage area for an indoor AP. In general, clients at the coverage area edge use a lower physical layer data rate than clients closer to the AP. The impact of t he lower data rate usage will be discussed in more detail later in this paper. Media Access Control Layer Background A fundamental problem in wireless communication is controlling access to the shared medium. The media access control (MAC) layer defines the rules and procedures for channel access of a given protocol. Wi Fi, as defined by the 802.11 working group of the Institute of Electrical and Electronic Engineers (IEEE), uses an access method called the Dis tributed Coordination Function (DCF). The design of the DCF is based on Carrier Sense Multiple Access with Collision Avoidance or CSMA/CA. In the DCF system, each device uses the following 3 basic steps when attempting to access the shared medium: 1. Perform a Clear Channel Assessment (CCA) by sensing the medium for a period of time before attempting to transmit. If the device determines that the medium is clear it proceeds to the next step. 2. Check the Network Allocation Vector (NAV) the virtual CCA mechanism, to ensure no hidden nodes are currently using the channel. 3. If the device determines the channel is busy in step 1 or 2, it sets a binary exponential backoff timer and waits before attempting the access the medium again, starting back at step 1. Otherwise if the device senses the medium is not busy, the device can now transmit a frame.

PAGE 15

7 For most traffic types, the amount of time the device must sense the medium in step one is the sum of the appropriate Interframe Space (IFS) plus the random binary back of f time called the Contention Window (CW). The IFS most often used is called the DCF IFS or DIFS. This is a fixed parameter determined by the physical layer characteristics of the network. The DIFS is defined as 2 x Slot Time + SIFS. The SIFS is described n ext. In a few select cases the device may use a short IFS, or SIFS, to access the channel without adding the CW. This medium access method gives certain packets absolute priority access to the medium over those using the DIFS + CW method. These special cas es include layer 2 acknowledgements, the response message to a Request To Send (RTS) frame called the Clear to Send (CTS) frame, data frames immediately following a CTS message, and any fragments of a fragmented frame after the first portion has been sent. There is a third IFS defined in the base 802.11 standards called the PCF IFS. However, Point Coordination Function (PCF) operation has seen little, if any, adoption so neither it, nor the PIFS will be discussed further. Table 3 below provides a summary of the various IFS values. Table 3 : DCF Timing Parameter Definitions 2.4 GHz 5 GHz Phy 802.11b 802.11g 802.11n 802.11a 802.11n Slot Time 20us Long GI = 20us Short GI = 9us Long GI = 20us Short GI = 9us 9us 9us SIFS 10us 10us 10us 16us 16us DIFS 50us Long GI = 50us Short GI = 28us Long GI = 5 0us Short GI = 28 us 34us 34us

PAGE 16

8 Based on a review of the current draft of the 802.11ac amendment [16], the aforementioned values are not changing and the mechanisms and discussion herein apply to this upcoming technology as well. Figure 2 below shows the relationship and usage of the IFS when used to access the shared channel. Figure 2 DCF IFS relationship When devices on the network attempt to gain access to the channel, they use a random binary back off procedure. In this procedure, during the first attempt to access the channel, a random value between zero and the contention window minimum value ( CWmin ) is chosen. In this fashion, the probability of collisions is reduced via each device choosing a random back off value from a range. This process is illustrated below in Figure 3. Figure 3 Contention access to the channel DIFS channel busy DIFS contention SIFS PIFS next frame t DIFS channel busy DIFS contention next frame t Backoff Slot contention window with randomly selected back-off slots

PAGE 17

9 Air interface packet collisions are detected by the absence of a layer 2 acknowledgement frame from the receiving party in response to a transmitted frame. When a collisio n does occur, the value of CWmin is increased and the process is repeated. Increasing the size of C Wmin can increase the channel access latency, but i t also reduces the probability of a collision. The tradeoffs of this relationship will also be discussed later in this paper. The contention window random backoff process is the basis of the new method described later in this paper. In addition, the proba bility of successful transmission and collision will also be explored for various CWmin configurations in depth later in this paper. A key point to highlight is that, in traditional DCF operation, all devices on the network have the same value for DIFS, S IFS, and the same algorithm for adjusting the value of CWmin Therefore, over time all devices have an equal probability of success when attempting to access the medium. The shortcomings of this equality will be discussed more detail later in this paper. $ $

PAGE 18

10 CHAPTER II QUALITY OF SERVICE IN WI FI NETWORKS Motivation for Quality of Service Wi Fi Quality of Service (QoS) is becoming more important as Wi Fi continues to gain popularity. In addition, access network data rates continue to increase and stress Wi Fi networks capacity The popularity of Wi Fi contributes to the need for QoS in two ways: f irst, by increasing the number of Wi Fi networks; second, by an increase in the number of devices on each Wi Fi network. The following section will explore the roots and motivation for Wi Fi QoS. Spectrum Crunch The 802.11 Wi Fi specifications have been written to take advantage of unlicensed spectrum. Early Wi Fi, namely 802.11 and 802.11b/g, use channel frequencies in the 2.4 GHz ISM band comprised of 11 chann els, 3 of which are non overlapping. Later additions to the Wi Fi spectrum include 23 non overlapping channels in the 5 GHz UNII 1, 2, and 3 bands used by 802.11a, 802.11n, and 802.11ac. Until recently the majority of Wi Fi devices supported 2.4 GHz frequ encies, with a smaller fraction of devices also supporting 5 GHz frequencies. As smartphones and tablets flood i nto Wi Fi networks, the majority of these devices supported only 2.4 GHz. This biased device support has lead to over crowding of the 3 non over lapping channels in the 2.4 GHz spectrum. In addition, the spectrum is further stressed by the frequency re use of adjacent networks. This leads to co channel interference. As discussed by Panda et al. in [5] there are three interference regions in 802.11 networks. The three regions are the Decoding Region, the Carrier Sensing Region, and the Interference Region. As shown

PAGE 19

11 in their research, co channel 802.11 networks with overlap that occupies the Decoding Region essentially become one network and can shar e the bandwidth efficiently In cases of overlap occupying the other two regions the efficiency of both networks suffers due to the increase in probability of collisions. Unfortunately, the net result is that any coverage area overlap of two networks, re gardless of region, results in lower aggregate throughput for both networks. This affects well managed enterprise networks with many APs in close proximity as well as poorly configured adjacent residential or hotspot networks occupying the same channel. DCF Performance The DCF used by all, or nearly all, of the currently deployed Wi Fi networks controls access to the wireless channel as described earlier. DCF channel access can be modeled as a bi dimensional Markov Chain as shown in [2] and [3] and refine d in [4]. One limitation of the DCF highlighted by these studies is that it loses efficiency as the number of devices increases. This has also been shown through analysis first in [2] and confirmed in [6], [7], and many other studies. Bianchi [2] first sho wed that the saturation throughput displays asymptotic behavior as the number of devices, and therefore the collision probability, goes up. Saturation is defined as the condition where all devices on the network have constantly non empty transmit queues, i .e. all devices are always contending for channel access. This fundamental limitation in combination with the spectrum and network crowding combine to form one key motivation for improved quality of service mechanisms. All devices on a given network suffer approximately equal increases in

PAGE 20

12 channel access time and reductions in throughput as the device count rises due to the egalitarian nature of the DCF. However, there are use cases in which there exist s a subset of devices that may need or want pri ority ac cess to the channel or a larger portion of the network resources. In the Community Wi Fi use case, the private network, servicing the home users, may want priority access to ensure compliance with a Service Level Agreement (SLA), either explicit or implici t, between the customer and the service provider. In such a scenario, the service provider may want a mechanism to ensure that resources are first allocated to the private network and any resources in excess of those needed to meet the SLA can then be allo cated to the public network users. Airtime Fairness and Throughput In Wi Fi networks throughput, though the primary interest of the user, is often not a good performance metric. This is due to the large number of variables which effect single client and a ggregate network throughput. For many instances, a metric called airtime is a better indicator of relative network resource allocation between a set of clients. Airtime, for the purposes of this paper, is the amount of time over a fixed interval that a giv en client has access to transmit on the shared channel. The relationship between user level throughput and airtime is upper bounded by: !'# $ where !"#$%& is user throughput data rate, is the physical layer link data rate. The factor n is to account for the time needed by the DIFS, SIFS, and by the receiving node to send an acknowledgement frame. This scaling factor varies depending on the spectrum R client R phy 1 n Airtime client Airtime total

PAGE 21

13 band used and version of 802.11 (e.g. .11a, .11b, .11g, etc) and takes a value in the range 1 n 2 It can be easily seen from (4) that user level throughput is directly proportional to the airtime that a client receives. The airtime needed to transmit a packet of !"# bytes of data is given by: !+# $ where !"#$ accounts for the time from DIFS, !"#! is the time for a SIFS, and !"# accounts for the time needed to send the acknowledgement frame. From (5) it can be seen that the airtime needed to transmit a packet is inversely proportional physical layer data rate As mentioned previously clients farther from the AP will use lower physical layer data rates. Therefore, by combining the fair channel access of the DCF, with equations (4) and (5), clients at the edge of the network co verage area will use more airtime while getting lower throughput due to less efficient use of the airtime. Heusse e t al first identified this phenomenon in [8]. I n a later study [4] by Kumar et al. this concept was extended to reflect the effect of the ed ge users on the total network throughput. In their study, they showed that the total network throughput was upper bounded by the reciprocal of the harmonic mean of the physical layer data rates of the clients on the network, as shown in (6) below. !)# $ Applying this concept to the Community Wi Fi use case it is clear that with a single radio AP the public network users, who will predominantly be farther from the Airtime pkt T DIFS + B pkt R phy + T SIFS + T ack R tot 1 1 n n i =1 1 R phy i n min 1 i n R phy i

PAGE 22

14 access point than the private network users, will undoubtedly have a negative effect on the overall network throughput, and therefore the private network throughput. One possible deployment model proposes the use of a QoS enabled device upstream of the AP (i.e. the access network modem) to manage the resource allocation between the public and p rivate Wi Fi networks. In such a model, Wi Fi throughput and resource management is performed indirectly by throttling the traffic flow to and from each network. As shown later in the simulation and test results, this method is sufficient when the aggregat e throughput of the Wi Fi network exceeds that of the access network. However, when the edge user related inefficiency lowers the aggregate throughput of the Wi Fi network below that of the access network, this management method is no longer able to effect ively manage the resources. Moreover, any QoS system that focuses solely on fixed throughput thresholds and fails to consider airtime fairness will have a similar performance floor, below which it becomes ineffective. Airtime Fairness Simulation and Testi ng Results NS 3 Simulation A simulation using Network Simulator 3 (NS 3) was performed to illustrate the airtime fairness and throughput issues facing the Community Wi Fi deployment model. NS 3 is a discrete event based network simulator. The base code is written in C++ and Python and simulation functions can be written in either. The simulation scripts used for the results below are included in Appendix B. The simulated 802.11g Wi Fi network contained two Wi Fi clients and one wired client. The Wi Fi clie nts were spatially configured such that one was directly adjacent to the AP (zero meters) and the other was a configurable distance (X meters) from the AP;

PAGE 23

15 see Figure 4 below. TCP traffic was generated from both Wi Fi clients with the destination for both flows being the wired client. The simulation was then cycled with the distance X increasing while the individual and aggregate throughput were tracked. The simulation outputs are packet captures in the form of .pcap files. The output packet traces were the n analyzed to extract throughput and airtime metrics. The python script used for airtime calculation is included in Appendix C. Throughput was measured using the Wireshark freeware application. The NS 3 Wi Fi client model includes automatic link rate adapt ation as the client moves. Furthermore, the simulator allows for the use of various wireless channel propagation models. For the simulation results presented below, the Log Distance Propagation model was used. The Log Distance model in NS 3 is based on the free space propagation loss model described earlier by equation (1). Using the propagation model, the simulator determines link quality metrics including signal strength and signal to noise ratio, and adjusts the physical layer data rate as appropriate similar to the behavior of a real Wi Fi client. Clients positioned farther from the AP use a lower physical layer data rate in the simulation. By testing over a range of distance configurations, the simulation provides a view into the effect of edge users on overall network and individual user throughput.

PAGE 24

16 Figure 4 Simulated Network Topology Figure 5 below shows the individual user throughput and the aggregate throughput of the network as the distance interval X was increased. In general, as the far client moves away from the AP, all throughput decreases. Initially, with both clients equally close to the AP (0 on the x axis), both clients achieve roughly equal throughput of approximately 6 Mbps. As the far client moves away from t he AP, both client's throughput drops, decreasing aggregate throughput. This drop in aggregate throughput indicates a drop in efficiency. Figure 5 802.11g Throughput with Near vs. Far Client 0 X TCP Sink TCP Source 2 TCP Source 1 802.11g AP 0 20 40 60 80 100 120 0 5 10 15 Far Client Distance (Feet) Throughput (Mbps) 802.11g Throughput Near Client Far Client Aggregate

PAGE 25

17 Figure 6 below shows the cumulative airtime for both the near and far client. In Case 1, the distance interval is set to 0 meters and both clie nts are very close to the AP. In this configuration it can be seen that both clients achieve nearly equal cumulat ive airtime due to the DCF fairness for clients with similar link rates In addition, both clients cumulative airtime curve maintains a roughly constant slope throughout the simulation indicating that each client was able to use the channel consistently. I n Case 2, the distance interval was increased to 110 meters, one client was 0 meters from the AP and the other was 110 meters from the AP. In this configuration, the cumulative airtime curves have different slopes. The far client is able to dominate the ai rtime, which is explained by the relative efficiency of the two clients. Both clients have equal probability of accessing the channel. However, when the far client gets control of the channel, it uses the channel less efficiently and holds the channel for a longer period of time. Furthermore, it follows that the overall network throughput drops because the far client gets a large portion of the airtime and uses the lowest physical data rate. Figure 6 Cumulative Airtime for Distance Interval of 0 m and 110 m 0 10 20 30 40 50 60 70 0 5 10 15 20 25 30 35 Simulation Time Cumulative Airtime (sec) Near/Near and Near/Far Cumulative Airtime per STA Case 1 Near STA1 Case 1 Near STA2 Case 2 Near STA Case 2 Far STA

PAGE 26

18 Device Testing Lab testing was performed using Wi Fi devices and a cable access network in order to confirm the edge user effect on single radio Community Wi Fi scenarios. An 802.11n AP running the highly flexible OpenWRT [15] firmware was configured to broadcast two separate SSIDs; a "public" network and a "private" network on the same radio. Each network was configured to draw IP addresses from a separate Class C subnet via DHCP. The WAN connection of the AP was connecte d to a cable modem that was provisioned with two upstream DOCSIS service flows, with each configured to pass the traffic from only one SSIDs IP subnet. The upstream bandwidth serving the private network was rate limited to 30 Mbps. Similarly, the upstream bandwidth serving the public network was rate limited to 10Mbps. Figure 7 Device Testing Topology Figure 8 below shows the device testing results. Each plot shows a two minute time sample. Iperf [16] software was used to create and measure the throughput of TCP flows on both the near and far client to a server behind the DOCSIS access network. The near client would start first and transmit for two minutes. At the one minute mark the far Private Home Network Public Community Network Cable Modem Home Client #1 Public Client #1 2 Upstream Service Flows 1 per Wi-Fi network 1 Downstream Service Flow 5GHz AP w/ OpenWRT

PAGE 27

19 client would start to transmit and send da ta for one minute. This staggered start approach allows for visualization of the effect of the far user on the near user. The solid lines with x = 3 both clients were placed within 3 feet of the AP. Both clients had physical data rates of 130 Mbps using 802.11n Modulation Coding Scheme (MCS) 15. It can be seen that both clients had sufficient airtime to fully utilize their access network provisioned rate limits of 10 and 30 Mbps. The dotted lines in Figure 8 show the results when the far user was moved 50 feet away from the access point in an indoor environment. In this configuration, the far user's phys ical data rate dropped to MCS 3 or 26 Mbps. As shown in the dotted line plot s the near user is able to consistently achieve the rate limit of 30 Mbps for the first minute with the exception of an anomalous rate drop early on At 60 seconds, the far user starts a traffic stream and is able to achieve the 10 Mbps rate limit. However, the near user throughput drops and becomes erratic when the far user starts sending traffic. The average throughput for the second minute of the near user drops by 20% due to the far user taking a disproportionate share of airtime. Figure 8 Throughput Related to Edge User Distance 0 20 40 60 80 100 120 0 5 10 15 20 25 30 35 Throughput Related to Edge User Distance Time (sec) Throughput (Mbps) x = 3 Near x = 50 Near x = 3 Far x = 50 Far

PAGE 28

20 The configuration fil es for the both the OpenWRT AP and the cable modem can be found in Appendix D. The clients used for testing were two identical MacBook Air laptops running the latest OS software with all updates installed. Current QoS Mechanisms The current options for Wi Fi QoS fall into two fundamental categories, standards based approaches and vendor proprietary approaches. Standards based approaches are agreed upon extensions or amendments to the 802.11 MAC/PHY specification. These features are well documented and avail able to all device manufacturers. Vendor proprietary solutions are individual approaches implemented by individual vendors. Often, device support for vendor proprietary methods is limited or hard to determine without testing. As shown in the previous secti on, it is clear that QoS mechanisms which address allocation of uplink bandwidth and airtime fairness must have broad client support to function efficiently and prevent overall network performance from being driven by non QoS enabled edge users. This paper will not discuss the vendor proprietary solutions, but instead will focus on the more widely supported standards based approaches in the next section. Furthermore, the method proposed later in the paper must have wide device support to ensure it's applica bility in current networks. 802.11e MAC Enhancements for Quality of Service The 802.11 working group of the IEEE acknowledged the need for QoS in Wi Fi networks and released a n amendment called 802.11e aimed at providing it in 2005 [12]. The approach is similar to an early proposal described in a study from Heusse et al. in 2003 [9]. This amendment was incorporated in the release of the core 802.11 2007 and later the 802.11 2012 specification.

PAGE 29

21 802.11e introduced two new coordination functions both aimed at improving the performance of the DCF for latency sensitive traffic such as voice or video. These new MAC methods are called the Enhanced Distributed Channel Access (EDCA) and the Hybrid Distributed Channel Access (HDCA) methods. The core mechanism behind the 802.11e QoS method is the assignment of different size IFS and CWmin channel access parameters based on the Differentiated Services (DiffServ) field in the IP header of pa ckets The new IFS used is called the Abritrary IFS, or AIFS. Using this method, differing channel access priority levels are mapped to DiffServ markings. The standard also introduced the Access Category (AC) concept that is used for traffic mapping with t wo DiffServ values assigned to each AC. The four ACs are Voice, Video, Best Effort, and Background, in descending order of priority. In this way, latency sensitive traffic is able to gain access to the channel with higher priority, resulting in reduced channel access time. In a high density network scenario with many equal priority users all with strong link characteristics, this enables network resources to most efficiently be used. Wi Fi MultiMedia Wi Fi multimedia (WMM) is the trade name for an 802.11 e based QoS mechanism. The Wi Fi Alliance (WFA) is a testing and certification body for Wi Fi devices. Their certification programs select a set of standards based features that support a particular service or set of use cases. A few examples include WMM f or QoS related features, Voice Enterprise for voice over Wi Fi use cases, and Passpoint (HotSpot2.0) for automatic network discovery and selection use cases.

PAGE 30

22 In the case of WMM, the WFA has specified default values and acceptable ranges for configurati on parameters related to 802.11e QoS [13]. In their specification, the WFA has defined the values of the AIFS and CWmin according to Figure 9 below. Figure 9 WMM CMSA/CA and AC Parameter Relationship It is clear from Figure 9 that traffic mapped to an AC with higher priority is assigned a shorter AIFS. Therefore, higher priority traffic is able to gain channel access before lower priority traffic. Said differently, it gives higher priority traffic a higher probability of succes s when attempting to access the shared medium. Similar to 802.11e, packets are mapped to an AC by the use of the IETF DiffServ field in the packet header. Described as User Priority (UP), this places the burden on the client device to appropriately set the DiffServ field for traffic to get the appropriate priority. Furthermore, the DiffServ code is often set at the application layer based on the service type of the application. This practice often requires complicated user configuration and/or results in di sparate behavior from similar applications from different implementers. As a result, the performance gains afforded by the use of WMM QoS are often only realized in tightly managed enterprise or commercial scenarios. In such a case, SIFS SIFS SIFS SIFS 2 slots 2 slots 2 slots 3 slots 7 slots 0-15 slots 0-15 slots 0-7 slots 0-3 slots Voice Video Best Effort Background AIFS Random Back-off window *WMM Defaults

PAGE 31

23 the network and the cli ents are both managed and configured by a common dedicated staff allowing for the proper configuration of the myriad settings needed to optimize performance. The key distinction of the WMM protocol is that the QoS is applied to specific traffic class or a pplication types. There is no mention above of the user as a priority classification criterion. There is therefore an implicit assumption that all users are equal and should get equal treatment. The goal of WMM is to optimize network usage among a group of equal clients. Current Wi Fi QoS Shortcomings The built in assumption of user equality is the fundamental shortcoming of current Wi Fi QoS. There is no user identity based mechanism available for network operators to leverage when a use case calls for di fferentiated service amongst sets of users. The lack of a user based option prevents current Wi Fi QoS from being applicable in the Community Wi Fi use case. Take for example the case where the public (Far) user is using a video streaming application whil e the private (Near) user is web browsing or uploading a large file. In such a case, if WMM were enabled as the QoS mechanism on the network, the public user would have a higher priority traffic type that requires sustained bandwidth. In addition, the publ ic user would be farther from the AP and therefore using the network resources less efficiently. Combining these two points, higher priority and less efficiency, it is possible that on a single radio AP, the private user may be completely starved of airtim e by a high priority public user located at the edge of the AP coverage area.

PAGE 32

24 Another built in assumption is that high priority flows have lower bandwidth. From an application based point of view, this is true for the most part. Voice over IP applications are very latency/jitter sensitive but commonly use as little as 64 kbps of bandwidth. Streaming video applications that are also latency/jitter sensitive, particularly when interactive such as in video calling, usually require bandwidth on the order of 2 3 Mbps. Using these assumptions, the WMM protocol allows these applications priority access to the wireless channel. However because of the "high priority = low bandwidth" assumption no metering of resources or rate limiting mechanism has been built into t he QoS definition. Taken to the logical extreme, if a high priority flow were to become a high bandwidth flow, it could starve all lower priority flows of network airtime/resources. The low bandwidth assumption therefore prevents the trivial extension of the 802.11e/WMM mechanisms to enable user based QoS. A key functional component would need to be added to police the division of resources amongst the high and low priority sets of users. Such a function could enforce a resource division policy configured by the network operator and designed to satisfy the SLA offered to users.

PAGE 33

25 CHAPTER III USER BASED QOS IN WI FI NETWORKS The idea of improved QoS mechanisms for Wi Fi networks is not a new one. Researchers have been working to improve 802.11e since it's int roduction in 2005. This chapter explores the underlying mechanisms governing the behavior of the 802.11e channel access method and the tradeoffs that must be balanced when searching for optimizations. In addition, this chapter will review several approache s to optimize the channel access method of 802.11e. Finally, this chapter presents a new algorithm for configuring 802.11e channel access parameters that is well suited to the Community Wi Fi use case. Probability Analyses of the 802.11e EDCA Collision Pro bability As described previously the re are two important parameters that govern Wi Fi client access to the shared channel under the EDCA, the AIFS and the CWmin. Similar to channel access under the DCF, the AIFS is a fixed waiting period, whereas the CWmin defines a range from which a r andom waiting time is selected. Therefore the total waiting t ime elapsed during the clear channel assessment can be defined as X = X A + X CW where X A is the fixed value AIFS assigned to each AC, and X CW is a uniformly distributed random variable which can take values between 0 and CWmin : !-# $ Using the above parameter definitions, the following is a derivation of the probability of a single client winning the channel summarizing to that provided by Rajmic et al. in [21], X CW { 0 1 ,...CWmin }

PAGE 34

26 [22]. This is a simplified model compared to the 2 D Markov Cha in model u sed in many analyses. H owever it is useful because it efficiently and accurately illustrates the effects of the CWmin parameter on the per client channel access probability and the overall collision probability that are of most interest to this analysis. In this derivation, a simplifying assumption is made that the current contention period is not dependent on any previous conditions. In a network with K clients, t he probability of a given client client 1, gaining access to the channel is given by: !,# $ I t can be see n that (8) is composed of a set of complex events, one event f or each contention slot in the CWmin range, thus expanding each slot into a set of independent events produces: !.# $ For a m ore compact form of (9) the symbol can be replaced by multiplication and the symbol can be replaced w ith summation resulting in: !"(# $ Using (10) the probability of collision can be computed by finding the comp lement of the sum of the probabilities for each client k K winning, given by: P win = P X 1
PAGE 35

27 !""# $ From (10) and (11) the overall network efficiency can be related back to the AIFS and CWmin chose for each AC. In addition, (10) enables the exploration of parameter and network configurations to learn more about the dynamics of the CWmin, network client composition, and their joint effect on proportional resource allocation. Using the Community Wi Fi use case as an example, suppose two networks are served by one radio interface. The two networks each have one AC with matching AIFS values but differing CWmin values. The private network has a fixed CWmin = 15 to match the standard DCF parameter. The public network CWmin is varied and the collision probability is explore d as a function of client count in each network. P coll =1 K k =1 P win ( k ) #

PAGE 36

28 Figure 10 Collision Probability vs. Client Count for Various CWmin Values Figure 10 shows the relationship between the number of clients in each network sharing a Community Wi Fi radio and the simplified collision probability. The top curve where CWmin for the public network equals 15 is equ ivalent to the DCF; the standard non QoS channel access method i.e. both networks using a CWmin = 15, all clients have equal probability of transmitting in a given contention slot The well known inefficiencies of the DCF can be seen as the collision probability quickly climbs as the client count rises Comparatively, the curves for a public CWmin equal to 31 and 63 (circle and star markers) show a significant reduction in the collision probability in the cases of 5 and 10 clients per network. In this scenario, half of the clients contending for the shared medium are selecting a random number from a range 2 to 4 times as large as the other half of the 2 5 10 15 20 25 30 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 Number of STAs in each Network Network Probability of Collision Collision Probability for Modulated CWmin for Various CWmin Configurations CWmin = 15 CWmin = 31 CWmin = 63 CWmin = 127 CWmin = 255 CWmin = 511 CWmin = 1023

PAGE 37

29 clients. This division creates two classes of service and also reduces the likelihood of collision. The remaining curves for a public CWmin = 1 27, 255, 511, and 1023 show diminishing returns and only reduce collision probability slightly compared to the CWmin = 63 case. As shown in previous analysis [ 19 ], [20], increasing the CWmin increases the channel access delay. Therefore, when tuning the C Wmin parameter, unnecessary increases in CWmin should be avoided as they incur a delay cost on the link. It should be noted that Huang et al. have shown in [19] that this increase in channel access delay is compounded as the clien t count increases This wi ll be relevant in later sections of this paper. Channel Access Probability per Network One way to delineate groups of Wi Fi clients K i which is particularly well suited to the Community Wi Fi use case is to group clients according to the network or SSID with which they are associated. Suppose again there are two networks one private and one public, served by a single radio. In this case there are K priv cl ients on the private network and K pub clients on the public network. Also suppos e that the ISP wants to control the allocation of Wi Fi resources to each network. Using (10) the probability that each client within its respective network is successful at gaini ng access to the channel can be summed to find the probability that a given network wins access to the channel. Using the private network as an example, this is expressed by: !"*# $ P win k K priv = K priv # k =1 $ P win ( k ) %

PAGE 38

30 Based on (11) and (12) the following is also evident : !"%# $ From (13) it can be seen that in the Community Wi Fi use case there are only three events in the set of possible outcomes for each contention slot : either a private user su ccessfully accesses the channel; a public user successfully accesses the channel ; or a collision occurs. The optimization goal for designing a resource control algorit hm is therefore controlling the first two events while maintaining an acceptably low probability of collision. Figure 11 below shows the probability of any client in a given network gaining channel access versus the CWmin value of the public network for v arious client count ratios. Figure 11 Channel Access Probability for Networks vs CWmin(public) The relationship between client ratio and the CWmin scaling follows the general trend that can be seen in Figure 11. The upper set of curves represents the private 15 31 63 127 255 511 1023 0 0.2 0.4 0.6 0.8 1 Cwmin of Public Network Network Probability of Successful Transmission Channel Access Probability for Private and Public Network vs CWmin(public) for Various STA count Configurations Priv:Pub = 2:7 Priv:Pub = 2:6 Priv:Pub = 2:5 Priv:Pub = 2:4 Priv:Pub = 2:3 Priv:Pub = 2:2 K priv k =1 P win ( k ) # + K pub k =1 P win ( k ) # + P coll =1

PAGE 39

31 network probability of winning channel access. The lower set of curves represents the same m etric for the public network. For a simple example, take the outer curves that represent a case in which each network has two clients. For compact notation, {CWmin_priv, CWmin_pub} will be used to convey the CWmin relationship between the two networks. In addition, it will be assumed for now that all clients have the same link rate. The first data point is {15,15} where the public and private network both have P win = .436. T he ratio of the probability of winning the channel for private versus public is 1:1 As the CWmin increases for the public network, it can be see that this ratio increases with it, e.g. {15, 31} = 2.6:1, {15, 63} = 5.9:1, {15, 127} = 12.5:1, {15, 255} = 25.7 or roughly doubling the ratio for each doubling of the public CWmin. Inspection of the relationship between the client count ratio and the ratio of the network probability of winning the channel reveals a similar trend. For example holding the CWmin ratio fixed at {15, 15} and varying the client count ratio, it can be seen that when t he client ratio is 1:1, the network probability of winning the channel ratio is 1:1. When the client ratio is 2:3, the ratio of the network probability of winning the channel is 2:3. Figure 12 below provides a surface plot of the parameter space regarding channel access probability for the simple two network Community Wi Fi scenario. The y axis is the client ratio between the two networks. The x axis is the CWmin chosen for the public network while the private network CWmin is fixed at 15. The z axis is th e private versus public network channel access probability ratio. The surface plot shows that when the networks have parity in either CWmin ratio or client count ratio (i.e. moving along the x or y axis) the growth in the channel access probability is prop ortional to the variable

PAGE 40

32 being changed. However, if both ratios are changing the effects compound and the channel access probability ratio increase significantly. Figure 12 Probability of Channel Access Ratio Surface and Contou r Below the surface plot are five contour lines showing the zero change contours for channel access probability ratios of 20x, 40x, 60x, 80x, and 100x. These values were chosen to be illustrative and not prescriptive, an infinite number of similar contours can be found in this data set. In an idealized network, an algorithm could react to the client ratio as it changes and adjust the CWmi n parameter in arbitrary step size s to maintain a desired channel access probability ratio by following such a contour Unfortunately, current standards, and therefore devices, limit CWmin values to power of 2 minus 1 15 63 127 255 511 1023 2/8 2/7 2/6 2/5 2/4 2/3 2/2 0 50 100 Public CWmin Probability of Channel Access Success Ratio for Private/Public Network as a function of Client Ratio and Public CWmin Private / Public Client Ratio Probability of Channel Access Ratio (Private Network / Public Network) 20x 40x 60x

PAGE 41

33 values only as CWmin is derived from the value m spe cified by the access point by calculating CWmin = 2 m 1 Regardless of this constraint, this analysis gives insight into the design of an algorithm that could be used to manage resources on the shared medium. Specifically, this analysis shows the relations hip between two key inputs and one key output that is to be controlled. Approaches to Optimizing Wi Fi QoS As mentioned before, years of research have produced many proposed optimizations or replacements to the EDCA channel access mechanism. The following is an analysis of three approaches that directly apply to the problem that is the focus of this paper. These approaches were chosen for review because they are either often cited in related papers, proposed by authorities in the field, or tested via real implementation; the latter of which is rare and directly applies to this paper. Idle Sense The first approached reviewed is a concept referred to as Idle Sen se. This a pproach as defined by Heusse et al. in [ 17 ] and further analyzed by Nassiri et al. in [18] replaces the exponential backoff proc edure with an access method based on sensing channel idle time In an idle sense network, each client tracks a value n i that is a count of the idle slots between two tran smission attempts. Each client then uses a control algorithm to adjust its own CWmin to try to drive its measured n i towards a target value n i target The authors offer performance assessment s that show that the algorithm converges quickly with all clients n i tending towards n i target When convergence occurs, the network is shown to achieve optimal throughput characteristics with minimal collisions and differentiated services achieving their respective throughput targets.

PAGE 42

34 While the above qualities are attra ctive, t here are limitations to the Idle Sense approach. First, the analysis was performed using integer values for CWmin which does no t match current device capabilities or the definition of CWmin in the 802.11e standard As stated before the current 802 .11e standard in force specifies CWmin via the equation CWmin = 2 m 1, where m is a n integer. Thus only powers of two minus one are valid values of CWmin. In addition, the simulation results shared displayed a tendency to employ large values of CWmin for lo wer priority ACs. This is common among research into differentiated throughput services via CWmin modulation. Th is tendency can also be see in [19], [24], [25] [26] all of which focus on maximizing aggregate throughput for a large number of clients while providing differentiated throughput services. However, the focus of throughput efficiency comes at the expense of channel access delay. As mentioned before, increases in the value of CWmin result in increases in channel access delay. Finally, the idle se nse algorithm fundamentally changes the client side behavior at the MAC layer This has two significant implications. First, support for the millions of legacy Wi Fi devices is very unlikely as MAC functions are generally in hardware with limited software upgradability More importantly, a s stated in the research, any clients that join an idle sense network but do not participate in the idle sense measurement process and adjust their CWmin accordingly can prevent the system from converging. Link MTU Modula tion The second approach in [28] reviewed uses modulation of the link Maximum Transmission Unit ( MTU ) to control differentiated services on the Wi Fi link. The MTU is the largest data packet, inclusive of all link headers and overhead bits, capable of

PAGE 43

35 trav ersing a link in a data network. In this method t he Wi Fi MAC layer remains unaffected and thus each has eq uiprobable access to the link. As discussed before, i n the standard DCF, this results in clients with lower physical layer data rates dominating the use of the shared airtime resource. The heart of the method lies in modulating the link MTU on a per client basis such that clients with lower physical layer link rates see a link with a lower MTU size. The smaller MTU size used by clients with lower physi cal layer rates organically limits the airtime used to send a single packet by making the packet smaller. Therefore, MTU size is used to manage the airtime allocation. In this way, each client gets equiprobable access to the channel, and more equal airtime once they win the channel. This approach is very novel and approaches the problem from a new angle. Furthermore, the results show that the method is effective at providing differentiated throughput services. However, there are some fundamental flaws to t his method that make it unsuitable for use in current Wi Fi networks. First, this method increases framing overhead on the end to end connection by forcing the MTU lower Some proposals affect the efficiency of the Wi Fi portion of a connection, but the ad ditional overhead incurred by reducing the MTU size of a connection affects the entire path the connection traverses. Another problem with this method is that many I nternet applications have requirements on MTU and simply break when the MTU is reduced bel ow the minimum expected value. As an example, the popular Xbox Live gaming platform has a well documented minimum MTU size of 1364 bytes. The method proposed requires the ratio of the client physical layer rates be proportional to the MTU size used by each client. With the standard Ethernet MTU of 1500 bytes, the ratio of the 1500 to 1364 does not

PAGE 44

36 offer enough differentiation to provide meaningful fairness control when compared to physical layer data rates which varying from 300+ Mbps to 1 Mbps In additio n, the study points o ut that the clients can take up to 10 minutes to react to changes in MTU size. The I nternet Engineering Task Force (IETF) Request For Comments ( RFC ) document that govern s the MTU discovery protocol [27] specifies a maximum cycle time o f 10 minutes between MTU size probes. The long reaction time between stimulus and response obviously limits the usefulness of this method in real networks. Finally, updates to the 802.11 standards incorporated in the 802.11e and 802.11n amendments allow f or frame aggregation. In frame aggregation smaller packets are grouped into larger frames before being sent over the wireless medium. The intent of frame aggregation is to reduce the overhead of sending many small packets and thus increase throughput. This feature fundamentally breaks the MTU modulation method as pro posed. In modern Wi Fi devices, even if the end to end connection MTU is small, the Wi Fi link is able to aggregate the frames for transmission over the Wi Fi link. CWmin Adaptation The third approach reviewed is CWmin adaptation In this method the value of CWmin is modulated to achieve the desired throughput differentiation between ACs. Extensive research has gone into this method with notable examples including [20 ], [24], [25], and [26]. I n the Tinnirello study [20], co authored by Bianchi ( an author ity in the field), the various parameters of the 802.11e EDCA are explored for their suitability for controlling

PAGE 45

37 airtime resources. It was concluded that AIFS provides good differentiation in th e access delay between ACs while CWmin provides good control of throughput differentiation. In the Li study [24] the authors proved the existence of the inverse relationship between the CWmin assigned to ACs their proportional throughput. This finding is key to the study of EDCA optimization. This result was later referenced and extended in the study by Yang et al. in [25] Their results focused on aggregate efficiency of the network with high client counts. Similarly, in the Yoon et al. study [26] the Li finding is exploited in an attempt to optimize the setting of CWmin values for ACs with different fairness or proportional throughput goals. In all of the above referenced papers, the authors focused on throughput efficiency as the primary optimization f actor. Moreover, the focus was on high client count networks. All four studies provided simulation or theoretical results for networks with client counts up to 200. This is a key distinction between these studies and the goal of this paper. T he goal of thi s paper is to develop an algorithm suitable for the Community Wi Fi use case. In this use case, client count s will often be in the 10 to 20 client range. In addition, [24], [25], and [26] perform the efficiency optimization with no consideration for chann el access delay. More specifically, [24] and [25] clearly favor larger values of CWmin in general. Whereas [26] allowed extremely large values of CWmin in the simulations ; the magnitude of which are not feasible for real world devices. In all cases, the ch annel access delay incurred would render the link unusable for practical purposes.

PAGE 46

38 P roposed CWmin Adaptation Algorithm The goal of this paper i s to motivate, develop an d implement a control algorithm that resolves the uncontrolled resource allocation problem in the community Wi Fi use case. T he algorithm should be able to protect differentiated services between two or more networks across the Wi Fi link. As shown previously in this p aper, simply rate limiting the network side connections for each network is insufficient for ensuring Wi Fi throughput. The proposed algorithm leverages three key parameters previously discussed to achieve the control goal The three parameters are CWmin, the client count ratio between the networks, and the physical layer data rates of the clients within each network. CWmin Adaptation CWmin adaptation was chosen as the primary control interface for its well documented ability to provide differentiated thr oughput between traffic classes. Moreover the negative behaviors shown in previous studies are largely ameliorated by characteristics of the Community Wi Fi use case, while any remaining negative behaviors are accepted as tradeoffs Specifically, previous studies have shown that CWmin adaptation can be inefficient for networks with many clients e.g. 100 200 clients Fortunately, the typical residential or small business user will have on the order of 10 20 Wi Fi devices or fewer. In this lower client count region of Figure 10, collision probability stays acceptably low and therefore network efficiency remains sufficiently high. Perhaps most importantly, the vast majority of Wi Fi devices deployed support CWmin adaptation since it is explicitly allowed in the 802.11e standard [12]. Any

PAGE 47

39 solution developed with the goal of being implementable and deployable in scale requires client side support without changing the MAC layer of the device. Network Client Count Ratio The primary Community Wi Fi use case is a simple two network, one radio deployment configuration supporting a private and a public network. In this configuration the goal is to manage the air resource such that throughput thresholds are protected for the private network. Any air resources in exces s of those needed to achieve the private network throughput threshold can be then shared with the public network to provide service to roaming customers. In this scenario, the network is the entity being managed not any single client. Hence, the number of private clients active at any given time wil l a ffect the resources being used by the private network. The same is true of the public network. Thus, a ny CWmin adaptation process needs to account for a varying client count ratio so that the appropriate per c lient channel access probability is assigned such that the overall network channel access ratio is maintained. Furthermore, this process must be dynamic to acco unt for scenarios such as active clients going into power save mode for long periods or clients joining and leaving the network. An example of such and algorithm would be one that follows a zero change contour line from Figure 12. Physical Layer Link Rate Airtime is directly proportional to both channel access probability as well as the physical lay er link rate of the client. As mentioned previously and described in equation (6), low rate clients govern the throughput behavior of a network. Thus any algorit hm that aims to control throughp ut or airtime, or both, must consider the physical layer li nk

PAGE 48

40 r ate. In the proposed algorithm, the minimum link rate in both networks is compared to the object throughput rate when used for determining the CWmin of the public network. Control Algorithm Based on the above motivation, the CWmin adaptation algorithm proposed is designed to protect a predetermined throughput threshold for the private network. The algorithm is designed to follow a contour on the surface in Figure 12 based on the input desired private data rate. This algorithm uses the CWmin of the private network as a baseline. The CWmin for the public network is then scaled based on the physical layer link rate ratio and the client count ratio to provide a probability of channel access succes s ratio for the private network that is sufficient to achieve the desired data rate. The scaling function is given by: !"'# $ w here R desired is the desired throughput of the private network, n is a scaling function defined for each physical layer and accounts for protocol overhead (e.g. n = 2 for 802.11g), R min is the minimum physical layer link rate of any active client in either network, and Count priv and Count pub are the active client counts in the private and public networks, respectively The log bas e two function is used find the appropriate value for use with the current definition of CWmin as discussed previously. Then finally the ceiling function is used to always round up so that the t hreshold is protected absolutely. CWmin pub = CWmin priv + log 2 n R desired R min Count priv Count pub # $

PAGE 49

41 The control algorithm in the current implementation is represented in pseudo code as follows: 1. If (Active Client Count in Private > 0 && Active Client Count in Public > 0) 2. Update CWmin pub per (14) 3. Else 4. Use default CWmin pub = 5 5. End If In this way, when any network is the only network with an active client the standard DCF configuration is used However, when both networks have clients that are actively contending the channel, the relative channel acces s probability is governed by (14) to ensure the private network receives the necessary resources for the desired throughput rate Testing Results To validate the proposed algorithm an implementation was created using the OpenWrt platform. The implementati on consisted of modifying the OpenWrt source C++ code for the access point controller daemon, known as "hostapd". The function that handles the MAC management beacon frame was located and modified such that the advertised WMM param eters set, in particular CWmin, was recalculated every two seconds via equation (14) Thus the maximum possible update rate for the CWmin adaptation was once every 2 seconds. The function was further modified to allow for the collection of necessary input parameters to equation (1 4) including R min Count priv and Count pub Once the modifications were in place, the router was configured to support two Wi Fi networks. One network was the "private" network and the other the "public" network. The only difference in this case was that the WMM parameter set was fixed at

PAGE 50

42 the default values for the private network, and for the public network the CWmin value was varied per (14). The same configuration as illustrated in Figure 7 was used for testing the proposed algorithm. The network consisted of a residential cable modem connected to a Netgear WNDR3800 Wi Fi router running the modified version of OpenWrt. The Wi Fi router was configured to serve the two Wi Fi networks via a single radio on channel 36 in the 5GHz UNII 1 band. The cable modem was configured with two upstream service flows with rate limits of 10 Mbps and 30 Mbps for the public and private Wi Fi networks respectively. The test procedure was identical to that discussed previously resulting in the data for Figure 8. Two id entical Apple MacBook Air laptops were used to perform throughput tests over the priv ate and public networks. In all test s the private client was place within 5 feet of the access point and used a link rate of 130Mbps, or 802.11n MCS 15. The public client was placed approximately 50 feet away on the other side of a wall and primarily used a link rate of 26 Mbps or MCS 3. The link rate would occasionally fluctuate between MCS 2,3,4 for link rates of 20, 26, and 39 Mbps respectively. Once the clients were po sitioned, the private client would initiate an Iperf throughput test with a two minute duration. After one minute, the public client would initiate a one minute Iperf throughput test thus sharing the channel resources for the second minute of the private c lient test Both throughput tests terminated at a server behind the cable network. Figure 13 shows the results of the throughput tests for the case with one client in each network. The left plot shows the behavior of the standard DCF channel access method This is also the behavior of the EDCA if all the traffic is classified into the Best

PAGE 51

43 Effort AC. It can be seen that the private client throughput in the first minute is stable around the configured cable modem rate limit of 30 Mbps. In the second minute the public user begins contending for the channel resources. It is clear from the results that the private users throughput drops as a result of insufficient airtime resources. This result is similar to those presented in Figure 8. In this case, the CWmi n for both network s was held constant at 15. The right plot in Figure 13 shows the result of the same test performed with the proposed CWmin adaptation algorithm enabled on the access point. In this case, the CWmin value of the public netw ork was varied p er (14) with an update interval of two seconds. It can be seen that the throughput of the private network showed minimal impact from the public user contending for the shared resource. It can also be seen that the throughput of the public user was reduced compared to the left plot, but did not go to zero. Thus from Figure 13 it can be seen that the algorithm is able to secure the resources needed by the private user to achieve the protected data rate of 30 Mbps while allowing the public user to use any rem aining resources. It should be noted that in Figure 13, 14, and 15 the x axis is measured in samples not time. The Iperf tool outputs throughput measurement samples at intervals of approximately 1 second, but not exactly 1 second. Thus to a void confusion, the axis is labeled in samples not seconds. The full duration of all tests was 120 seconds. Each plot has approximately 104 samples.

PAGE 52

44 Figure 13 Throughput Test: {1,1 } Private (N ear) vs. Public (Far) The previous test exercised the physical layer data rate portion of the proposed algorithm. Next the client ratio portion of the algorithm was exercised in addition to the physical layer data rate portion. Figure 14 shows the results for a similar through put test with one private user and two public users. In this test, both public users were physically located at the signal coverage edge and both primarily used MCS 3 or 26 Mbps physical layer data rates. Thus in this test there is a 2:1 client ratio betwe en the networks as well as a physical layer data rate disparity. The left plot in Figure 14 again shows the standard DCF performance in this scenario. It is clear that the standard channel access method is not able to protect the private user from being a ffected by the public users. The right plot shows the results when the proposed CWmin adaptation algorithm is enabled. The private user threshold is protected via the dynamic control of the CWmin parameter. This test exhibits the algorithms ability to acco unt for physical layer data rate and client ratio disparities. 0 50 100 0 10 20 30 40 Sample # Throughput (Mbps) Standard DCF or EDCA 0 50 100 0 10 20 30 40 Sample # Throughtput (Mbps) CWmin Adaptation Private Public 1

PAGE 53

45 Figure 14 Throughput Test: {1,2} Private (Near) vs. Public (Far) The transient behavior seen in both Figure 13 and 14 is a result of the Wi Fi clients dynamically a djusting the physical layer data rate more frequently than the implementation can update the CWmin value. The Wi Fi clients can adjust the physical layer data rate for each burst which is on the order of milli seconds. The current implementation is limited to updating the CWmin every 2 seconds. This time disparity occasionally results in a momentary drop in throughput. The standard beacon frame interval is 100ms. Thus, further optimization of the implementation code could reduce the update interval and the transient behavior. Figure 15 below shows the behavior when a private user attempts to gain access to the channel in the middle of a public user heavily using the channel. Again the left plot shows the behavior of the standard DCF channel access method. It can be seen that the public client is able to achieve the configured cable upstream data rate for the first minute. In the second minute, once the private user starts a throughput test, the public users is able to keep most of the resources needed to reac h the 10 Mbps rate while the private users throughput suffers. 0 50 100 0 10 20 30 40 Sample # Throughput (Mbps) Standard DCF or EDCA 0 50 100 0 10 20 30 40 Sample # Throughtput (Mbps) CWmin Adaptation Private Public 1 Public 2

PAGE 54

46 The right plot of Figure 15 shows the result when the proposed algorithm is used for the same test. At the one minute mark, the private user begins contending for the channel and the algorithm begins to decrease the channel access probability for the public user. As a result the private user is able to achieve much closer to the configured throughput rate than under the standard DCF. Furthermore, in contrast to the DCF, the established connecti on of the public user is de prioritized via reduced channel access probability and thus the throughput drops. Again, it is important to note that the public user continues to receive some resources, just at a diminished rate. In addition, the private users rate instability is tending to reduce as time progresses. Figure 15 Throughput Test: Private Joins During Public Session Figure 16 shows the CWmin value over time for the test in which the private user joins late. In this cas e, the public users starts w ith a default CWmin of 5 and then increases it's value once the private client joins and becomes active. The fluctuations seen in the data are related to the physical layer data rate of the public user adjusting between MCS 2, 3 and 4 resulting in the algorithm adjusting the CWmin accordingly. 0 50 100 0 10 20 30 40 Sample # Throughput (Mbps) Standard DCF or EDCA 0 50 100 0 10 20 30 40 Sample # Throughtput (Mbps) CWmin Adaptation Public 1 Private

PAGE 55

47 The early spike is the result of the private client issuing a probe request or some other MAC management traffic for a short period of time. In the current implementation, the CWmin adapta tion is only activated if there is at least one active user in each network. Thus, during the first half of this test, any traffic from the private user would trigger the momentary activation of the CWmin adaptation. Figure 16 CWmin Adaptation vs. Time for Private Late Join Test Algorithm Optimizations The proposed algorithm and proof of concept implementation provide evidence that the method used is capable of address ing the resource protection goal of this paper. However, duri ng the development and testing phases, areas of future optimization were identified. First, the inability to use integer step sizes for CWmin adjustments is a hindrance to the optimal tuning of the parameter. For the proof of concept implementation the cei ling function was used to ensure sufficient priority for the private network. However, an alternative approach is to use dithering to rapidly modulate the CWmin value to achieve and effective CWmin that is between the power of two steps currently available 0 20 40 60 80 100 120 140 1 2 3 4 5 6 7 8 9 10 CWmin Adapation vs. Time for Private Client Late Join Test Time (sec) Public Network CWmin

PAGE 56

48 The second optimization for future work is to tune the control process with some measure of hysteresis such that rapid fluctuations in physical layer link rate were smoothed from the viewpoint of (14). Such a smooth process would provide a more stable C Wmin for the public network. As of this time, the maximum client supported CWmin update frequency is unknown.

PAGE 57

49 CHAPTER IV CONCLUSION This paper has presented a simple control law and algorithm with the demonstrated ability to control the air resource alloc ations in the Community Wi Fi use case. The principals governing the physical and MAC layers of Wi Fi technologies were explored and used to motivate the proposed algorithm. The objective of the algorithm is to protect a private network throughput threshol d in the presence of conditions that would otherwise cause airtime unfairness. Three related optimization efforts were analyzed and shown to be unsuitable for the goals of this project. The algorithm was constrained to being something that was implementabl e and deployable in current Wi Fi networks. Th ese constraints limited the tools available for airtime control and forced some tradeoffs. However, the resulting method has been shown to achieve the service objectives while staying within the constraints.

PAGE 58

50 R EFERENCES [1] IEEE 802.11: Telecommunications and information exchange between systems Local and metropolitan area networks Specific requirements Part 11: Wireless LAN Medium Access Control (MAC) and Physical Layer (PHY) Specifications, 2012. [2] Bia nchi, Giuseppe. "Performance analysis of the IEEE 802.11 distributed coordination function." Selected Areas in Communications, IEEE Journal on 18.3 (2000): 535 547. [3] Wu, Haitao, et al. "Performance of reliable transport protocol over IEEE 802.11 wireles s LAN: analysis and enhancement." INFOCOM 2002. Twenty First Annual Joint Conference of the IEEE Computer and Communications Societies. Proceedings. IEEE Vol. 2. IEEE, 2002. [4] Kumar, Anurag, et al. "New insights from a fixed point analysis of single cel l IEEE 802.11 WLANs." INFOCOM 2005. 24th Annual Joint Conference of the IEEE Computer and Communications Societies. Proceedings IEEE Vol. 3. IEEE, 2005. [5] Panda, Manoj K., Anurag Kumar, and S. H. Srinivasan. "Saturation throughput analysis of a system o f interfering IEEE 802.11 WLANs." World of Wireless Mobile and Multimedia Networks, 2005. WoWMoM 2005. Sixth IEEE International Symposium on a IEEE, 2005. [6] Manshaei, Mohammad Hossein, and Jean Pierre Hubaux. "Performance Analysis of the IEEE 802.11 Distributed Coordination Function: Bianchi Model." Mobile Networks, Communication Systems & Computer Science Divisions (2007). [7] Vardakas, John S., Michael K. Sidiropoulos, and Michael D. Logothetis. "Performance behaviour of IEEE 802.11 distributed coordi nation function." IET circuits, devices & systems 2.1 (2008): 50 59. [8] Heusse, Martin, et al. "Performance anomaly of 802.11 b." INFOCOM 2003. Twenty Second Annual Joint Conference of the IEEE Computer and Communications. IEEE Societies Vol. 2. IEEE, 2003. [9] H Heusse, Martin, et al. "Bandwidth allocation for DiffServ based quality of service over 802.11." Global Telecommunications Conference, 2003. GLOBECOM'03. IEEE Vol. 2. IEEE, 2003. [10] Wi Fi Requirements for Cable Modem Gateways, WR SP WiFi GW I01 100729, July 29, 2010, Cable Television Laboratories, Inc. [11] ITU R RECOMMENDATION P.1238 7, Propagation data and prediction methods for the planning of indoor radio communication systems and radio local area networks in the frequency range 900 MHz t o 100 GHz, 2012. Available online at: http://www.itu.int/rec/R REC P.1238/ [12] IEEE 802.11e: Amendment 8: Medium Access Control (MAC) Quality of Service Enhancements, 2005.

PAGE 59

51 [13] Wi Fi Alliance, "WMM Sp ecification", v1.2, 2012, http://www.wi fi.org/knowledge_center/published specifications [14] http://www.nsnam.org/ [15] https://openwrt.org/ [16] IEEE 802.11ac/D2.0: Amendment 4: Enhancements for Very High Throughput for Operation in Bands below 6 GHz, 2012. [17 ] Heusse, Martin, et al. "Idle sense: an optimal access method for high throughput and fairness in rate diverse wireless LANs." ACM SIGCOMM Computer Communication Review Vol. 35. No. 4. ACM, 2005. [18 ] Nassiri, Mohammad, Martin Heusse, and Andrzej Duda. "A novel access method for supporting absolute and proportional priorities in 802.11 WLANs." INFOCOM 2008. The 27th Conference on Computer Communications. IEEE IEEE, 2008. [19] Huang, Ching Ling, and Wanjiun Liao. "Throughput and delay performance of IEEE 802.11 e enhanced distributed channel access (EDCA) under saturation condition." Wireless Co mmunications, IEEE Transactions on 6.1 (2007): 136 145. [20] Tinnirello, Ilenia, Giuseppe Bianchi, and Luca Scalia. "Performance evaluation of differentiated access mechanisms effectiveness in 802.11 networks." Global Telecommunications Conference, 2004. G LOBECOM'04. IEEE Vol. 5. IEEE, 2004. [21] Rajmic, Pavel, Dan Komosny, and Karol Moln‡r. "Theoretical Analysis of EDCA Medium Access Control Method in Simplified Network Environment." Networks, 2009. ICN'09. Eighth International Conference on IEEE, 2009. [ 22] Rajmic, P., et al. "Optimized Algorithm for Probabilistic Evaluation of Enhanced Distributed Coordination Access According to IEEE 802. 11e." Proceedings of the 33rd International Conference Telecommunications and Signal Processing Baden bei Wien, 201 0, 297 303 [24] Li, Bo, and Roberto Battiti. "Performance analysis of an enhanced IEEE 802.11 distributed coordination function supporting service differentiation." Quality for all Springer Berlin Heidelberg, 2003. 152 161. [25] Yang, Yaling, Jun Wang, a nd Robin Kravets. "Distributed optimal contention window control for elastic traffic in wireless LANs." INFOCOM 2005. 24th Annual Joint Conference of the IEEE Computer and Communications Societies. Proceedings IEEE Vol. 1. IEEE, 2005. [26] Yoon J, Yun S, Kim H, Bahk S. Maximizing differentiated throughput in IEEE 802.11e wireless LANs. In: Ken C, Matthias F, eds. Proc. of the 31st IEEE Conf. on Local Computer Networks. Los Alamitos: IEEE Computer Society, 2006. 411" 417. [27] J.C. Mogul, S. E. Deering "RFC 1191, Path MTU discovery [ November 1990 ] (TXT = 47936) (Obsoletes RFC1063) (Status: DRAFT STANDARD) (Stream: Legacy) [28] Dunn, Joseph, et al. "A practical cross layer mechanism for fairness in 802.11 networks." Broadband Networks, 2004. BroadNets 2004. Proceedings. First International Conference on IEEE, 2004.

PAGE 60

52 APPENDIX A : Device Data FCC Published Testing Data Phone/Tablet Peak Tx Power Measured (SARS) Antenna Specs. iPhone 27 ipod touch A1288 24.24 1.5dbi iPod Touch A1318 10.73 1.dbi iPad2 A1395 13.94 .6dbi iPhone 3gs A1303 26.69 1.2dbi iPad A1219 22.8 3.8dbi HTC Vigor PH98100 21.7 2dbi HTC Evo Shift 4G PG06100 21.66 2dbi Droid Incredible PB31200 21.6 Laptops Intel PRO/Wireless 3945ABG 24.94 .9dBi Intel Centrino Wireless N 2200 16.5 2.6dBi Lenovo Thinkpad x200 Intel Wi Fi link 5300 29.5 1.3dBi Intel Wif link 5100 18.6 Dell PP02X Precision M60 Peak TX Power Antenna Gain Average of FCC Testing Data 22 1 *Data aggregated, not all data available for all devices. Web Search Device Data Product Chipset TX peak power (dBm) RX Sensitivity (dBm) HTC EVO 4G BCM4329 18 Nokia N8 TI WL1271A 20 89 HTC Droid Incredible BCM4329 18 Google Nexus One BCM4329 18 Palm Pre Plus Marvell W8686 16 82 HTC HD2 BCM4329 18 Motorola Droid TI WL1271A 20 89 iPhone 4 BCM4329 18 HTC Thunderbolt BCM4329 18 Sony Ericsson Xperia Play BCM4329 18 Motorola Atrix BCM4329 18 Motorola Droid X TI WL1273 18 87

PAGE 61

53 Product Chipset TX peak power (dBm) RX Sensitivity (dBm) Nook TI WL1273 18 87 iPhone 2G Marvell W8686 16 82 iPhone3G Marvell W8686 16 82 iPod Touch 1G Marvell W8686 16 82 iPod Touch 3G BCM4329 18 Samsung Galaxy S1 BCM4329 18 iPad BCM4329 18 iPad2 BCM4329 18 Xoom BCM4329 18 Samsung Galaxy Tab BCM4329 18 Samsung Galaxy S 4G BCM4329 18 Google Nexus S BCM4329 18 Blackberry Torch 9800 TI WL1271A 20 89 BelAir 100SNE 38 102 Cisco Aironet 1520 28 92 Rukus Strand Mounted 7761cm 27 Average of web data 19 88

PAGE 62

54 APPENDIX B : NS 3 Simulation Code /* Mode:C++; c file style:"gnu"; indent tabs mode:nil; */ /* This is the code for Joey Padden's independent study of Wi Fi QoS motivation. This is based on the NS 3 third example application.*/ #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" usi ng namespace ns3; NS_LOG_COMPONENT_DEFINE ("IndependentStudy"); int main (int argc, char *argv[]) { //default values for configurable params uint32_t nCsma = 0; uint32_t nWifi = 2; uint32_t maxBytes = 0; //build node container for p2p nodes NodeContainer p2pNodes; p2pNodes.Create (2); //establish point to point link attributes PointToPointHelper pointToPoint; pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("50Mbps")); pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms")); //build p2p netdeivces NetDeviceContainer p2pDevices; p2pDevices = pointToPoint.Install (p2pNodes);

PAGE 63

55 //create the node container to hold the csma devices(AP and //wired device N IC cards) NodeContainer csmaNodes; csmaNodes.Add (p2pNodes.Get (1)); csmaNodes.Create (nCsma); //setup the cmsa link using the cmsahelper CsmaHelper csma; csma.SetChannelAttribute ("DataRate", StringValue ("100Mbps")); csma.SetChannelAttribu te ("Delay", TimeValue (NanoSeconds (6560))); //define csma devices NetDeviceContainer csmaDevices; csmaDevices = csma.Install (csmaNodes); //create node container for wifi fixed client and AP NodeContainer wifiStaNodes; wifiStaNodes.Create ( nWifi); NodeContainer wifiApNode = p2pNodes.Get (0); //create node container and device for moving wifi client NodeContainer movingStaNode; movingStaNode.Create (1); //use yans to setup wifi phy and channel YansWifiChannelHelper channel = YansWifiChannelHelper::Default (); YansWifiPhyHelper phy = YansWifiPhyHelper::Default (); phy.SetChannel (channel.Create ()); //set trace type to include radiotap headers for SNR, sig power, //and phy rate for us e in finding the airtime and throughput phy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO); //setup the wifihelper with default settings WifiHelper wifi = WifiHelper::Default (); wifi.SetRemoteStationManager ("ns3::AarfWifiManager") ; //setup wifi mac, simple DCF no qos mode NqosWifiMacHelper mac = NqosWifiMacHelper::Default (); //initialize SSID and AP behavior Ssid ssid = Ssid ("ns 3 ssid");

PAGE 64

56 mac.SetType ("ns3::StaWifiMac", "Ssid", SsidValue (ssid), "ActiveProbing", BooleanValue (false)); //add wifi devices to node contatianer and apply phy and mac created NetDeviceContainer staDevices; staDevices = wifi.Install (phy, mac, wifiStaNodes); NetDeviceContainer movingStaDevice; movingStaDevice = wifi.Install (phy, mac, movingStaNode); //configure mac for the SSID mac.SetType ("ns3::ApWifiMac", "Ssid", SsidValue (ssid)); //add AP to ap container NetDeviceContainer apDevices; apDevices = wifi.Install (phy, mac, wifiApNode); //create one mobility helper for the fixed client and AP MobilityHelper mobility; mobility.SetPositionAllocator ("ns3::GridPositionAllocator", "MinX", DoubleValue (0.0), "MinY", DoubleValue (0.0), "DeltaX", DoubleValue (0.0), "DeltaY", DoubleValue (0.0), "GridWidth", UintegerValue (1), "LayoutType", StringValue ("RowFirst")); mobility.Install (wifiStaNodes); mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); mobility.Install (wifiApNode); //create second mobility helper for moving client. By adjusting //MinY you can move the client the desired distance from the AP MobilityHelper mobility2; mobility2.SetPositionAllocator ("ns3::GridPositionAllocator", "MinX", DoubleValue (0.0), "Min Y", DoubleValue (115.0),

PAGE 65

57 "DeltaX", DoubleValue (0.0), "DeltaY", DoubleValue (0.0), "GridWidth", UintegerValue (1), "LayoutTy pe", StringValue ("RowFirst")); mobility2.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); mobility2.Install (movingStaNode); //install IP stack on all devices InternetStackHelper stack; stack.Install (csmaNodes); stack.Install (wifiAp Node); stack.Install (wifiStaNodes); stack.Install (movingStaNode); //DHCP all devices to get addresses. There are three networks to make //traffic tracability tractable. Ipv4AddressHelper address; address.SetBase ("10.1.1.0", "255.255.255.0 "); Ipv4InterfaceContainer p2pInterfaces; p2pInterfaces = address.Assign (p2pDevices); address.SetBase ("10.1.2.0", "255.255.255.0"); Ipv4InterfaceContainer csmaInterfaces; csmaInterfaces = address.Assign (csmaDevices); address.SetBase ("10.1.3.0", "255.255.255.0"); address.Assign (movingStaDevice); address.Assign (staDevices); address.Assign (apDevices); // Create a BulkSendApplication and install it on wireless nodes uint16_t port = 9; Ipv4GlobalRoutingH elper::PopulateRoutingTables (); BulkSendHelper source ("ns3::TcpSocketFactory", InetSocketAddress (csmaInterfaces.GetAddress (nCsma), port)); source.SetAttribute ("MaxBytes", UintegerValue (maxBytes)); ApplicationContainer s ourceApps = source.Install (wifiStaNodes.Get (1)); sourceApps.Add (source.Install(movingStaNode.Get(0))); sourceApps.Start (Seconds (0.0)); sourceApps.Stop (Seconds (60.0));

PAGE 66

58 // Create a PacketSinkApplication and install it on wired node Pac ketSinkHelper sink ("ns3::TcpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), port)); ApplicationContainer sinkApps = sink.Install (csmaNodes.Get (nCsma)); sinkApps.Start (Seconds (0.0)); sinkApps.Stop (Seconds (55. 0)); Simulator::Stop (Seconds (65.0)); //configure tracing parameters pointToPoint.EnablePcapAll ("third"); phy.EnablePcapAll ("third", false); csma.EnablePcap ("third", csmaDevices.Get (0), true); //run simulation Simulator::Run (); Simulator::Destroy (); return 0; }

PAGE 67

59 APPENDIX C : Airtime Analysis Python Script The script below was adapted from a script from the OLPC computer company. Their airtime computation did not accurately account for overhead. In addition, the lower physical layer data rates were added because they were not previously included. Otherwise the input output processing was left as is. #!/usr/bin/python import sys import commands import math from optparse import OptionParser arguments = OptionParser() arguments.a dd_option(" f"," -pcap file", dest="pcapfile", help="Capture dump") arguments.add_option(" t"," -text file", dest="textfile", help="Capture already converted/filtered") arguments.add_option(" i"," -interval", dest="interval", help="Consolidation interval in seconds") arguments.add_option(" w"," -filter", dest="filter", help="Wireshark filt er") arguments.add_option(" o"," -output format", dest="output", help="Output Format [csv, lines] ") arguments.add_option(" -no fcs", action="store_false", dest="crc", default=True, help="don't check if frames have bad crc") (options, args) = arguments.parse_args() if not (options.pcapfile or options.textfile) : print "input file is mandatory"

PAGE 68

60 sys.exit(0) filter_exp = '' filte r = '' if options.crc == True: filter += 'wlan.fcs_good == 1' if options.filter: filter += and '+options.filter else: filter += options.filter if options.crc or options.filter: filter_exp = R "'+filter+'"' if options.pcapfile: pcapfile = options.pcapfile inputfile = pcapfile if options.textfile: textfile = options.textfile inputfile = textfile else: textfile = pcapfile+'.tmp3' filter_cmd='tshark r %s %s T fields e frame.time_relative e radiotap.datarate e frame.len > %s' % (pcapfile, filter_exp, textfile) s, o = commands.getstatusoutput(filter_cmd) if options.interval: interval = float(options.interval) else: interval = 1 timeslot = 0 lastslot = 0 airtime = [0] fd = open(textfile, 'r') cck_datarate s = ('2', '4', '11', '22') ofdm_datarates = ('6', '9', '12', '18', '24', '36', '48', '72', '96', '108') for line in fd: time, rate, size = line.split(' \ t') size = size.strip(' \ n') if rate in cck_datarates: airsize = 192 + float(size) 16 / float (rate) elif rate in ofdm_datarates: airsize = 10 + 28 + 24 + 4 math.ceil(((float(size)) 8 + 6) / (float (rate) 4)) else: airsize = 0 timeslot = int(math.floor(float(time) / interval))

PAGE 69

61 if timeslot > lastslot: for slot in range(lastslot, timeslot): airtime.append(0) airtime[timeslot] += airsize / (interval 1000000) lastslot = timeslot if options.output == "csv": for i in airtime: print str(i)+',', else: for i in range(0, len( airtime)): print "[%s %s): %.2f%%" % (i*interval, (i+1)*interval, airtime[i] 100)

PAGE 70

62 APPENDIX D : OpenWrt Router Configuration The AP used for device testing was a Netgear WNDR 3800 hardware running OpenWRT software version 12.09 The pertinent conf iguration files are below. Prior to testing the wireless environment was scanned. It wa s determined that 5Ghz channel 3 6 was not occupied by any networks so this channel was used for testing to ensure no co channel interference outside of the testing was p roduced. Network Configuration config 'interface' 'loopback' option 'ifname' 'lo' option 'proto' 'static' option 'ipaddr' '127.0.0.1' option 'netmask' '255.0.0.0' config 'interface' 'lan' option 'ifname' 'eth0' option 'type' 'bridge' option 'proto' 'static' option 'netmask' '255.255.0.0' option 'defaultroute' '0' option 'peerdns' '0' option 'ipaddr' '10.32.115.2' option 'gateway' '10.32.115.1' config 'interface' 'wan' option 'ifname' 'eth1' option 'proto' 'dhcp' config 'switch' opti on 'name' 'rtl8366s' option 'reset' '1' option 'enable_vlan' '1' option 'blinkrate' '2' config 'switch_vlan' option 'device' 'rtl8366s'

PAGE 71

63 option 'vlan' '0' option 'ports' '0 1 2 3 5' config 'switch_port' option 'device' 'rtl8366s' option 'port' '1' option 'led' '9' config 'switch_port' option 'device' 'rtl8366s' option 'port' '2' option 'led' '6' config 'switch_port' option 'device' 'rtl8366s' option 'port' '5' option 'led' '6' config 'interface' 'lan2' option 'ifname' 'eth0' option 'proto' 'static' option 'ipaddr' '10.50.151.2' option 'netmask' '255.255.0.0' option 'gateway' 10.50.101.1' Wireless Configuration config 'wifi device' 'radio0' option 'type' 'mac80211' option 'macaddr' '30:46:9a:1c:57:fe' option 'hwmode' '11ng' option 'htmode' 'HT20' list 'ht_capab' 'SHORT GI 40' list 'ht_capab' 'DSSS_CCK 40' option 'disabled' '1' option 'channel' '1' option 'txpower' '8' config 'wifi iface' option 'device' 'radio0' option 'network' 'lan' option 'mode' 'ap' option 'ssid' 'OpenWrt'

PAGE 72

64 option 'encryption' 'none' config 'wifi device' 'radio1' option 'type' 'mac80211' option 'channel' '40' option 'macaddr' '30:46:9a:1c:58:00' option 'hwmode' '11na' option 'htmode' 'HT20' list 'ht_capab' 'SHORT GI 40' list 'ht_capa b' 'DSSS_CCK 40' option 'disabled' '0' option 'txpower' '8' config 'wifi iface' option 'device' 'radio1' option 'network' 'lan' option 'mode' 'ap' option 'ssid' 'OpenWrt' option 'encryption' 'none' config 'wifi iface' option 'device' 'radio1' op tion 'ssid' 'OpenWrt2' option 'network' 'lan' option 'mode' 'ap' option 'encryption' 'none'

PAGE 73

65 APPENDIX E : OpenWrt Dynamic CWmin Implementation Code The OpenWrt version 12.09 "Attitude Adjustment" was used for this project. The application hostapd wpad mini" was installed to run the access point functions of the router. The following files were modified to support the implementation of the algorithm discussed above: "& /00&1 $ *& /00&2 $ %& 345678&1 $ '& 297834:&1 $ The following appendix provides the entire code for each file. Search for "JRP" to find the modified sections of the code. The primary logic and modification occurs in wmm.c and aplist.c. The other files contain necessary actions for initialization and clean up. Most of the work consisted of adding funct ionality not present in the OpenWrt code. However, in the aplist.c file, the behavior was modified. In this case, code was commented out to prevent unwanted behavior. Thus, this commented out code remains in the documentation below. WMM.C Ful l path: /Volumes/OpenWrtAA/openwrt/build_dir/target mips_r2_uClibc 0.9.33.2/hostapd wpad mini/hostapd 20130405/src/ap /wmm.c /* hostapd / WMM (Wi Fi Multimedia) Copyright 2002 2003, Instant802 Networks, Inc. Copyright 2005 2006, Devicescape Softw are, Inc. Copyright (c) 2009, Jouni Malinen 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. Alternatively, this software may be distributed under the terms of BSD license. See README and COPYING for more details. */

PAGE 74

66 #include "utils/includes.h" #include "utils/common.h" #include "common/ieee802_11_defs.h" #include "common/ieee802_11 _common.h" #include "hostapd.h" #include "ieee802_11.h" #include "sta_info.h" #include "ap_config.h" #include "ap_drv_ops.h" #include "wmm.h" //JRP added #include #include "syslog.h" /* TODO: maintain separate sequence and fragment numbers f or each AC TODO: IGMP snooping to track which multicasts to forward and use QOS DATA if only WMM stations are receiving a certain group */ static inline u8 wmm_aci_aifsn(int aifsn, int acm, int aci) { u8 ret; ret = (aifsn << WMM_AC_AIFNS_SHIFT) & WMM_AC_AIFSN_MASK; if (acm) ret |= WMM_AC_ACM; ret |= (aci << WMM_AC_ACI_SHIFT) & WMM_AC_ACI_MASK; return ret; } static inline u8 wmm_ecw(int ecwmin, int ecwmax) { return ((ecwmin << WMM_AC_ECWMIN_SHIFT) & WMM_AC_ECWMIN_MASK) | ((ecwmax << WMM _AC_ECWMAX_SHIFT) & WMM_AC_ECWMAX_MASK); } //JRP adding to check which AP we are updating for. static inline int mainssid(struct hostapd_data *hapd) { u8 mymac[ETH_ALEN]; mymac[0] = 0x20; mymac[1] = 0x4e; mymac[2] = 0x7f; mymac[3] = 0x4a; mymac[4] = 0x98; mymac[5] = 0x44; int ret; ret = memcmp(mymac,hapd >own_addr,6); return ret; } //JRP added find active STA cnt in OpenWrt network static inline int active_sta_openwrt(int *minrate) { DIR *dir; struct dirent *ep; char Filenam e[84]; char Filename2[88]; char Filename3[85]; int active_cnt = 0; int value = 1001; int value2 = NULL; int value3 = NULL;

PAGE 75

67 if ((dir = opendir("/sys/kernel/debug/ieee80211/phy1/netdev:wlan1/stations/")) == NULL) { syslog(LOG_INFO,"Cannot open directory for stations on wlan1"); return 0; }else { while ((ep = readdir (dir))){ if(strncmp(ep >d_name,".",1) && strncmp(ep >d_name,"..",2)){ //formulate filename to find i nactive ms time for this client strcpy(Filename,"/sys/kernel/debug/ieee80211/phy1/netdev:wlan1/stations/"); strcat(Filename,ep >d_name); strcat(Filename,"/inactive_ms"); FILE *inputdata; inputdata = NULL; inputdata = fopen(Filename,"r"); //open next file if (inputdata) { fscanf(inputdata,"%d",&value); fclose (inputdata); } if (value < 1000) { active_c nt++; //formulate filename to find tx rate for this client strcpy(Filename2,"/sys/kernel/debug/ieee80211/phy1/netdev:wlan1/stations/"); strcat(Filename2,ep >d_name); strcat(Filename2,"/cu rrent_tx_rate"); FILE *inputdata2; inputdata2 = NULL; inputdata2 = fopen(Filename2,"r"); //open next file if (inputdata2) { fscanf(inputdata2,"%d.",&value2); fclose (inputdata2); } if (*minrate == NULL) *minrate = value2; else if (value2 < *minrate) *minrate = value2; //formulate filename to find inactive ms time for this cli ent strcpy(Filename3,"/sys/kernel/debug/ieee80211/phy1/netdev:wlan1/stations/"); strcat(Filename3,ep >d_name); strcat(Filename3,"/last_rx_rate"); FILE *inputdata3; inputd ata3 = NULL; inputdata3 = fopen(Filename3,"r"); //open next file if (inputdata3) { fscanf(inputdata3,"%d.",&value3); fclose (inputdata3); } if (*minrate == NULL) *minrate = value3; else if (value3 < *minrate) *minrate = value3; } } }

PAGE 76

68 closedir(dir); return active_cnt; } } //JRP added find active STA cnt in OpenWrt2 network stat ic inline int active_sta_openwrt2(int *minrate) { DIR *dir; struct dirent *ep; char Filename[86]; char Filename2[90]; char Filename3[87]; int active_cnt = 0; int value = 1001; int value2 = NULL; int value3 = NULL; if ((dir = opendir("/sys/kernel/debug/ieee80211/phy1/netdev:wlan1 1/stations/")) == NULL) { syslog(LOG_INFO,"Cannot open directory for stations on wlan1 1"); return 0; }else { while ((ep = readdir (dir))){ if(strncmp(ep >d _name,".",1) && strncmp(ep >d_name,"..",2)){ //formulate filename to find inactive ms time for this client strcpy(Filename,"/sys/kernel/debug/ieee80211/phy1/netdev:wlan1 1/stations/"); strcat (Filename,ep >d_name); strcat(Filename,"/inactive_ms"); FILE *inputdata; inputdata = NULL; inputdata = fopen(Filename,"r"); //open next file if (inputdata) { fscanf(inputdata ,"%d",&value); fclose (inputdata); } if (value < 1000) { active_cnt++; //formulate filename to find inactive ms time for this client strcpy(Filename2,"/sys/kernel/debug/ieee80211/phy1/netdev:wlan1 1/stations/"); strcat(Filename2,ep >d_name); strcat(Filename2,"/current_tx_rate"); FILE *inputdata2; inputd ata2 = NULL; inputdata2 = fopen(Filename2,"r"); //open next file if (inputdata2) { fscanf(inputdata2,"%d.",&value2); fclose (inputdata2); } if (*minrate == NULL) *minrate = value2; else if (value2 < *minrate) *minrate = value2; //formulate filename to find inactive ms time for this client strcpy(Filename3,"/sys/kernel/debug/ieee80211/phy1/netdev:wlan1 1/ stations/"); strcat(Filename3,ep >d_name); strcat(Filename3,"/last_rx_rate");

PAGE 77

69 FILE *inputdata3; inputdata3 = NULL; inputdata3 = fopen(Filename3,"r"); //open next file if (inputdata3) { fscanf(inputdata3,"%d.",&value3); fclose (inputdata3); } if (*minrate == NULL) *minrate = value3; else if (value3 < *minrate) *minrate = value3; } } } closedir(dir); return active_cnt; } } //JRP added find the rx byte count in OpenWrt network static inline int bytes_openwrt(void) { DIR *dir; struct dirent *ep; char Filename[81]; int bytes = 0; int value = 0; if ((dir = opendir("/sys/kernel/debug/ieee80211/phy1/netdev:wlan1/stations/")) == NULL) { syslog(LOG_INFO,"Cannot open directory for stations on wlan1"); return 0; }else { while ((ep = readdir (dir))){ if(strncmp(ep >d_name,".",1) && strncmp(ep >d_name,"..",2)){ //formulate filename to find inactive ms time for this client strcpy(Filename,"/sys/kernel/debug/ieee802 11/phy1/netdev:wlan1/stations/"); strcat(Filename,ep >d_name); strcat(Filename,"/rx_bytes"); FILE *inputdata; inputdata = NULL; inputdata = fopen(Filename,"r"); //open next file if (inputdata) { fscanf(inputdata,"%d.",&value); fclose (inputdata); } bytes += value; } } closedir(dir); return bytes; } } //JRP get bytes rx in OpenWrt2 network static inline int bytes_openwrt2(void)

PAGE 78

70 { DIR *dir; struct dirent *ep; char Filename[83]; int bytes = 0; int value = 0; if ((dir = opendir("/sys/kernel/debug/ieee80211/phy1/netdev:wlan1 1/stations/")) == NULL) { syslog(LOG_INFO,"Cannot open direc tory for stations on wlan1 1"); return 0; }else { while ((ep = readdir (dir))){ if(strncmp(ep >d_name,".",1) && strncmp(ep >d_name,"..",2)){ //formulate filename to find inactive ms time for this client strcpy(Filename,"/sys/kernel/debug/ieee80211/phy1/netdev:wlan1 1/stations/"); strcat(Filename,ep >d_name); strcat(Filename,"/rx_bytes"); FILE *inputdata; inputdata = NULL; inputdata = fopen(Filename,"r"); //open next file if (inputdata) { fscanf(inputdata,"%d.",&value); fclose (inputdata); } bytes += value; } } closedir(dir); return bytes; } } //JRP get the number of total STAs in OpenWrt static inline int sta_cnt_openwrt(void) { DIR *dir; struct dirent *ep; char Filename[59]; int bytes = 0; int value = 0; //formulate filename to find inactive ms time for this client strcpy(Filename,"/sys/kernel/debug/ieee80211/phy1/netdev:wlan1/num_mcast_sta"); FILE *inputdata; inputdata = NULL; inputdata = fopen(Filename,"r"); //open next file if (inputdata) { fscanf(inputdata,"%d.",&value); fclose (inputdata); } bytes += value; return bytes;

PAGE 79

71 } //JRP get the number of total STAs in OpenWrt2 static inline int sta_cnt_openwrt2(void) { DIR *dir; struct dirent *ep; char Filename[61]; int bytes = 0; int value = 0; //formulate filename to find inactive ms time for this client strcpy(Filename,"/sys/kernel/debug/ieee80211/phy1/netdev:wlan1 1/num_mcast_sta"); FILE *inputdata; inputdata = NULL; inputdata = fopen(Filename,"r"); //open next file if (inputdata) { fscanf(inputdata,"%d.",&value); fclose (inputdata); } bytes += value; return bytes; } /* Add WMM Parameter Element to Beacon, Probe Response, and (Re)Association Response frames. */ u8 hostapd_eid_wmm(struct hostapd_data *hapd, u8 *eid) { u8 *pos = eid; struct wmm_parameter_element *wmm = (struct wmm_parameter_element *) (pos + 2) ; int e; //JRP variables int activecnt = NULL; int activecnt2 = NULL; int stacnt = NULL; int stacnt2 = NULL; int bytes = NULL; int bytes2 = NULL; int minrate2 = NULL; int minrate = NULL; int ssidtest = NULL; double tput = 0.0; double tput2 = 0 .0; int printac = 0; int cwmin2 = 5; float cwdeltaf = 0.0; float cwdeltac = 0.0; int cwdelta = 0; int cwdelta2 = 0; openlog ("wmm.c", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL0); if (!hapd >conf >wmm_enabled) return eid; //JRP check if we are in OpenWrt SSID Beacon Frame

PAGE 80

72 ssidtest = mainssid(hapd); //JRP if we are in OpenWrt2 SSID Beacon Frame, then fetch STA count in each BSS. if (ssidtest!=0) { activecnt = active_sta_openwrt(&minrate); activecnt2 = active_sta_openwrt2(&minrate2); //shift old paramhist to slot 0 paramhist[0] = paramhist[1]; //JRP get stacnt for each network, ensures oldbyte count is valid to use right now. stacnt = sta_cnt_openwrt(); stacnt2 = sta_cnt_openwrt2(); //JRP do tput calculation for OpenWrt if old stored numbers are valid, otherwise update //stored numbers and wait for next round. if (stacnt == oldstacnt) { bytes = bytes_openwrt(); tput = (bytes oldbytes)*8/2; oldbytes = bytes; } else { oldstacnt = stacnt; oldbytes = bytes; syslog(LOG_INFO,"STA joined or left OpenWrt, tput count is borked for this interval"); } //JRP do tput calculation for OpenWrt if old stored numbers are valid, otherwise update stored //numbers and wait for next round. if (stacnt2 == ol dstacnt2) { bytes2 = bytes_openwrt2(); tput2 = (bytes2 oldbytes2)*8/2; oldbytes2 = bytes2; } else { oldstacnt2 = stacnt2; oldbytes2 = bytes2; syslog(LOG_INFO,"STA joined or left OpenWrt2, tput count is borked for this interval"); } //JRP find cwmin of public network if (minrate != 0 && minrate2 != 0) { if (minrate > minrate2) { minrate = minrate2; } cwdeltaf = 1.442695040888964 log(2 40 / (float)minrate); cwdeltac = 1.442695040888964 log(( activecnt + activecnt2) / (float)activecnt); cwdelta = (int)(cwdeltaf + 0.5); cwdelta2 = (int)(cwdeltac + 0.5); if (cwdelta > 0) { cwmin2 = cwmin2 + cwdelta; } if (cwdelta2 > 0){ cwmin2 = cwmin2 + cwdelta2; } if (cwmin2 > 10) cwmin2 = 10; } } eid[0] = WLAN_EID_VENDOR_SPECIFIC; wmm >oui[0] = 0x00; wmm >oui[1] = 0x50; wmm >oui[2] = 0xf2;

PAGE 81

73 wmm >oui_type = WMM_OUI_TYPE; wmm >oui_subtype = WMM_OUI_SUBTYPE_PARAMETER_ELEMENT; wmm >version = WMM_VERSION; //wmm >qos_info = hapd > parameter_set_count & 0xf; if (hapd >conf >wmm_uapsd && (hapd >iface >drv_flags & WPA_DRIVER_FLAGS_AP_UAPSD)) wmm >qos_info |= 0x80; wmm >reserved = 0; /* fill in a parameter set record for each AC */ for (e = 0; e < 4; e++) { struct wmm _ac_parameter *ac = &wmm >ac[e]; struct hostapd_wmm_ac_params *acp = &hapd >iconf >wmm_ac_params[e]; //JRP adding logic for cwmin adjustments for BE ac e = 0 if (e == 0 && ssidtest != 0) { acp >cwmin = cwmin2; syslog (LOG_INFO, "AC %d A IFS = %d, CWmin = %d, CWmax = %d, TXop = %d, minrate = %d, minrate2 = %d, tput = %.2f, tput2 = %.2f, cwdeltaf = %.2f, cwdelta =%d, cwdeltac = %.2f, cwdelta2 = %d", e, acp >aifs,acp >cwmin, acp >cwmax,acp >txop_limit,minrate,minrate2,tput,t put2,cwdeltaf, cwdelta,cwdeltac,cwdelta2); paramhist[1] = cwmin2; } else if(e == 0){ acp >cwmin = 4; } ac >aci_aifsn = wmm_aci_aifsn(acp >aifs, acp >admission_control_mandatory, e); ac >cw = wmm_ecw(acp > cwmin, acp >cwmax); ac >txop_limit = host_to_le16(acp >txop_limit); } //JRP if the params have changed then increment the param_set_count for the hapd we are in. if ( (ssidtest != 0) && (paramhist[0] != paramhist[1]) ) { hapd >parameter_set_coun t++; } //JRP update parameter set count element. the 0xf bit is to prevent sending in a too big //a number it cuts is off at 16 bit number wmm >qos_info = hapd >parameter_set_count & 0xf; pos = (u8 *) (wmm + 1); eid[1] = pos eid 2; /* eleme nt length */ closelog(); return pos; } /* This function is called when a station sends an association request with WMM info element. The function returns 1 on success or 0 on any error in WMM element. eid does not include Element ID and Length octets. */ int hostapd_eid_wmm_valid(struct hostapd_data *hapd, const u8 *eid, size_t len) { struct wmm_information_element *wmm;

PAGE 82

74 wpa_hexdump(MSG_MSGDUMP, "WMM IE", eid, len); if (len < sizeof(st ruct wmm_information_element)) { wpa_printf(MSG_DEBUG, "Too short WMM IE (len=%lu)", (unsigned long) len); return 0; } wmm = (struct wmm_information_element *) eid; wpa_printf(MSG_DEBUG, "Validating WMM IE: OUI %02x:%02x:%02x "OUI typ e %d OUI sub type %d version %d QoS info 0x%x", wmm >oui[0], wmm >oui[1], wmm >oui[2], wmm >oui_type, wmm >oui_subtype, wmm >version, wmm >qos_info); if (wmm >oui_subtype != WMM_OUI_SUBTYPE_INFORMATION_ELEMENT || wmm >version != WMM_VERS ION) { wpa_printf(MSG_DEBUG, "Unsupported WMM IE Subtype/Version"); return 0; } return 1; } static void wmm_send_action(struct hostapd_data *hapd, const u8 *addr, const struct wmm_tspec_element *tspec, u8 action_code, u8 dialogue_token, u8 status_code) { u8 buf[256]; struct ieee80211_mgmt *m = (struct ieee80211_mgmt *) buf; struct wmm_tspec_element *t = (struct wmm_tspec_element *) m >u.action.u.wmm_action.variable; int len; hostapd_logger(ha pd, addr, HOSTAPD_MODULE_IEEE80211, HOSTAPD_LEVEL_DEBUG, "action response reason %d", status_code); os_memset(buf, 0, sizeof(buf)); m >frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT, WLAN_FC_STYPE_ACTION); os_memcpy(m >da, addr, ETH_ALEN); os_memcpy(m >sa, hapd >own_addr, ETH_ALEN); os_memcpy(m >bssid, hapd >own_addr, ETH_ALEN); m >u.action.category = WLAN_ACTION_WMM; m >u.action.u.wmm_action.action_code = action_code; m >u.action.u.wmm_action.dialog_token = dialogue_token; m >u.action.u.wmm_action.status_code = status_code; os_memcpy(t, tspec, sizeof(struct wmm_tspec_element)); len = ((u8 *) (t + 1)) buf; if (hostapd_drv_send_mlme(hapd, m, len, 0) < 0) perror("wmm_send_action: send"); } int wmm_process_tspec(struc t wmm_tspec_element *tspec) { int medium_time, pps, duration; int up, psb, dir, tid; u16 val, surplus; up = (tspec >ts_info[1] >> 3) & 0x07; psb = (tspec >ts_info[1] >> 2) & 0x01; dir = (tspec >ts_info[0] >> 5) & 0x03; tid = (tspec >ts_info[0] >> 1 ) & 0x0f; wpa_printf(MSG_DEBUG, "WMM: TS Info: UP=%d PSB=%d Direction=%d TID=%d", up, psb, dir, tid); val = le_to_host16(tspec >nominal_msdu_size); wpa_printf(MSG_DEBUG, "WMM: Nominal MSDU Size: %d%s", val & 0x7fff, val & 0x8000 ? (fixed)" : ""); wpa_printf(MSG_DEBUG, "WMM: Mean Data Rate: %u bps",

PAGE 83

75 le_to_host32(tspec >mean_data_rate)); wpa_printf(MSG_DEBUG, "WMM: Minimum PHY Rate: %u bps", le_to_host32(tspec >minimum_phy_rate)); val = le_to_host16(tspec > surplus_bandwidth_allowance); wpa_printf(MSG_DEBUG, "WMM: Surplus Bandwidth Allowance: %u.%04u", val >> 13, 10000 (val & 0x1fff) / 0x2000); val = le_to_host16(tspec >nominal_msdu_size); if (val == 0) { wpa_printf(MSG_DEBUG, "WMM: Invalid Nomin al MSDU Size (0)"); return WMM_ADDTS_STATUS_INVALID_PARAMETERS; } /* pps = Ceiling((Mean Data Rate / 8) / Nominal MSDU Size) */ pps = ((le_to_host32(tspec >mean_data_rate) / 8) + val 1) / val; wpa_printf(MSG_DEBUG, "WMM: Packets per second estimate for TSPEC: %d", pps); if (le_to_host32(tspec >minimum_phy_rate) < 1000000) { wpa_printf(MSG_DEBUG, "WMM: Too small Minimum PHY Rate"); return WMM_ADDTS_STATUS_INVALID_PARAMETERS; } duration = (le_to_host16(tspec >nominal_msdu_size) & 0x7fff) 8 / (le_to_host32(tspec >minimum_phy_rate) / 1000000) + 50 /* FIX: proper SIFS + ACK duration */; /* unsigned binary number with an implicit binary point after the leftmost 3 bits, i.e., 0x2000 = 1.0 */ surplus = le_to_host16(tspec >surplus_b andwidth_allowance); if (surplus <= 0x2000) { wpa_printf(MSG_DEBUG, "WMM: Surplus Bandwidth Allowance not "greater than unity"); return WMM_ADDTS_STATUS_INVALID_PARAMETERS; } medium_time = surplus pps duration / 0x2000; wpa_printf(MSG_DEBUG, "WMM: Estimated medium time: %u", medium_time); /* TODO: store list of granted (and still active) TSPECs and check whether there is available medium time for this request. For now, just refuse requests that would by them selves take very large portion of the available bandwidth. */ if (medium_time > 750000) { wpa_printf(MSG_DEBUG, "WMM: Refuse TSPEC request for over "75%% of available bandwidth"); return WMM_ADDTS_STATUS_REFUSED; } /* Convert to 32 mi croseconds per second unit */ tspec >medium_time = host_to_le16(medium_time / 32); return WMM_ADDTS_STATUS_ADMISSION_ACCEPTED; } static void wmm_addts_req(struct hostapd_data *hapd, const struct ieee80211_mgmt *mgmt, struct wmm_tspec_element *tspec, size_t len) { const u8 *end = ((const u8 *) mgmt) + len; int res; if ((const u8 *) (tspec + 1) > end) { wpa_printf(MSG_DEBUG, "WMM: TSPEC overflow in ADDTS Request"); return; } wpa_printf(MSG_DEBUG, "WMM: ADDTS Request (Dialog Token %d) for TSPEC

PAGE 84

76 "from MACSTR, mgmt >u.action.u.wmm_action.dialog_token, MAC2STR(mgmt >sa)); res = wmm_process_tspec(tspec); wpa_printf(MSG_DEBUG, "WMM: ADDTS processing result: %d", res); wmm_send_action(hapd, m gmt >sa, tspec, WMM_ACTION_CODE_ADDTS_RESP, mgmt >u.action.u.wmm_action.dialog_token, res); } void hostapd_wmm_action(struct hostapd_data *hapd, const struct ieee80211_mgmt *mgmt, size_t len) { int action_code; int left = len IEEE80211_HDRLEN 4; const u8 *pos = ((const u8 *) mgmt) + IEEE80211_HDRLEN + 4; struct ieee802_11_elems elems; struct sta_info *sta = ap_get_sta(hapd, mgmt >sa); /* check that the request comes from a valid station */ if (!sta || (sta >flags & (WLAN_STA_ASSOC | WLAN_STA_WMM)) != (WLAN_STA_ASSOC | WLAN_STA_WMM)) { hostapd_logger(hapd, mgmt >sa, HOSTAPD_MODULE_IEEE80211, HOSTAPD_LEVEL_DEBUG, "wmm action received is not from associated wmm" station"); /* TO DO: respond with action frame refused status code */ return; } /* extract the tspec info element */ if (ieee802_11_parse_elems(pos, left, &elems, 1) == ParseFailed) { hostapd_logger(hapd, mgmt >sa, HOSTAPD_MODULE_IEEE80211, HOSTAPD_LEVEL_ DEBUG, "hostapd_wmm_action could not parse wmm "action"); /* TODO: respond with action frame invalid parameters status code */ return; } if (!elems.wmm_tspec || elems.wmm_tspec_len != (sizeof(struct wmm_tspec_element) 2)) { hostapd_logger(hapd, mgmt >sa, HOSTAPD_MODULE_IEEE80211, HOSTAPD_LEVEL_DEBUG, "hostapd_wmm_action missing or wrong length "tspec"); /* TODO: respond with action frame invalid parameters status code */ return; } /* TODO: check the request is for an AC with ACM set, if not, refuse request */ action_code = mgmt >u.action.u.wmm_action.action_code; switch (action_code) { case WMM_ACTION_CO DE_ADDTS_REQ: wmm_addts_req(hapd, mgmt, (struct wmm_tspec_element *) (elems.wmm_tspec 2), len); return; #if 0 /* TODO: needed for client implementation */ case WMM_ACTION_CODE_ADDTS_RESP: wmm_setup_request(hapd, mgmt, len); return; /* TODO: handle station teardown requests */

PAGE 85

77 case WMM_ACTION_CODE_DELTS: wmm_teardown(hapd, mgmt, len); return; #endif } hostapd_logger(hapd, mgmt >sa, HOSTAPD_MODULE_IEEE80211, HOSTAPD_LEVEL_DEBUG, "hostapd_wmm_action unknown action code %d", action_code); } WMM.H Full Path: /Volumes/OpenWrtAA/openwrt/build_dir/target mips_r2_uClibc 0.9.33.2/hostapd wpad mini/hostapd 20130405/src/ap /wmm.h /* hostapd / WMM (Wi Fi Mu ltimedia) Copyright 2002 2003, Instant802 Networks, Inc. Copyright 2005 2006, Devicescape Software, Inc. 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. Alternatively, this software may be distributed under the terms of BSD license. See README and COPYING for more details. */ #ifndef WME_H #define WME_H struct ieee80211_mgmt; struct wmm_tspec_element; //JRP added u8 paramhist[2]; int oldbytes; int oldbytes2; int oldstacnt; int oldstacnt2; u8 hostapd_eid_wmm(struct hostapd_data *hapd, u8 *eid); int hostapd_eid_wmm_valid(struct hostapd_data *hapd, const u8 *eid, size_t len); vo id hostapd_wmm_action(struct hostapd_data *hapd, const struct ieee80211_mgmt *mgmt, size_t len); int wmm_process_tspec(struct wmm_tspec_element *tspec); #endif /* WME_H */ APLIST.C Full Path: /Volumes/OpenWrtAA/openwrt/build_dir/target mips_r2_uClibc 0.9.33.2/hostapd wpad mini/hostapd 20130405/src/ap /aplist.c /* hostapd / AP table Copyright (c) 2002 2009, Jouni Malinen Copyright (c) 2003 2004, Instant802 Networks, Inc. Co pyright (c) 2006, Devicescape Software, Inc. This software may be distributed under the terms of the BSD license. See README for more details.

PAGE 86

78 */ #include "utils/includes.h" #include "utils/common.h" #include "utils/eloop.h" #include "common/ie ee802_11_defs.h" #include "common/ieee802_11_common.h" #include "drivers/driver.h" #include "hostapd.h" #include "ap_config.h" #include "ieee802_11.h" #include "sta_info.h" #include "beacon.h" #include "ap_list.h" /* AP list is a double linked list with head >prev pointing to the end of the list and tail >next = NULL. Entries are moved to the head of the list whenever a beacon has been received from the AP in question. The tail entry in this link will thus be the least recently used entry. */ s tatic int ap_list_beacon_olbc(struct hostapd_iface *iface, struct ap_info *ap) { int i; if (iface >current_mode >mode != HOSTAPD_MODE_IEEE80211G || iface >conf >channel != ap >channel) return 0; if (ap >erp != 1 && (ap >erp & ERP_INFO_NON_ERP_ PRESENT)) return 1; for (i = 0; i < WLAN_SUPP_RATES_MAX; i++) { int rate = (ap >supported_rates[i] & 0x7f) 5; if (rate == 60 || rate == 90 || rate > 110) return 0; } return 1; } static struct ap_info ap_get_ap(struct hostapd_iface *iface, const u8 *ap) { struct ap_info *s; s = iface >ap_hash[STA_HASH(ap)]; while (s != NULL && os_memcmp(s >addr, ap, ETH_ALEN) != 0) s = s >hnext; return s; } static void ap_ap_list_add(struct hostapd_iface *iface, struct ap_info *ap) { if (if ace >ap_list) { ap >prev = iface >ap_list >prev; iface >ap_list >prev = ap; } else ap >prev = ap; ap >next = iface >ap_list; iface >ap_list = ap; } static void ap_ap_list_del(struct hostapd_iface *iface, struct ap_info *ap) { if (iface >ap_list == ap)

PAGE 87

79 iface >ap_list = ap >next; else ap >prev >next = ap >next; if (ap >next) ap >next >prev = ap >prev; else if (iface >ap_list) iface >ap_list >prev = ap >prev; } static void ap_ap_hash_add(struct hostapd_iface *iface, struct ap_info *ap ) { ap >hnext = iface >ap_hash[STA_HASH(ap >addr)]; iface >ap_hash[STA_HASH(ap >addr)] = ap; } static void ap_ap_hash_del(struct hostapd_iface *iface, struct ap_info *ap) { struct ap_info *s; s = iface >ap_hash[STA_HASH(ap >addr)]; if (s == NULL) r eturn; if (os_memcmp(s >addr, ap >addr, ETH_ALEN) == 0) { iface >ap_hash[STA_HASH(ap >addr)] = s >hnext; return; } while (s >hnext != NULL && os_memcmp(s >hnext >addr, ap >addr, ETH_ALEN) != 0) s = s >hnext; if (s >hnext != NULL) s > hnext = s >hnext >hnext; else printf("AP: could not remove AP MACSTR from hash table \ n", MAC2STR(ap >addr)); } static void ap_free_ap(struct hostapd_iface *iface, struct ap_info *ap) { ap_ap_hash_del(iface, ap); ap_ap_list_del(iface, ap ); iface >num_ap -; os_free(ap); } static void hostapd_free_aps(struct hostapd_iface *iface) { struct ap_info *ap, *prev; ap = iface >ap_list; while (ap) { prev = ap; ap = ap >next; ap_free_ap(iface, prev); } iface >ap_list = NULL; } static struct ap_info ap_ap_add(struct hostapd_iface *iface, const u8 *addr) { struct ap_info *ap;

PAGE 88

80 ap = os_zalloc(sizeof(struct ap_info)); if (ap == NULL) return NULL; /* initialize AP info data */ os_memcpy(ap >addr, addr, ETH_ALEN); ap_ap_lis t_add(iface, ap); iface >num_ap++; ap_ap_hash_add(iface, ap); if (iface >num_ap > iface >conf >ap_table_max_size && ap != ap >prev) { wpa_printf(MSG_DEBUG, "Removing the least recently used AP MACSTR from AP table", MAC2STR(ap >prev > addr)); ap_free_ap(iface, ap >prev); } return ap; } void ap_list_process_beacon(struct hostapd_iface *iface, const struct ieee80211_mgmt *mgmt, struct ieee802_11_elems *elems, struct hostapd_frame_info *fi) { struct ap_info *ap ; struct os_time now; int new_ap = 0; int set_beacon = 0; if (iface >conf >ap_table_max_size < 1) return; ap = ap_get_ap(iface, mgmt >bssid); if (!ap) { ap = ap_ap_add(iface, mgmt >bssid); if (!ap) { printf("Failed to allocate AP informati on entry \ n"); return; } new_ap = 1; } merge_byte_arrays(ap >supported_rates, WLAN_SUPP_RATES_MAX, elems >supp_rates, elems >supp_rates_len, elems >ext_supp_rates, elems >ext_supp_rates_len); if (elems >erp_info && elems >erp_info_len == 1) ap >erp = elems >erp_info[0]; else ap >erp = 1; if (elems >ds_params && elems >ds_params_len == 1) ap >channel = elems >ds_params[0]; else if (elems >ht_operation && elems >ht_operation_len >= 1) ap >channel = elems >ht_operation[0]; el se if (fi) ap >channel = fi >channel; if (elems >ht_capabilities) ap >ht_support = 1; else ap >ht_support = 0; os_get_time(&now); ap >last_beacon = now.sec; if (!new_ap && ap != iface >ap_list) { /* move AP entry into the beginning of the list so that the oldest entry is always in the end of the list */

PAGE 89

81 ap_ap_list_del(iface, ap); ap_ap_list_add(iface, ap); } if (!iface >olbc && ap_list_beacon_olbc(iface, ap)) { iface >olbc = 1; wpa_printf(MSG_DEBUG, "OLBC AP detected: MACSTR (channel %d) enable protection", MAC2STR(ap >addr), ap >channel); set_beacon++; } #ifdef CONFIG_IEEE80211N if (!iface >olbc_ht && !ap >ht_support && (ap >channel == 0 || ap >channel == iface >conf >channel || a p >channel == iface >conf >channel + iface >conf >secondary_channel 4)) { iface >olbc_ht = 1; hostapd_ht_operation_update(iface); wpa_printf(MSG_DEBUG, "OLBC HT AP detected: MACSTR (channel %d) enable protection", MAC2STR(ap >addr), ap >channel); set_beacon++; } #endif /* CONFIG_IEEE80211N */ //JRP //if (set_beacon) //ieee802_11_update_beacons(iface); } static void ap_list_timer(void *eloop_ctx, void *timeout_ctx) { struct hostapd_iface *iface = eloop_ctx; struct os_time now; struct ap_info *ap; int set_beacon = 0; eloop_register_timeout(10, 0, ap_list_timer, iface, NULL); if (!iface >ap_list) return; os_get_time(&now); while (iface >ap_list) { ap = iface >ap_list >prev; if (ap >last_beacon + iface >conf >ap_table_expiration_time >= now.sec) break; ap_free_ap(iface, ap); } if (iface >olbc || iface >olbc_ht) { int olbc = 0; int olbc_ht = 0; ap = iface >ap_list; while (ap && (olbc == 0 || olbc_ht == 0)) { if (ap_list_beacon_olbc(iface, ap)) olbc = 1; if (!ap >ht_support) olbc_ht = 1; ap = ap >next; } if (!olbc && iface >olbc) {

PAGE 90

82 wpa_printf(MSG_DEBUG, "OLBC not detected anymore"); iface >olbc = 0; set_beacon++; } #ifdef CONFIG_IEEE80 211N if (!olbc_ht && iface >olbc_ht) { wpa_printf(MSG_DEBUG, "OLBC HT not detected anymore"); iface >olbc_ht = 0; hostapd_ht_operation_update(iface); set_beacon++; } #endif /* CONFIG_IEEE80211N */ } //JRP //if (set_beacon) // ieee802_11_update_beacons(iface); } //JRP beacon update timer with no extra triggers to accidentally fire it. static void beacon_update_timer(void *eloop_ctx, void *timeout_ctx) { struct hostapd_iface *iface = eloop_ctx; eloop_register_timeout(2,0,beac on_update_timer, iface, NULL); ieee802_11_update_beacons(iface); } int ap_list_init(struct hostapd_iface *iface) { eloop_register_timeout(10, 0, ap_list_timer, iface, NULL); //JRP kicking off my timer loop eloop_register_timeout(2,0,beacon_update_tim er, iface, NULL); return 0; } void ap_list_deinit(struct hostapd_iface *iface) { eloop_cancel_timeout(ap_list_timer, iface, NULL); //JRP cancel off my timer loop eloop_cancel_timeout(beacon_update_timer, iface, NULL); hostapd_free_aps(iface); } HOSTAPD.C Full Path: /Volumes/OpenWrtAA/openwrt/build_dir/target mips_r2_uClibc 0.9.33.2/hostapd wpad mini/hostapd 20130405/src/ap /hostapd.c /* hostapd / Initialization and configuration Copyright (c) 2002 2012, Jouni Malinen This software may be distributed under the terms of the BSD license. See README for more details. */ #include "utils/includes.h" #include "utils/common.h" #include "utils/eloop.h" #include "common/ieee802_11_defs.h" #include "radius/radius_clien t.h" #include "radius/radius_das.h" #include "drivers/driver.h" #include "hostapd.h" #include "authsrv.h"

PAGE 91

83 #include "sta_info.h" #include "accounting.h" #include "ap_list.h" #include "beacon.h" #include "iapp.h" #include "ieee802_1x.h" #include "ieee802_11.h" #include "ieee802_11_auth.h" #include "vlan_init.h" #include "wpa_auth.h" #include "wps_hostapd.h" #include "hw_features.h" #include "wpa_auth_glue.h" #include "ap_drv_ops.h" #include "ap_config.h" #include "p2p_hostapd.h" #include "gas_serv .h" //JRP #include "wmm.h" static int hostapd_flush_old_stations(struct hostapd_data *hapd, u16 reason); static int hostapd_setup_encryption(char *iface, struct hostapd_data *hapd); static int hostapd_broadcast_wep_clear(struct hostapd_data *hapd); extern int wpa_debug_level; extern struct wpa_driver_ops *wpa_drivers[]; int hostapd_for_each_interface(struct hapd_interfaces *interfaces, int (*cb)(struct hostapd_iface *iface, void *ctx), void *ctx) { size_t i; int ret; for (i = 0; i < interfaces >count; i++) { ret = cb(interfaces >iface[i], ctx); if (ret) return ret; } return 0; } static void hostapd_reload_bss(struct hostapd_data *hapd) { #ifndef CONFIG_NO_RADIUS radius_client_reconfig(hapd >radius, hapd >conf >radius ); #endif /* CONFIG_NO_RADIUS */ if (hostapd_setup_wpa_psk(hapd >conf)) { wpa_printf(MSG_ERROR, "Failed to re configure WPA PSK "after reloading configuration"); } if (hapd >conf >ieee802_1x || hapd >conf >wpa) hostapd_set_drv_ieee8021x(hapd, hapd >conf >iface, 1); else hostapd_set_drv_ieee8021x(hapd, hapd >conf >iface, 0); if (hapd >conf >wpa && hapd >wpa_auth == NULL) { hostapd_setup_wpa(hapd); if (hapd >wpa_auth) wpa_init_keys(hapd >wpa_auth); } e lse if (hapd >conf >wpa) { const u8 *wpa_ie; size_t wpa_ie_len; hostapd_reconfig_wpa(hapd);

PAGE 92

84 wpa_ie = wpa_auth_get_wpa_ie(hapd >wpa_auth, &wpa_ie_len); if (hostapd_set_generic_elem(hapd, wpa_ie, wpa_ie_len)) wpa_printf(MSG_ERROR, "Failed to con figure WPA IE for "the kernel driver."); } else if (hapd >wpa_auth) { wpa_deinit(hapd >wpa_auth); hapd >wpa_auth = NULL; hostapd_set_privacy(hapd, 0); hostapd_setup_encryption(hapd >conf >iface, hapd); hostapd_set_generic_elem(hapd, (u8 *) "", 0); } ieee802_11_set_beacon(hapd); hostapd_update_wps(hapd); if (hapd >conf >ssid.ssid_set && hostapd_set_ssid(hapd, hapd >conf >ssid.ssid, hapd >conf >ssid.ssid_len)) { wpa_printf(MSG_ERROR, "Could not set SSID for kernel driver"); /* try to continue */ } wpa_printf(MSG_DEBUG, "Reconfigured interface %s", hapd >conf >iface); } static void hostapd_clear_old(struct hostapd_iface *iface) { size_t j; /* Deauthenticate all stations since the new configuration may no t allow them to use the BSS anymore. */ for (j = 0; j < iface >num_bss; j++) { hostapd_flush_old_stations(iface >bss[j], WLAN_REASON_PREV_AUTH_NOT_VALID); hostapd_broadcast_wep_clear(iface >bss[j]); #ifndef CONFIG_NO_RADIUS /* TODO: update dynamic data based on changed configuration items (e.g., open/close sockets, etc.) */ radius_client_flush(iface >bss[j] >radius, 0); #endif /* CONFIG_NO_RADIUS */ } } int hostapd_reload_config(struct hostapd_iface *iface) { struct hostapd _data *hapd = iface >bss[0]; struct hostapd_config *newconf, *oldconf; size_t j; if (iface >config_fname == NULL) { /* Only in memory config in use assume it has been updated */ hostapd_clear_old(iface); for (j = 0; j < iface >num_bss; j++) hostapd_reload_bss(iface >bss[j]); return 0; } if (iface >interfaces == NULL || iface >interfaces >config_read_cb == NULL) return 1; newconf = iface >interfaces >config_read_cb(iface >config_fname); if (newconf == NULL) return 1; hostapd_clear_old(iface);

PAGE 93

85 oldconf = hapd >iconf; iface >conf = newconf; hostapd_select_hw_mode(iface); iface >freq = hostapd_hw_get_freq(hapd, newconf >channel); if (hostapd_set_freq(hapd, newconf >hw_mode, iface >freq, newconf >channel, newconf >ieee80211n, newconf >ieee80211ac, newconf >secondary_channel, newconf >vht_oper_chwidth, newconf >vht_oper_centr_freq_seg0_idx, newconf >vht_oper_centr_freq_seg1_idx)) { wpa_printf(MSG_ERROR, "Could not set channel for "kernel driver"); } if (iface >current_mode) hostapd_prepare_rates(iface, iface >current_mode); for (j = 0; j < iface >num_bss; j++) { hapd = iface >bss[j]; hapd >iconf = newconf; hapd >conf = &newconf >bss[j]; hostapd_reload_bss(hapd); } hostapd_config_free(oldconf); return 0; } static void hostapd_broadcast_key_clear_iface(struct hostapd_data *hapd, char *ifname) { int i; for (i = 0; i < NUM_WEP_KEYS; i++) { if (hostapd_drv_set_key(ifnam e, hapd, WPA_ALG_NONE, NULL, i, 0, NULL, 0, NULL, 0)) { wpa_printf(MSG_DEBUG, "Failed to clear default "encryption keys (ifname=%s keyidx=%d)", ifname, i); } } #ifdef CONFIG_IEEE80211W if (hapd >conf >ieee80211w) { for (i = NU M_WEP_KEYS; i < NUM_WEP_KEYS + 2; i++) { if (hostapd_drv_set_key(ifname, hapd, WPA_ALG_NONE, NULL, i, 0, NULL, 0, NULL, 0)) { wpa_printf(MSG_DEBUG, "Failed to clear "default mgmt encryption keys "(ifname=%s keyidx=%d)", ifname, i); } } } #endif /* CONFIG_IEEE80211W */ } static int hostapd_broadcast_wep_clear(struct hostapd_data *hapd) { hostapd_broadcast_key_clear_iface(hapd, hapd >conf >iface); return 0; }

PAGE 94

86 static int hostapd_broadc ast_wep_set(struct hostapd_data *hapd) { int errors = 0, idx; struct hostapd_ssid *ssid = &hapd >conf >ssid; idx = ssid >wep.idx; if (ssid >wep.default_len && hostapd_drv_set_key(hapd >conf >iface, hapd, WPA_ALG_WEP, broadcast_ether_addr, idx 1, NULL, 0, ssid >wep.key[idx], ssid >wep.len[idx])) { wpa_printf(MSG_WARNING, "Could not set WEP encryption."); errors++; } if (ssid >dyn_vlan_keys) { size_t i; for (i = 0; i <= ssid >max_dyn_vlan_keys; i++) { const char *ifname; struct hostapd_wep_keys *key = ssid >dyn_vlan_keys[i]; if (key == NULL) continue; ifname = hostapd_get_vlan_id_ifname(hapd >conf >vlan, i); if (ifname == NULL) continue; idx = key >idx; if (hostapd_drv_set_key(ifname, h apd, WPA_ALG_WEP, broadcast_ether_addr, idx, 1, NULL, 0, key >key[idx], key >len[idx])) { wpa_printf(MSG_WARNING, "Could not set "dynamic VLAN WEP encryption."); errors++; } } } return errors; } static void hostapd_free_hapd_data(struct hostapd_data *hapd) { iapp_deinit(hapd >iapp); hapd >iapp = NULL; accounting_deinit(hapd); hostapd_deinit_wpa(hapd); vlan_deinit(hapd); hostapd_acl_deinit(hapd); #ifndef CONFIG_NO_RADIUS radius_client_deinit(hapd >radiu s); hapd >radius = NULL; radius_das_deinit(hapd >radius_das); hapd >radius_das = NULL; #endif /* CONFIG_NO_RADIUS */ hostapd_deinit_wps(hapd); authsrv_deinit(hapd); if (hapd >interface_added && hostapd_if_remove(hapd, WPA_IF_AP_BSS, hapd >con f >iface)) { wpa_printf(MSG_WARNING, "Failed to remove BSS interface %s", hapd >conf >iface); } os_free(hapd >probereq_cb);

PAGE 95

87 hapd >probereq_cb = NULL; #ifdef CONFIG_P2P wpabuf_free(hapd >p2p_beacon_ie); hapd >p2p_beacon_ie = NULL; wpabuf_free(hapd >p2p_probe_resp_ie); hapd >p2p_probe_resp_ie = NULL; #endif /* CONFIG_P2P */ wpabuf_free(hapd >time_adv); #ifdef CONFIG_INTERWORKING gas_serv_deinit(hapd); #endif /* CONFIG_INTERWORKING */ #ifdef CONFIG_SQLITE os_free(hapd >tmp_eap_ user.identity); os_free(hapd >tmp_eap_user.password); #endif /* CONFIG_SQLITE */ } /** hostapd_cleanup Per BSS cleanup (deinitialization) @hapd: Pointer to BSS data This function is used to free all per BSS data structures and resources. This gets called in a loop for each BSS between calls to hostapd_cleanup_iface_pre() and hostapd_cleanup_iface() when an interface is deinitialized. Most of the modules that are initialized in hostapd_setup_bss() are deinitialized here. */ sta tic void hostapd_cleanup(struct hostapd_data *hapd) { if (hapd >iface >interfaces && hapd >iface >interfaces >ctrl_iface_deinit) hapd >iface >interfaces >ctrl_iface_deinit(hapd); hostapd_free_hapd_data(hapd); } /** hostapd_cleanup_iface_pre Preliminary per interface cleanup @iface: Pointer to interface data This function is called before per BSS data structures are deinitialized with hostapd_cleanup(). */ static void hostapd_cleanup_iface_pre(struct hostapd_iface *iface) { } static void hostapd_cleanup_iface_partial(struct hostapd_iface *iface) { hostapd_deinit_ht(iface); hostapd_free_hw_features(iface >hw_features, iface >num_hw_features); iface >hw_features = NULL; os_free(iface >current_rates); iface >current_rates = N ULL; os_free(iface >basic_rates); iface >basic_rates = NULL; ap_list_deinit(iface); } /** hostapd_cleanup_iface Complete per interface cleanup @iface: Pointer to interface data

PAGE 96

88 This function is called after per BSS data structures are de initialized with hostapd_cleanup(). */ static void hostapd_cleanup_iface(struct hostapd_iface *iface) { hostapd_cleanup_iface_partial(iface); hostapd_config_free(iface >conf); iface >conf = NULL; os_free(iface >config_fname); os_free(iface >bss); os_free(iface); } static void hostapd_clear_wep(struct hostapd_data *hapd) { if (hapd >drv_priv) { hostapd_set_privacy(hapd, 0); hostapd_broadcast_wep_clear(hapd); } } static int hostapd_setup_encryption(char *iface, struct hostapd_data *hapd) { int i; hostapd_broadcast_wep_set(hapd); if (hapd >conf >ssid.wep.default_len) { hostapd_set_privacy(hapd, 1); return 0; } /* When IEEE 802.1X is not enabled, the driver may need to know how to set authentication algorithms for static WEP. */ hostapd_drv_set_authmode(hapd, hapd >conf >auth_algs); for (i = 0; i < 4; i++) { if (hapd >conf >ssid.wep.key[i] && hostapd_drv_set_key(iface, hapd, WPA_ALG_WEP, NULL, i, i == hapd >conf >ssid.wep.idx, NULL, 0, hapd >conf > ssid.wep.key[i], hapd >conf >ssid.wep.len[i])) { wpa_printf(MSG_WARNING, "Could not set WEP "encryption."); return 1; } if (hapd >conf >ssid.wep.key[i] && i == hapd >conf >ssid.wep.idx) hostapd_set_privacy(hapd, 1); } r eturn 0; } static int hostapd_flush_old_stations(struct hostapd_data *hapd, u16 reason) { int ret = 0; u8 addr[ETH_ALEN]; if (hostapd_drv_none(hapd) || hapd >drv_priv == NULL) return 0; wpa_dbg(hapd >msg_ctx, MSG_DEBUG, "Flushing old station entries"); if (hostapd_flush(hapd)) {

PAGE 97

89 wpa_msg(hapd >msg_ctx, MSG_WARNING, "Could not connect to "kernel driver"); ret = 1; } wpa_dbg(hapd >msg_ctx, MSG_DEBUG, "Deauthenticate all stations"); os_memset(addr, 0xff, ETH_ALEN); hostapd_drv_sta_d eauth(hapd, addr, reason); hostapd_free_stas(hapd); return ret; } /** hostapd_validate_bssid_configuration Validate BSSID configuration @iface: Pointer to interface data Returns: 0 on success, 1 on failure This function is used to va lidate that the configured BSSIDs are valid. */ static int hostapd_validate_bssid_configuration(struct hostapd_iface *iface) { u8 mask[ETH_ALEN] = { 0 }; struct hostapd_data *hapd = iface >bss[0]; unsigned int i = iface >conf >num_bss, bits = 0, j; int auto_addr = 0; if (hostapd_drv_none(hapd)) return 0; /* Generate BSSID mask that is large enough to cover the BSSIDs. */ /* Determine the bits necessary to cover the number of BSSIDs. */ for (i -; i; i >>= 1) bits++; /* Determine the bits necessary to any configured BSSIDs, if they are higher than the number of BSSIDs. */ for (j = 0; j < iface >conf >num_bss; j++) { if (hostapd_mac_comp_empty(iface >conf >bss[j].bssid) == 0) { if (j) auto_addr++; continue; } for (i = 0 ; i < ETH_ALEN; i++) { mask[i] |= iface >conf >bss[j].bssid[i] ^ hapd >own_addr[i]; } } if (!auto_addr) goto skip_mask_ext; for (i = 0; i < ETH_ALEN && mask[i] == 0; i++) ; j = 0; if (i < ETH_ALEN) { j = (5 i) 8; while (mask[i] != 0) { mask[i] >>= 1; j++; } } if (bits < j) bits = j;

PAGE 98

90 if (bits > 40) { wpa_printf(MSG_ERROR, "Too many bits in the BSSID mask (%u)", bits); return 1; } os_memset(mask, 0xff, ETH_ALEN); j = bits / 8; for (i = 5; i > 5 j; i -) mask[i] = 0; j = bits % 8; while (j -) mask[i] <<= 1; skip_mask_ext: wpa_printf(MSG_DEBUG, "BSS count %lu, BSSID mask MACSTR (%d bits)", (unsigned long) iface >conf >num_bss, MAC2STR(mask), bits); if (!auto_addr) return 0; for (i = 0; i < ETH_ALEN; i++) { if ((hapd >own_addr[i] & mask[i]) != hapd >own_addr[i]) { wpa_printf(MSG_ERROR, "Invalid BSSID mask MACSTR for start address MACSTR ".", MAC2STR(mask), MAC2STR(hapd >own_addr)); wpa_printf(MSG _ERROR, "Start address must be the "first address in the block (i.e., addr "AND mask == addr)."); return 1; } } return 0; } static int mac_in_conf(struct hostapd_config *conf, const void *a) { size_t i; for (i = 0; i < conf >num_bss; i++) { if (hostapd_mac_comp(conf >bss[i].bssid, a) == 0) { return 1; } } return 0; } #ifndef CONFIG_NO_RADIUS static int hostapd_das_nas_mismatch(struct hostapd_data *hapd, struct radius_das_attrs *attr) { /* TODO */ return 0; } static struct sta_info hostapd_das_find_sta(struct hostapd_data *hapd, struct radius_das_attrs *attr) { struct sta_info *sta = NULL; char buf[128]; if (attr >sta_addr) sta = ap_get_sta(hapd, attr >sta_addr);

PAGE 99

91 if (sta == NULL && attr >acct_session_id && attr >acct_session_id_len == 17) { for (sta = hapd >sta_list; sta; sta = sta >next) { os_snprintf(buf, sizeof(buf), "%08X %08X", sta >acct_session_id_hi, sta >acct_session_id_lo); if (os_memcmp(attr >ac ct_session_id, buf, 17) == 0) break; } } if (sta == NULL && attr >cui) { for (sta = hapd >sta_list; sta; sta = sta >next) { struct wpabuf *cui; cui = ieee802_1x_get_radius_cui(sta >eapol_sm); if (cui && wpabuf_len(cui) == attr >cui_len && os_memcmp(wpabuf_head(cui), attr >cui, attr >cui_len) == 0) break; } } if (sta == NULL && attr >user_name) { for (sta = hapd >sta_list; sta; sta = sta >next) { u8 *identity; size_t identity_len; identity = ieee802_1x_get_identity(sta >eapol_sm, &identity_len); if (identity && identity_len == attr >user_name_len && os_memcmp(identity, attr >user_name, identity_len) == 0) break; } } return sta; } static enum radius_ das_res hostapd_das_disconnect(void *ctx, struct radius_das_attrs *attr) { struct hostapd_data *hapd = ctx; struct sta_info *sta; if (hostapd_das_nas_mismatch(hapd, attr)) return RADIUS_DAS_NAS_MISMATCH; sta = hostapd_das_find_sta(hapd, attr); if (sta == NULL) return RADIUS_DAS_SESSION_NOT_FOUND; hostapd_drv_sta_deauth(hapd, sta >addr, WLAN_REASON_PREV_AUTH_NOT_VALID); ap_sta_deauthenticate(hapd, sta, WLAN_REASON_PREV_AUTH_NOT_VALID); return RADIUS_DAS_SUCCESS; } #endif /* CONFIG_NO_RADIUS */ /** hostapd_setup_bss Per BSS setup (initialization) @hapd: Pointer to BSS data @first: Whether this BSS is the first BSS of an interface This function is used to initialize all per BSS data structures and resource s. This gets called in a loop for each BSS when an interface is

PAGE 100

92 initialized. Most of the modules that are initialized here will be deinitialized in hostapd_cleanup(). */ static int hostapd_setup_bss(struct hostapd_data *hapd, int first) { struct ho stapd_bss_config *conf = hapd >conf; u8 ssid[HOSTAPD_MAX_SSID_LEN + 1]; int ssid_len, set_ssid; char force_ifname[IFNAMSIZ]; u8 if_addr[ETH_ALEN]; if (!first) { if (hostapd_mac_comp_empty(hapd >conf >bssid) == 0) { /* Allocate the next available BSSID. */ do { inc_byte_array(hapd >own_addr, ETH_ALEN); } while (mac_in_conf(hapd >iconf, hapd >own_addr)); } else { /* Allocate the configured BSSID. */ os_memcpy(hapd >own_addr, hapd >conf >bssid, ETH_ALEN); if (hostapd_mac_comp(h apd >own_addr, hapd >iface >bss[0] >own_addr) == 0) { wpa_printf(MSG_ERROR, "BSS '%s' may not have "BSSID set to the MAC address of "the radio", hapd >conf >iface); return 1; } } hapd >interface_added = 1; if (hostapd_if_add(hapd >iface >bss[0], WPA_IF_AP_BSS, hapd >conf >iface, hapd >own_addr, hapd, &hapd >drv_priv, force_ifname, if_addr, hapd >conf >bridge[0] ? hapd >conf >bridge : NULL)) { wpa_printf(MSG_ERROR, "Failed to add BSS (BSSID=" MACSTR ")", MAC2STR(hapd >own_addr)); return 1; } } if (conf >wmm_enabled < 0) conf >wmm_enabled = hapd >iconf >ieee80211n; hostapd_flush_old_stations(hapd, WLAN_REASON_PREV_AUTH_NOT_VALID); hostapd_set_privacy(hapd, 0); hostapd_broadcast_wep_clear(hapd); if (hostapd_setup_encryption(hapd >conf >iface, hapd)) return 1; /* Fetch the SSID from the system and use it or, if one was specified in the config file, verify they matc h. */ ssid_len = hostapd_get_ssid(hapd, ssid, sizeof(ssid)); if (ssid_len < 0) { wpa_printf(MSG_ERROR, "Could not read SSID from system"); return 1; } if (conf >ssid.ssid_set) { /* If SSID is specified in the config file and it differs from what is being used then force installation of the new SSID. */ set_ssid = (conf >ssid.ssid_len != (size_t) ssid_len ||

PAGE 101

93 os_memcmp(conf >ssid.ssid, ssid, ssid_len) != 0); } else { /* No SSID in the config file; just use the o ne we got from the system. */ set_ssid = 0; conf >ssid.ssid_len = ssid_len; os_memcpy(conf >ssid.ssid, ssid, conf >ssid.ssid_len); } if (!hostapd_drv_none(hapd)) { wpa_printf(MSG_ERROR, "Using interface %s with hwaddr MACSTR an d ssid \ "%s \ "", hapd >conf >iface, MAC2STR(hapd >own_addr), wpa_ssid_txt(hapd >conf >ssid.ssid, hapd >conf >ssid.ssid_len)); } if (hostapd_setup_wpa_psk(conf)) { wpa_printf(MSG_ERROR, "WPA PSK setup failed."); return 1; } /* Set SSID for the kernel driver (to be used in beacon and probe response frames) */ if (set_ssid && hostapd_set_ssid(hapd, conf >ssid.ssid, conf >ssid.ssid_len)) { wpa_printf(MSG_ERROR, "Could not set SSID for kernel driver"); return 1; } if (wpa_debug_level == MSG_MSGDUMP) conf >radius >msg_dumps = 1; #ifndef CONFIG_NO_RADIUS hapd >radius = radius_client_init(hapd, conf >radius); if (hapd >radius == NULL) { wpa_printf(MSG_ERROR, "RADIUS client initialization failed."); return 1; } if (hapd >conf >radius_das_port) { struct radius_das_conf das_conf; os_memset(&das_conf, 0, sizeof(das_conf)); das_conf.port = hapd >conf >radius_das_port; das_conf.shared_secret = hapd >conf >radius_das_shared_secret; das_conf.shared_secret_le n = hapd >conf >radius_das_shared_secret_len; das_conf.client_addr = &hapd >conf >radius_das_client_addr; das_conf.time_window = hapd >conf >radius_das_time_window; das_conf.require_event_timestamp = hapd >conf >radius_das_require_event_timesta mp; das_conf.ctx = hapd; das_conf.disconnect = hostapd_das_disconnect; hapd >radius_das = radius_das_init(&das_conf); if (hapd >radius_das == NULL) { wpa_printf(MSG_ERROR, "RADIUS DAS initialization "failed."); return 1; } } #endif /* CONFIG_NO_RADIUS */ if (hostapd_acl_init(hapd)) { wpa_printf(MSG_ERROR, "ACL initialization failed."); return 1; } if (hostapd_init_wps(hapd, conf)) return 1;

PAGE 102

94 if (authsrv_init(hapd) < 0) return 1; if (ieee802_1x_init(hapd)) { wpa_printf(MSG_ERROR, "IEEE 802.1X initialization failed."); return 1; } if (hapd >conf >wpa && hostapd_setup_wpa(hapd)) return 1; if (accounting_init(hapd)) { wpa_printf(MSG_ERROR, "Accounting initialization failed."); return 1; } if (hapd >conf >ieee802_11f && (hapd >iapp = iapp_init(hapd, hapd >conf >iapp_iface)) == NULL) { wpa_printf(MSG_ERROR, "IEEE 802.11F (IAPP) initialization "failed."); return 1; } #ifdef CONFIG_INTERWORKING if (gas_serv_init(hapd)) { wpa _printf(MSG_ERROR, "GAS server initialization failed"); return 1; } #endif /* CONFIG_INTERWORKING */ if (hapd >iface >interfaces && hapd >iface >interfaces >ctrl_iface_init && hapd >iface >interfaces >ctrl_iface_init(hapd)) { wpa_printf(M SG_ERROR, "Failed to setup control interface"); return 1; } if (!hostapd_drv_none(hapd) && vlan_init(hapd)) { wpa_printf(MSG_ERROR, "VLAN initialization failed."); return 1; } ieee802_11_set_beacon(hapd); if (hapd >wpa_auth && wpa_init_keys(hapd >wpa_auth) < 0) return 1; if (hapd >driver && hapd >driver >set_operstate) hapd >driver >set_operstate(hapd >drv_priv, 1); return 0; } static void hostapd_tx_queue_params(struct hostapd_iface *iface) { struct hostapd_data *ha pd = iface >bss[0]; int i; struct hostapd_tx_queue_params *p; for (i = 0; i < NUM_TX_QUEUES; i++) { p = &iface >conf >tx_queue[i]; if (hostapd_set_tx_queue_params(hapd, i, p >aifs, p >cwmin, p >cwmax, p >burst)) { wpa_printf(MSG_DEBUG, "F ailed to set TX queue "parameters for queue %d.", i); /* Continue anyway */ } }

PAGE 103

95 } static int setup_interface(struct hostapd_iface *iface) { struct hostapd_data *hapd = iface >bss[0]; size_t i; char country[4]; /* Make sure that all BSSes get configured with a pointer to the same driver interface. */ for (i = 1; i < iface >num_bss; i++) { iface >bss[i] >driver = hapd >driver; iface >bss[i] >drv_priv = hapd >drv_priv; } if (hostapd_validate_bssid_con figuration(iface)) return 1; if (hapd >iconf >country[0] && hapd >iconf >country[1]) { os_memcpy(country, hapd >iconf >country, 3); country[3] = \ 0'; if (hostapd_set_country(hapd, country) < 0) { wpa_printf(MSG_ERROR, "Failed to set country code"); return 1; } } if (hostapd_get_hw_features(iface)) { /* Not all drivers support this yet, so continue without hw feature data. */ } else { int ret = hostapd_select_hw_mode(iface); if (ret < 0) { wpa_printf(MSG_ERROR, "Could n ot select hw_mode and "channel. (%d)", ret); return 1; } ret = hostapd_check_ht_capab(iface); if (ret < 0) return 1; if (ret == 1) { wpa_printf(MSG_DEBUG, "Interface initialization will "be completed in a callback"); return 0; } } //JRP initializing some params here. paramhist[0]=0; paramhist[1]=0; oldbytes = 0; oldbytes2 = 0; oldstacnt = 0; oldstacnt2 = 0; return hostapd_setup_interface_complete(iface, 0); } int hostapd_setup_interface_complete(struct hostapd_iface *iface, int err) { struct hostapd_data *hapd = iface >bss[0]; size_t j; u8 *prev_addr; if (err) goto error;

PAGE 104

96 wpa_printf(MSG_DEBUG, "Completing interface initialization"); if (hapd >iconf >channel) { iface >freq = hostapd_hw_get_fr eq(hapd, hapd >iconf >channel); wpa_printf(MSG_DEBUG, "Mode: %s Channel: %d "Frequency: %d MHz", hostapd_hw_mode_txt(hapd >iconf >hw_mode), hapd >iconf >channel, iface >freq); if (hostapd_set_freq(hapd, hapd >iconf >hw_mode, ifac e >freq, hapd >iconf >channel, hapd >iconf >ieee80211n, hapd >iconf >ieee80211ac, hapd >iconf >secondary_channel, hapd >iconf >vht_oper_chwidth, hapd >iconf >vht_oper_centr_freq_seg0_idx, hapd >iconf >vht_oper_centr_freq_seg1_idx)) { wpa_printf(MSG_ERROR, "Could not set channel for "kernel driver"); goto error; } } if (iface >current_mode) { if (hostapd_prepare_rates(iface, iface >current_mode)) { wpa_printf(MSG_ERROR, Failed to prepare rates "table."); hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211, HOSTAPD_LEVEL_WARNING, "Failed to prepare rates table."); goto error; } } if (hapd >iconf >rts_threshold > 1 && hostapd_ set_rts(hapd, hapd >iconf >rts_threshold)) { wpa_printf(MSG_ERROR, "Could not set RTS threshold for "kernel driver"); goto error; } if (hapd >iconf >fragm_threshold > 1 && hostapd_set_frag(hapd, hapd >iconf >fragm_threshold)) { wpa_printf(MSG_ERROR, "Could not set fragmentation threshold "for kernel driver"); goto error; } prev_addr = hapd >own_addr; for (j = 0; j < iface >num_bss; j++) { hapd = iface >bss[j]; if (j) os_memcpy(hapd >own_addr, prev_addr, ETH_ ALEN); if (hostapd_setup_bss(hapd, j == 0)) goto error; if (hostapd_mac_comp_empty(hapd >conf >bssid) == 0) prev_addr = hapd >own_addr; } hostapd_tx_queue_params(iface); ap_list_init(iface); if (hostapd_driver_commit(hapd) < 0) { wpa_pri ntf(MSG_ERROR, "%s: Failed to commit driver "configuration", __func__); goto error; }

PAGE 105

97 /* WPS UPnP module can be initialized only when the "upnp_iface" is up. If "interface" and "upnp_iface" are the same (e.g., non bridge mode), the interface is up only after driver_commit, so initialize WPS after driver_commit. */ for (j = 0; j < iface >num_bss; j++) { if (hostapd_init_wps_complete(iface >bss[j])) return 1; } if (hapd >setup_complete_cb) hapd >setup_co mplete_cb(hapd >setup_complete_cb_ctx); wpa_printf(MSG_DEBUG, "%s: Setup of interface done.", iface >bss[0] >conf >iface); return 0; error: wpa_printf(MSG_ERROR, "Interface initialization failed"); eloop_terminate(); return 1; } /** hostapd_setup_interface Setup of an interface @iface: Pointer to interface data. Returns: 0 on success, 1 on failure Initializes the driver interface, validates the configuration, and sets driver parameters based on the configuration. Flushes old stations, sets the channel, encryption, beacons, and WDS links based on the configuration. */ int hostapd_setup_interface(struct hostapd_iface *iface) { int ret; ret = setup_interface(iface); if (ret) { wpa_printf(MSG_ERROR, "%s: U nable to setup interface.", iface >bss[0] >conf >iface); return 1; } return 0; } /** hostapd_alloc_bss_data Allocate and initialize per BSS data @hapd_iface: Pointer to interface data @conf: Pointer to per interface configuration @bss: Pointer to per BSS configuration for this BSS Returns: Pointer to allocated BSS data This function is used to allocate per BSS data structure. This data will be freed after hostapd_cleanup() is called for it during interface deiniti alization. */ struct hostapd_data hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface, struct hostapd_config *conf, struct hostapd_bss_config *bss) { struct hostapd_data *hapd; hapd = os_zalloc(sizeof(*hapd));

PAGE 106

98 if (hapd == NULL) return NULL; hapd >new_assoc_sta_cb = hostapd_new_assoc_sta; hapd >iconf = conf; hapd >conf = bss; hapd >iface = hapd_iface; hapd >driver = hapd >iconf >driver; hapd >ctrl_sock = 1; return hapd; } void hostapd_interface_deinit(struct hostapd_iface *iface) { size_t j; if (iface == NULL) return; hostapd_cleanup_iface_pre(iface); for (j = 0; j < iface >num_bss; j++) { struct hostapd_data *hapd = iface >bss[j]; hostapd_free_stas(hapd); hostapd_flush_old_stations(hapd, WLAN_RE ASON_DEAUTH_LEAVING); hostapd_clear_wep(hapd); hostapd_cleanup(hapd); } } void hostapd_interface_free(struct hostapd_iface *iface) { size_t j; for (j = 0; j < iface >num_bss; j++) os_free(iface >bss[j]); hostapd_cleanup_iface(iface); } #ifdef HOSTAPD void hostapd_interface_deinit_free(struct hostapd_iface *iface) { const struct wpa_driver_ops *driver; void *drv_priv; if (iface == NULL) return; driver = iface >bss[0] >driver; drv_priv = iface >bss[0] >drv_priv; hostapd_interface_deinit (iface); if (driver && driver >hapd_deinit && drv_priv) driver >hapd_deinit(drv_priv); hostapd_interface_free(iface); } int hostapd_enable_iface(struct hostapd_iface *hapd_iface) { if (hapd_iface >bss[0] >drv_priv != NULL) { wpa_printf(MSG_ERROR, "Interface %s already enabled", hapd_iface >conf >bss[0].iface); return 1; } wpa_printf(MSG_DEBUG, "Enable interface %s", hapd_iface >conf >bss[0].iface); if (hapd_iface >interfaces == NULL ||

PAGE 107

99 hapd_iface >interfaces > driver_init == NULL || hapd_iface >interfaces >driver_init(hapd_iface) || hostapd_setup_interface(hapd_iface)) { hostapd_interface_deinit_free(hapd_iface); return 1; } return 0; } int hostapd_reload_iface(struct hostapd_iface *hapd_iface ) { size_t j; wpa_printf(MSG_DEBUG, "Reload interface %s", hapd_iface >conf >bss[0].iface); for (j = 0; j < hapd_iface >num_bss; j++) { hostapd_flush_old_stations(hapd_iface >bss[j], WLAN_REASON_PREV_AUTH_NOT_VALID); #ifndef CONFIG_NO_R ADIUS /* TODO: update dynamic data based on changed configuration items (e.g., open/close sockets, etc.) */ radius_client_flush(hapd_iface >bss[j] >radius, 0); #endif /* CONFIG_NO_RADIUS */ hostapd_reload_bss(hapd_iface >bss[j]); } return 0; } int hostapd_disable_iface(struct hostapd_iface *hapd_iface) { size_t j; struct hostapd_bss_config *bss; const struct wpa_driver_ops *driver; void *drv_priv; if (hapd_iface == NULL) return 1; bss = hapd_iface >bss[0] >conf; driver = hapd_ifa ce >bss[0] >driver; drv_priv = hapd_iface >bss[0] >drv_priv; /* whatever hostapd_interface_deinit does */ for (j = 0; j < hapd_iface >num_bss; j++) { struct hostapd_data *hapd = hapd_iface >bss[j]; hostapd_free_stas(hapd); hostapd_flush_old_stati ons(hapd, WLAN_REASON_DEAUTH_LEAVING); hostapd_clear_wep(hapd); hostapd_free_hapd_data(hapd); } if (driver && driver >hapd_deinit && drv_priv) { driver >hapd_deinit(drv_priv); hapd_iface >bss[0] >drv_priv = NULL; } /* From hostapd_cleanup_iface: These were initialized in hostapd_setup_interface and hostapd_setup_interface_complete */ hostapd_cleanup_iface_partial(hapd_iface); bss >wpa = 0; bss >wpa_key_mgmt = 1; bss >wpa_pairwise = 1; wpa_printf(MSG_DEBUG, "Int erface %s disabled", bss >iface); return 0; }

PAGE 108

100 static struct hostapd_iface hostapd_iface_alloc(struct hapd_interfaces *interfaces) { struct hostapd_iface **iface, *hapd_iface; iface = os_realloc_array(interfaces >iface, interfaces >count + 1, s izeof(struct hostapd_iface *)); if (iface == NULL) return NULL; interfaces >iface = iface; hapd_iface = interfaces >iface[interfaces >count] = os_zalloc(sizeof(*hapd_iface)); if (hapd_iface == NULL) { wpa_printf(MSG_ERROR, "%s: Failed to allocate memory for "the interface", __func__); return NULL; } interfaces >count++; hapd_iface >interfaces = interfaces; return hapd_iface; } static struct hostapd_config hostapd_config_alloc(struct hapd_interfaces *interfaces, const char *ifnam e, const char *ctrl_iface) { struct hostapd_bss_config *bss; struct hostapd_config *conf; /* Allocates memory for bss and conf */ conf = hostapd_config_defaults(); if (conf == NULL) { wpa_printf(MSG_ERROR, "%s: Failed to allocate memory for "configuration", __func__); return NULL; } conf >driver = wpa_drivers[0]; if (conf >driver == NULL) { wpa_printf(MSG_ERROR, "No driver wrappers registered!"); hostapd_config_free(conf); return NULL; } bss = conf >last_bss = conf >bss; os_strlcpy(bss >iface, ifname, sizeof(bss >iface)); bss >ctrl_interface = os_strdup(ctrl_iface); if (bss >ctrl_interface == NULL) { hostapd_config_free(conf); return NULL; } /* Reading configuration file skipped, will be done in SET! From r eading the configuration till the end has to be done in SET */ return conf; } static struct hostapd_iface hostapd_data_alloc( struct hapd_interfaces *interfaces, struct hostapd_config *conf) { size_t i; struct hostapd_iface *hapd_iface =

PAGE 109

101 interfaces >iface[interfaces >count 1]; struct hostapd_data *hapd; hapd_iface >conf = conf; hapd_iface >num_bss = conf >num_bss; hapd_iface >bss = os_zalloc(conf >num_bss sizeof(struct hostapd_data *)); if (hapd_iface >bss == NULL) ret urn NULL; for (i = 0; i < conf >num_bss; i++) { hapd = hapd_iface >bss[i] = hostapd_alloc_bss_data(hapd_iface, conf, &conf >bss[i]); if (hapd == NULL) return NULL; hapd >msg_ctx = hapd; } hapd_iface >interfaces = interfaces; return hapd_iface; } int hostapd_add_iface(struct hapd_interfaces *interfaces, char *buf) { struct hostapd_config *conf = NULL; struct hostapd_iface *hapd_iface = NULL; char *ptr; size_t i; ptr = os_strchr(buf, '); if (ptr == NULL) return 1; *ptr++ = \ 0'; for (i = 0; i < interfaces >count; i++) { if (!os_strcmp(interfaces >iface[i] >conf >bss[0].iface, buf)) { wpa_printf(MSG_INFO, "Cannot add interface it "already exists"); return 1; } } hapd_iface = host apd_iface_alloc(interfaces); if (hapd_iface == NULL) { wpa_printf(MSG_ERROR, "%s: Failed to allocate memory "for interface", __func__); goto fail; } conf = hostapd_config_alloc(interfaces, buf, ptr); if (conf == NULL) { wpa_printf(MSG_ERROR, "%s: Failed to allocate memory "for configuration", __func__); goto fail; } hapd_iface = hostapd_data_alloc(interfaces, conf); if (hapd_iface == NULL) { wpa_printf(MSG_ERROR, "%s: Failed to allocate memory "for hostapd", __func__); goto fail; } if (hapd_iface >interfaces && hapd_iface >interfaces >ctrl_iface_init &&

PAGE 110

102 hapd_iface >interfaces >ctrl_iface_init(hapd_iface >bss[0])) { wpa_printf(MSG_ERROR, "%s: Failed to setup control "interfac e", __func__); goto fail; } wpa_printf(MSG_INFO, "Add interface '%s'", conf >bss[0].iface); return 0; fail: if (conf) hostapd_config_free(conf); if (hapd_iface) { os_free(hapd_iface >bss[interfaces >count]); os_free(hapd_iface); } return 1; } int hostapd_remove_iface(struct hapd_interfaces *interfaces, char *buf) { struct hostapd_iface *hapd_iface; size_t i, k = 0; for (i = 0; i < interfaces >count; i++) { hapd_iface = interfaces >iface[i]; if (hapd_iface == NULL) return 1; if (!os_strcmp(hapd_iface >conf >bss[0].iface, buf)) { wpa_printf(MSG_INFO, "Remove interface '%s'", buf); hostapd_interface_deinit_free(hapd_iface); k = i; while (k < (interfaces >count 1)) { interfaces >iface[k] = interfaces >ifa ce[k + 1]; k++; } interfaces >count -; return 0; } } return 1; } #endif /* HOSTAPD */ /** hostapd_new_assoc_sta Notify that a new station associated with the AP @hapd: Pointer to BSS data @sta: Pointer to the associated STA data @reassoc: 1 to indicate this was a re association; 0 = first association This function will be called whenever a station associates with the AP. It can be called from ieee802_11.c for drivers that exp ort MLME to hostapd and from drv_callbacks.c based on driver events for drivers that take care of management frames (IEEE 802.11 authentication and association) internally. */ void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *st a, int reassoc) { if (hapd >tkip_countermeasures) { hostapd_drv_sta_deauth(hapd, sta >addr, WLAN_REASON_MICHAEL_MIC_FAILURE); return; } hostapd_prune_associations(hapd, sta >addr);

PAGE 111

103 /* IEEE 802.11F (IAPP) */ if (hapd >conf > ieee802_11f) iapp_new_station(hapd >iapp, sta); #ifdef CONFIG_P2P if (sta >p2p_ie == NULL && !sta >no_p2p_set) { sta >no_p2p_set = 1; hapd >num_sta_no_p2p++; if (hapd >num_sta_no_p2p == 1) hostapd_p2p_non_p2p_sta_connected(hapd); } #endif /* CONFIG_P2P */ /* Start accounting here, if IEEE 802.1X and WPA are not used. IEEE 802.1X/WPA code will start accounting after the station has been authorized. */ if (!hapd >conf >ieee802_1x && !hapd >conf >wpa) { os_get_time(&sta >connected_ti me); accounting_sta_start(hapd, sta); } /* Start IEEE 802.1X authentication process for new stations */ ieee802_1x_new_station(hapd, sta); if (reassoc) { if (sta >auth_alg != WLAN_AUTH_FT && !(sta >flags & (WLAN_STA_WPS | WLAN_STA_MAYBE_WPS))) wpa_auth_sm_event(sta >wpa_sm, WPA_REAUTH); } else wpa_auth_sta_associated(hapd >wpa_auth, sta >wpa_sm); wpa_printf(MSG_DEBUG, "%s: reschedule ap_handle_timer timeout "for MACSTR (%d seconds ap_ma x_inactivity)", __func__, MAC2STR(sta >addr), hapd >conf >ap_max_inactivity); eloop_cancel_timeout(ap_handle_timer, hapd, sta); eloop_register_timeout(hapd >conf >ap_max_inactivity, 0, ap_handle_timer, hapd, sta); }

PAGE 112

104 APPENDIX F : MATLA B Analysis Code For various figures throughput the paper MATLAB was used for analysis and plotting. The analysis portions of the code are supplied here. The main probability analysis code was based on code from the referenced papers from Rajmic [21], [22]. The following is the contents of the key m files. PWIN_PER_STA.M %Function used for Joey Padden Thesis project 2012/2013 %This function was adapted from the Rajmic code found at %"http://www.mathworks.com/matlabcentral/fileexchange/27573 % probabilistic analysis of ieee 802 11e/content/edca_probability_win.m" function [p_win_net1,p_win_net2,p_coll,p_win_net_dcf,pcoll_dcf] ... = pwin_per_sta(n,m,cwn,cwm) net1(1:n,1)=3; net1(1:n,2)=cwn; net2(1:m,1)=3; net2(1:m,2)=cwm; matrix = [net1;net2]; K = size(matrix,1); %number of stations for k = 1 : K matrix = shift_nth_station_to_first(matrix,k); [p_win(k), ~] = edca_probability_win(matrix, 'whole' ); end p_win_net1 = sum(p_win(1:n)); p_win_net2 = sum(p_win(n+1:n+m) ); p = K 1; out = 0; cw = 15; z = 1:cw 1; pwin_dcf = (1/cw)*sum((z./cw).^p); p_win_net_dcf = [n*pwin_dcf m*pwin_dcf]; p_coll = edca_probability_collision(matrix); pcoll_dcf = 1 K*pwin_dcf;

PAGE 113

105 EDCA_PROBABILITY_COLLISION.M %Function used for Joey Padden thesis project 2012/13 %Code created by Rajmic. Original code found at %http://www.mathworks.com/matlabcentral/fileexchange/27573 % probabilistic analysis of ieee 802 11e/content/edca_probability_win.m function [p_coll] = edca_probability_c ollision(matrix) K = size(matrix,1); total = 0; for cnt = 0:(K 1) p_win = edca_probability_win(shift_nth_station_to_first(matrix,cnt+1)); total = total + p_win; end p_coll = 1 total; EDCA_PROBABILITY_WIN.M %Function used for Joey Padden thesis project 2012/13 %Code created by Rajmic. Original code found at %http://www.mathworks.com/matlabcentral/fileexchange/27573 % probabilistic analysis of ieee 802 11e/content/edca_probability_win.m function [p_win, matrix_p_win] = edca_proba bility_win(matrix,full) K = size(matrix,1); N0 = matrix(:,1); N = matrix(:,2); N0 = N0 min(N0); N10 = N0(1); N1 = N(1); total = N0+N; if nargin == 1 a = min(total(2:end)); if total(1) <= a no_cols = N1; else b = N10+1; c = a b; no_cols = max([0 c]); end else no_cols = N1; end if no_cols > 0 matrix_p_win = zeros(K 1,no_cols); for k = 2:K

PAGE 114

106 number = N(k) max(0,N10 N0(k)+1); matrix_p_win(k 1,1) = nu mber; end if no_cols > 1 ict = N0(2:K) N0(1) 1; for cnt = 2:no_cols matrix_p_win(:,cnt) = matrix_p_win(:,cnt 1) 1*(ict<=0); ict = ict 1; end matrix_p_win = max(0,matrix_p_win); end p_win = sum(prod(matrix_p_win)); p_win = p_win / prod(N(1:K)); else p_win = 0; matrix_p_win = []; end SHIFT_NTH_STATION_TO_FIRST.M %Function used for Joey Padden thesis project 2012/13 %Code created by Rajmic. Original code found at %http://www.mathworks.com/matlabcentral/fileexchange/27573 % probabilistic analysis of ieee 802 11e/content/edca_probability_win.m function matrix_new = shift_nth_station_to_first(matrix,no) matrix_new = matrix; if no ~= 1 matrix_new(1,:) = matrix(no,:); matrix_new(no,:) = matrix(1,:); end PLOTCWMINSURF.M %Function used for Joey Padden Thesis 2012/13 %Function plots the channel access probability ratio between two networks %based on CWmin and the client count ratios of the networks. function out = plotcwminsurf cwmin2 = [15 31 63 127 255 511 1023]; l = length(cwmin2); % Create figure figure1 = figure; % Create axes axes1 = axes( 'Parent' ,figure1, ... 'XTickLabel' ,{ '15' '31' '63' '127' '255' '511' '1023' }, ... 'Position' ,[0.0768261964735516 0.118251928020566 0.876574307304785 ...

PAGE 115

107 0.7990709066251], ... 'FontSize' ,12, ... 'FontName' 'Times' ); xlim(axes1,[0.9 7]); box(axes1, 'on' ); hold(axes1, 'all' ); cc=lines(10); stacnt = [2 2; 2 3; 2 4; 2 5; 2 6; 2 7;2 8]; L = length(stacnt(:,1)); for j = 1:L n = stacnt(j,1); m = stacnt(j,2); for k = 1:l [p_win_net1(k),p_win_net2(k),~,~,~] = pwin_per_sta(n,m,15, ... cwmin2(k)); end hold on ; plot(1:l,p_win_net1, 'Parent' ,axes1, 'Marker' '+' 'LineStyle' -' ... 'Color' cc(j,:), 'LineWidth' ,1.2); hold on ; plot(1:l,p_win_net2, 'Parent' ,axes1, 'Marker' '*' 'LineStyle' ':' ... 'Color' cc(j,:), 'LineWidth' ,1.2); out(j,:)=p_win_net1./p_win_net2; end % Create xlabel xlabel({ 'Cwmin of Public Network' }, 'FontSize' ,14, 'FontName' 'Times' ); % Create ylabel ylabel({ 'Network Probability of Successful Transmission' }, 'FontSize' ,14, ... 'FontName' 'Times' ); % Create title title({ Throughput for Private and Public Network vs CWmin(public) for ... Various STA count Configurations'}, ... 'FontSize' ,14, ... 'FontName' 'Times' ); figure2 = figure; x = [15 31 63 127 255 511 1023]; y = [2/2 2/3 2/4 2/5 2/6 2/7 2/8]; % Create a sample plot surfc(x,y,out) axis([0 1024 .1 1 120 120]) % Define the new level at which the contours should % be drawn new_level = 120; % Get the handle to each patch object h = findobj( 'type' 'patch' ); % Create a loop to change the height of each contour

PAGE 116

108 zd = get(h, 'ZData' ); for i = 1:length(zd) set(h(i), 'ZData' ,new_level*ones(length(zd{i}),1)) end PLOTCWMINSTACNT.M %Function used for Joey Padden Thesis 2012/13 %Function plots the channel access probability ratio between two networks %based on CWmin and the client count ratios of the networks. function out = plotcwminsurf cwmin2 = [15 31 63 127 255 511 1023]; l = length(cwmin2); % Create figure figure1 = figure; % Create axes axes1 = axes( 'Parent' ,figure1, ... 'XTickLabel' ,{ '15' '31' '63' '127' '255' '511' '1023' }, ... 'Position' ,[0.0768261964735516 0.118251928020566 0.876574307304785 ... 0.7990709066251], ... 'FontSize' ,12, ... 'FontName' 'Times' ); xlim(axes1,[0.9 7]); box(axes1, 'on' ); hold(axes1, 'all' ); cc=lines(10); stacnt = [2 2; 2 3; 2 4; 2 5; 2 6; 2 7;2 8]; L = length(stacnt(:,1)); for j = 1:L n = stacnt(j,1); m = stacnt(j,2); for k = 1:l [p_win_net1(k),p_win_net2(k),~,~,~] = pwin_per_sta(n,m,15, ... cwmin2(k)); end hold on ; plot(1:l,p_win_net1, 'Parent' ,axes1, 'Marker' '+' 'LineStyle' -' ... 'Color' cc(j,:), 'LineWidth' ,1.2); hold on ; plot(1:l,p_win_net2, 'Parent' ,axes1, 'Marker' '*' 'LineStyle' ':' ... 'C olor' cc(j,:), 'LineWidth' ,1.2); out(j,:)=p_win_net1./p_win_net2; end % Create xlabel

PAGE 117

109 xlabel({ 'Cwmin of Public Network' }, 'FontSize' ,14, 'FontName' 'Times' ); % Create ylabel ylabel({ 'Network Probability of Successful Transmission' }, 'FontSize' ,14, ... 'FontName' 'Times' ); % Create title title({ 'Throughput for Private and Public Network vs CWmin(public) for ... Various STA count Configurations'}, ... 'FontSize' ,14, ... 'FontName' 'Times' ); figure2 = figure; x = [15 31 63 127 255 511 1023]; y = [2/2 2/3 2/4 2/5 2/6 2/7 2/8]; % Create a sample plot surfc(x,y,out) axis([0 1024 .1 1 120 120]) % Define the new level at which the contours should % be drawn new_level = 120; % Get the handle to each patch object h = findobj( 'type' 'patch' ); % Create a loop to change the height of each contour zd = get(h, 'ZData' ); for i = 1:length(zd) set(h(i), 'ZData' ,new_level*ones(length(zd{i}),1)) end