API Documentation¶
ipktgen¶
client server packet generator
- class ipktgen.genpackets.Genpackets(allappmodels, allusessions, client, outdir, modeltype='Type4')[source]¶
Genpackets uses traffic model files and a user sessions file to generate packets on a device, using the device operating system networking stack.
- __init__(allappmodels, allusessions, client, outdir, modeltype='Type4')[source]¶
- Parameters
allappmodels (str) – traffic model file to use in generating traffic
allusersessions (str) – json file containing details of all user sessions for which traffic should be generated, and their start times.
client (bool) – if true traffic should be generated in client mode on the device. Otherwise, generate in server mode.
outdir (str) – output directory to save log files
modeltype (str) – the modeling method used to create the application model file, which will also be used to generate traffic. options are from the set (‘Type1’,’Type2’, ‘Type3’, ‘Type4’)
gen_netutils¶
utils for pkt creation and decoding
- ipktgen.gen_netutils.create_ether_hdr(dst_mac, src_mac, e_type, vlan_tag=None)[source]¶
creates an ethernet packet using given parameters etype can be a number<1500, or ip, or arp
- ipktgen.gen_netutils.create_udp_hdr(src_port, dst_port, l3_proto='ipv4', payload=None)[source]¶
creates an IP packet from supplied components
- ipktgen.gen_netutils.fake_sleep(delay_secs)[source]¶
fake sleep that stalls a process for delaySecs while using 100% cpu
- ipktgen.gen_netutils.fake_sleep_until(time_x)[source]¶
fake sleep that stalls a process for delaySecs while using 100% cpu
- ipktgen.gen_netutils.get_exit_iface(dest_ip)[source]¶
gets the exit interface for a target destination IP
- ipktgen.gen_netutils.get_ipv4_addresses(ifaces=['lo', 'ens3', 'ens4', 'ovs-system', 'inet-br', 'docker0', 'v6771109361585'])[source]¶
ifaces must be a list of ifaces, default is all interfaces include lo
- ipktgen.gen_netutils.get_mac_by_arp(ip_addr)[source]¶
gets the mac address for a given IP address using ARP
- ipktgen.gen_netutils.get_next_hop_ip(dest_ip)[source]¶
gets the next hop IP for a target destination IP
- ipktgen.gen_netutils.get_pkt_data_len(buf)[source]¶
gets tje packet data lenth for a packet that is arp icmp udp or tcp
- ipktgen.gen_netutils.ipv4_cidr_to_netmask(cidr)[source]¶
converts IP in CIDR format to tuple (ip,netmask)
- ipktgen.gen_netutils.ipv4_hex_2_str(ip_addr_hex)[source]¶
converts IP addrs in a.b.c.d format to hex
- ipktgen.gen_netutils.ipv4_string_2_hex(ip_addr_string)[source]¶
converts IP addrs in a.b.c.d format to hex
- ipktgen.gen_netutils.is_valid_mac_addr(mac_addr)[source]¶
return True if mac_addr is a valid mac address