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’)

generate()[source]

begin the packet generation process

gen_netutils

utils for pkt creation and decoding

ipktgen.gen_netutils.calc_ipv4_checksum(ip_hdr)[source]

calculates the checksum of an IP header

ipktgen.gen_netutils.calc_udp_checksum(data)[source]

calculates the checksum of a UDP header

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.dpktMacAddr2Str(addr)[source]

Convert MAC address to normal string

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_ether_type(eth_val)[source]

returns the string eth type

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(iface)[source]

gets the mac address of an interface iface

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

ipktgen.gen_netutils.mac_hex_2_str(mac_addr)[source]

removes the colums in a mac address of format aa:11:bb:22:cc:33

ipktgen.gen_netutils.mac_str_2_hex(mac_addr)[source]

removes the colums in a mac address

ipktgen.gen_netutils.modify_ipv4_hdr(pkt, change)[source]

modify a packet with given info

ipktgen.gen_netutils.modify_udp_hdr(pkt, change)[source]

modify a packet with given info