13 | | ''' AP-to-STA Throughput: ''' |
14 | | |
15 | | 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. |
16 | | |
17 | | 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. |
18 | | |
19 | | {{{#!python |
20 | | #Initialize the 802.11 WARP nodes |
21 | | nodes = wlan_exp_util.wlan_exp_init_nodes(['W3-a-00001', W3-a-00002']) |
22 | | |
23 | | #Find the AP node |
24 | | n_ap = [n for n in nodes if n.node_type == NT_AP][0] |
25 | | |
26 | | #Find the STA node |
27 | | n_sta = [n for n in nodes if n.node_type == NT_STA][0] |
28 | | |
29 | | #Start a flow from the AP's local traffic generator (LTG) to the STA |
30 | | # Set the flow to fully backlogged with 1400 byte payloads |
31 | | n_ap.config_ltg(n_sta, LTG_CBR(1400, 0)) |
32 | | |
33 | | #Experiment parameters - trial time and PHY rates to test |
34 | | TRIAL_TIME = 10 |
35 | | rates = (R6, R9, R12, R18) |
36 | | |
37 | | #Result arrays (filled in by the loop below) |
38 | | rx_bytes = [] |
39 | | rx_time_spans = [] |
40 | | |
41 | | for ii,rate in enumerate(rates): |
42 | | #Configure the AP's Tx rate for the selected station |
43 | | n_ap.set_tx_rate(n_sta, rate) |
44 | | |
45 | | #Record the station's initial Tx/Rx stats |
46 | | rx_stats_start = n_sta.get_txrx_stats(n_ap) |
47 | | |
48 | | time.sleep(TRIAL_TIME) |
49 | | |
50 | | #Record the station's final Tx/Rx stats |
51 | | rx_stats_end = n_sta.get_txrx_stats(n_ap) |
52 | | |
53 | | #Compute the number of new bytes received and the time span |
54 | | rx_bytes[ii] = rx_stats_end['rx_bytes'] - rx_stats_start['rx_bytes'] |
55 | | rx_time_spans[ii] = rx_stats_end['timestamp'] - rx_stats_start['timestamp'] |
56 | | |
57 | | #Calculate and display the throughput results |
58 | | for ii in len(num_rx[ii]): |
59 | | #Timestamps are in microseconds; bits/usec == Mbits/sec |
60 | | xput = (rx_bytes[ii] * 8) / rx_time_spans[ii] |
61 | | print("Rate = %2.1f Mbps Throughput = %2.1 Mbps", (rates[ii], xput)) |
62 | | |
63 | | }}} |
| 13 | * [wiki./Examples#AP-to-STAThroughput AP-to-STA Throughput] - measures the achieved throughput from one AP to one STA using various PHY rates |