cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
938
Views
0
Helpful
1
Replies

Packet filtering with python API

kasai
Cisco Employee
Cisco Employee

Hi ALL,

Can any one suggest about how to filter the received frames using python APIs using source mac address/destination mac address for automation purpose.

1 Reply 1

imarom
Cisco Employee
Cisco Employee

Hi Srinivasa,

TRex Python API supports adding captures queues to the server.

A capture allows you define a queue with a specific size and then query it for its captured packets.

Please refer to our docs:

TRex Stateless Capture API Documentation

After you have queried for the packets, you can filter them using scapy however you like.

In the next version, packet captures will be enhanced to support BPF (Berkeley Packet Filters).

This means that even under high traffic you will be after to activate a capture and provide a BPF pattern to filter the correct traffic.

For example:

client.start_capture(rx_ports = [0, 1], bpf_filter = 'ether src 01:02:03:04:05:06')

this will capture only packets that their source Ethernet address is 01:02:03:04:05:06

BPF filter format is the same as supported by tcpdump and alike.

Thanks,

Itay