wiki:802.11/wlan_exp/examples

Version 2 (modified by murphpo, 10 years ago) (diff)

--

802.11 Reference Design: Experiment Examples

AP-to-STA Throughput

This example uses two WARP v3 nodes running the 802.11 Reference Design. One node is configured as an AP, the other as a station. The station node is associates with the AP at boot.

This script uses the txrx_stats data in the reference design to calculate through in a unidirectional flow. The AP generates a fully backlogged flow of packets addressed to the station. The station counts how many bytes it has received from the AP. The Python script polls the station twice over a period of 10 seconds, recording the txrx_stats reports before and after. It then computes the number of new bytes received and the time span between reports. The script uses the timestamps reported by the node in the txrx_stats report to calculate the time span. This removes any dependence on the PC-nodes link in computing the denominator for the throughput calculation.

#Initialize the 802.11 WARP nodes
# Update the serial numbers below for your local nodes
nodes = wlan_exp_util.wlan_exp_init_nodes(['W3-a-00001', 'W3-a-00002'])

#Find the AP node
n_ap = wlan_exp_util.wlan_exp_get_ap_nodes(nodes)[0]

#Find the STA node
n_sta = wlan_exp_util.wlan_exp_get_sta_nodes(nodes)[0]

#Start a flow from the AP's local traffic generator (LTG) to the STA
# Set the flow to fully backlogged with 1400 byte payloads
n_ap.config_ltg(n_sta, LTG_CBR(1400, 0))

#Experiment parameters - trial time and PHY rates to test
TRIAL_TIME = 10
rates = (R6, R9, R12, R18)

#Result arrays (filled in by the loop below)
rx_bytes = []
rx_time_spans = []

for ii,rate in enumerate(rates):
  #Configure the AP's Tx rate for the selected station
  n_ap.set_tx_rate(n_sta, rate)

  #Record the station's initial Tx/Rx stats 
  rx_stats_start = n_sta.get_txrx_stats(n_ap)

  time.sleep(TRIAL_TIME)

  #Record the station's final Tx/Rx stats
  rx_stats_end = n_sta.get_txrx_stats(n_ap)

  #Compute the number of new bytes received and the time span
  rx_bytes[ii] = rx_stats_end['rx_bytes'] - rx_stats_start['rx_bytes']
  rx_time_spans[ii] = rx_stats_end['timestamp'] - rx_stats_start['timestamp']

#Calculate and display the throughput results
for ii in len(num_rx[ii]):
  #Timestamps are in microseconds; bits/usec == Mbits/sec
  xput = (rx_bytes[ii] * 8) / rx_time_spans[ii]
  print("Rate = %2.1f Mbps   Throughput = %2.1 Mbps", (rates[ii], xput))