mirror of
				https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
				synced 2025-11-02 19:58:03 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			251 lines
		
	
	
		
			6.4 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			251 lines
		
	
	
		
			6.4 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
#!/usr/bin/env python3
 | 
						|
'''
 | 
						|
Candela Technologies Inc.
 | 
						|
Info : Standard Script for WLAN Capacity Calculator
 | 
						|
Date :
 | 
						|
Author : Anjali Rahamatkar
 | 
						|
'''
 | 
						|
 | 
						|
import argparse
 | 
						|
import sys
 | 
						|
import os
 | 
						|
 | 
						|
from pip._internal.utils import logging
 | 
						|
 | 
						|
if 'py-json' not in sys.path:
 | 
						|
    sys.path.append(os.path.join(os.path.abspath('..'), 'py-json'))
 | 
						|
import wlan_theoretical_sta
 | 
						|
 | 
						|
# main method
 | 
						|
 | 
						|
def main():
 | 
						|
 | 
						|
    parse = wlan_theoretical_sta.abg11_calculator.create_argparse( prog='wlan_capacity_calculator.py',
 | 
						|
        formatter_class=argparse.RawTextHelpFormatter,
 | 
						|
        epilog='''\
 | 
						|
             This python script calculates the theoretical value of three different stations( 11abg/11n/11ac)''',
 | 
						|
        description='''\
 | 
						|
        wlan_capacity_calculator.py
 | 
						|
        ---------------------------------------------------------------------------
 | 
						|
 | 
						|
    Example of command line to run(11ac Station):
 | 
						|
   ./wlan_capacity_calculator.py 
 | 
						|
        -sta 11ac 
 | 
						|
        -t Voice 
 | 
						|
        -d 9 
 | 
						|
        -spa 3    
 | 
						|
        -ch 20
 | 
						|
        -gu 800 
 | 
						|
        -high 1
 | 
						|
        -e TKIP
 | 
						|
        -q Yes 
 | 
						|
        -ip 3
 | 
						|
        -mc 0
 | 
						|
        -b 6 12 24 54
 | 
						|
        -m 1518
 | 
						|
        -co Greenfield
 | 
						|
        -cw 15
 | 
						|
            ''')
 | 
						|
 | 
						|
    try:
 | 
						|
        args = parse.parse_args()
 | 
						|
        # Station
 | 
						|
        if (args.station is not None):
 | 
						|
            Calculator_name = args.station
 | 
						|
        else:
 | 
						|
            Calculator_name = "11abg"
 | 
						|
 | 
						|
        # Traffic Type
 | 
						|
        if (args.traffic is not None):
 | 
						|
            traffic_name = args.traffic
 | 
						|
        else:
 | 
						|
            traffic_name = "Data"
 | 
						|
 | 
						|
        # PHY Bit Rate
 | 
						|
        if (args.phy is not None):
 | 
						|
            phy_name = args.phy
 | 
						|
        else:
 | 
						|
            phy_name = "54"
 | 
						|
 | 
						|
        # Encryption
 | 
						|
        if (args.encryption is not None):
 | 
						|
            encryption_name = args.encryption
 | 
						|
        else:
 | 
						|
            encryption_name = "None"
 | 
						|
 | 
						|
        # QoS
 | 
						|
 | 
						|
        if (args.qos is not None):
 | 
						|
            qos_name = args.qos
 | 
						|
        else:
 | 
						|
            if "11abg" in Calculator_name:
 | 
						|
                qos_name = "No"
 | 
						|
            if "11n" in Calculator_name or "11ac" in Calculator_name:
 | 
						|
                qos_name = "Yes"
 | 
						|
 | 
						|
        # 802.11 MAC Frame
 | 
						|
 | 
						|
        if (args.mac is not None):
 | 
						|
            mac_name = args.mac
 | 
						|
        else:
 | 
						|
            mac_name = "1518"
 | 
						|
 | 
						|
        # Basic Rate Set
 | 
						|
 | 
						|
        if (args.basic is not None):
 | 
						|
            basic_name = args.basic
 | 
						|
        else:
 | 
						|
            basic_name = ['1', '2', '5.5', '11', '6', '12', '24']
 | 
						|
 | 
						|
        # Preamble value
 | 
						|
 | 
						|
        if (args.preamble is not None):
 | 
						|
            preamble_name = args.preamble
 | 
						|
        else:
 | 
						|
            preamble_name = "Short"
 | 
						|
 | 
						|
        # Slot Time
 | 
						|
 | 
						|
        if (args.slot is not None):
 | 
						|
            slot_name = args.slot
 | 
						|
        else:
 | 
						|
            slot_name = "Short"
 | 
						|
 | 
						|
        # Codec Type (Voice Traffic)
 | 
						|
 | 
						|
        if (args.codec is not None):
 | 
						|
            codec_name = args.codec
 | 
						|
        else:
 | 
						|
            if "11abg" in Calculator_name:
 | 
						|
                codec_name = "G.723"
 | 
						|
            if "11n" in Calculator_name:
 | 
						|
                codec_name = "G.711"
 | 
						|
            if "11ac" in Calculator_name:
 | 
						|
                codec_name = "Mixed"
 | 
						|
 | 
						|
        # RTS/CTS Handshake
 | 
						|
 | 
						|
        if (args.rts is not None):
 | 
						|
            rts_name = args.rts
 | 
						|
        else:
 | 
						|
            rts_name = "No"
 | 
						|
 | 
						|
        # CTS - to - self(protection)
 | 
						|
 | 
						|
        if (args.cts is not None):
 | 
						|
            cts_name = args.cts
 | 
						|
        else:
 | 
						|
            cts_name = "No"
 | 
						|
 | 
						|
        # station = 11n and 11ac
 | 
						|
 | 
						|
        # Data/Voice MCS Index
 | 
						|
 | 
						|
        if (args.data is not None):
 | 
						|
            data_name = args.data
 | 
						|
        else:
 | 
						|
            if "11n" in Calculator_name:
 | 
						|
                data_name = "7"
 | 
						|
            if "11ac" in Calculator_name:
 | 
						|
                data_name = "9"
 | 
						|
 | 
						|
        # Channel Bandwidth
 | 
						|
 | 
						|
        if (args.channel is not None):
 | 
						|
            channel_name = args.channel
 | 
						|
        else:
 | 
						|
            if "11n" in Calculator_name:
 | 
						|
                channel_name = "40"
 | 
						|
            if "11ac" in Calculator_name:
 | 
						|
                channel_name = "80"
 | 
						|
 | 
						|
        # Guard Interval
 | 
						|
 | 
						|
        if (args.guard is not None):
 | 
						|
            guard_name = args.guard
 | 
						|
        else:
 | 
						|
            guard_name = "400"
 | 
						|
 | 
						|
        # Highest Basic MCS
 | 
						|
 | 
						|
        if (args.highest is not None):
 | 
						|
            highest_name = args.highest
 | 
						|
        else:
 | 
						|
            highest_name = '1'
 | 
						|
 | 
						|
        # PLCP Configuration
 | 
						|
 | 
						|
        if (args.plcp is not None):
 | 
						|
            plcp_name = args.plcp
 | 
						|
        else:
 | 
						|
            plcp_name = "Mixed"
 | 
						|
 | 
						|
        # IP Packets per A-MSDU
 | 
						|
 | 
						|
        if (args.ip is not None):
 | 
						|
            ip_name = args.ip
 | 
						|
        else:
 | 
						|
            ip_name = "0"
 | 
						|
 | 
						|
        # MAC Frames per A-MPDU
 | 
						|
 | 
						|
        if (args.mc is not None):
 | 
						|
            mc_name = args.mc
 | 
						|
        else:
 | 
						|
            if "11n" in Calculator_name:
 | 
						|
                mc_name = '42'
 | 
						|
            if "11ac" in Calculator_name:
 | 
						|
                mc_name = '64'
 | 
						|
 | 
						|
        # CWmin (leave alone for default)
 | 
						|
 | 
						|
        if (args.cwin is not None):
 | 
						|
            cwin_name = args.cwin
 | 
						|
        else:
 | 
						|
            cwin_name = '15'
 | 
						|
 | 
						|
        # Spatial Streams
 | 
						|
 | 
						|
        if (args.spatial is not None):
 | 
						|
            spatial_name = args.spatial
 | 
						|
        else:
 | 
						|
            spatial_name = '4'
 | 
						|
 | 
						|
        # RTS/CTS Handshake and CTS-to-self
 | 
						|
 | 
						|
        if (args.rtscts is not None):
 | 
						|
            rtscts_name = args.rtscts
 | 
						|
        else:
 | 
						|
            rtscts_name = 'No'
 | 
						|
 | 
						|
 | 
						|
    except Exception as e:
 | 
						|
        logging.exception(e)
 | 
						|
        exit(2)
 | 
						|
 | 
						|
    # Select station(802.11a/b/g/n/ac standards)
 | 
						|
 | 
						|
    if "11abg" in Calculator_name:
 | 
						|
        Station1 = wlan_theoretical_sta.abg11_calculator(traffic_name, phy_name, encryption_name, qos_name, mac_name, basic_name,
 | 
						|
                                    preamble_name, slot_name, codec_name, rts_name, cts_name)
 | 
						|
        Station1.calculate()
 | 
						|
        Station1.get_result()
 | 
						|
 | 
						|
    if "11n" in Calculator_name:
 | 
						|
        Station2 = wlan_theoretical_sta.n11_calculator(traffic_name, data_name, channel_name, guard_name, highest_name, encryption_name,
 | 
						|
                                  qos_name, ip_name,
 | 
						|
                                  mc_name, basic_name, mac_name,
 | 
						|
                                  codec_name, plcp_name, cwin_name, rts_name, cts_name)
 | 
						|
        Station2.calculate()
 | 
						|
        Station2.get_result()
 | 
						|
    if "11ac" in Calculator_name:
 | 
						|
        Station3 = wlan_theoretical_sta.ac11_calculator(traffic_name, data_name, spatial_name, channel_name, guard_name, highest_name,
 | 
						|
                                   encryption_name
 | 
						|
                                   , qos_name, ip_name, mc_name, basic_name, mac_name,
 | 
						|
                                   codec_name, cwin_name, rtscts_name)
 | 
						|
        Station3.calculate()
 | 
						|
        Station3.get_result()
 | 
						|
 | 
						|
 | 
						|
if __name__ == "__main__":
 | 
						|
    main() |