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