Scapy Packet Capture Performance Testing Report
Scapy Packet Capture Performance Testing Report
2. Abstract
This report presents the results of testing the Scapy library for packet capture. The objective was to
determine the traffic rates at which packet loss occurs and assess if Scapy is suitable for our IP link
analyzer project. Tests were conducted on the loopback (lo) interface using various traffic rates and
durations with iperf3. We recorded packet capture counts, CPU usage, memory usage, and packet
loss percentages.
3. Introduction
The purpose of this testing was to evaluate the performance of the Scapy library in capturing network
packets under different conditions. The focus was on measuring packet loss, CPU usage, and
memory consumption at various traffic rates, durations, and numbers of packets. The results will help
determine if Scapy is suitable for our core packet capture script.
Environment Setup:
1. Stop Network Manager: Ensure the Network Manager is stopped to avoid any unnecessary
DNS packets and get more accurate readings.
2. Disable Unnecessary Plugins: If using an IDE like VSCode, disable any unnecessary plugins
that might generate additional network traffic.
1. Install Scapy:
2. Capture Script: Use the provided capture script from the GitHub repository:
core_packet_capture.py
3. Run the Script: Execute the script to start capturing packets on the loopback interface.
1. Install iperf3:
iperf3 -s
3. Generate Traffic:
For Specific Bandwidth and Duration:
1. Capture Packets with Scapy: Run the Scapy capture script while generating traffic with iperf3.
2. Open Wireshark: Launch Wireshark and start capturing on the loopback interface ( lo ).
3. Verify Captured Packets: Compare the packets captured by Scapy with those captured by
Wireshark to ensure consistency.
top
2. Record Packet Loss: Analyze the captured packets to calculate the packet loss percentage by
comparing the number of packets sent with the number of packets received.
5. Results
Rate Duration packets packets packets packet loss% cpu% cpu% memory memory
captured captured lost user system used free
(scapy) (wireshark) (mib) (mib)
100M 300 228925 114474 11.5 0.0100459493 3.4 0.3 1550 8623.3
100M 1000 762885 381551 108.5 0.02843656549 2.8 0.4 2225.8 151.2
1G 10 48457 38079 13850.5 36.37306652 2 0.9 2011.3 9108.3
1G 30 143702 114387 42536 37.18604387 4 0.7 2346.5 7263.8
1G 60 289138 228710 84141 36.78938394 8.2 1.4 2290.3 3640
Rate packets packet packet packets packet cpu% cpu% memory memory
sent captured captured lost loss % user system used free
(scapy) (wireshark) (mib) (mib)
1K 10 84 42 0 0 1.7 0.5 1786.6 11084.3
1K 100 264 132 0 0 1.1 0.4 1791.4 11093.4
10K 10 84 42 0 0 0.4 0.3 1753.8 11126.2
100M 1000000 800323 1000040 599878.5 59.98545058 1.5 0.4 2120.4 9212.2
1G 10 82 41 0 0 1 0.4 2130.7 10684.8
1G 100 113 131 74.5 56.87022901 0.6 0.3 2137.9 10701.9
1G 1000 204 1039 937 90.18286814 0.6 0.3 2143 10695.2
1G 10000 780 10032 9642 96.11244019 0.7 0.3 2133.4 10688.7
Duration-Based Tests
Analysis of Results:
Duration-Based Tests:
At low traffic rates (up to 10Mbps), Scapy performs well with negligible packet loss.
Significant packet loss starts at 100Mbps, becoming critical at 1Gbps.
CPU usage remains low across most tests, but spikes significantly at higher traffic rates and
durations.
Memory consumption also spikes significantly at higher traffic rates and durations.
Packet-Based Tests:
Similar trends are observed with low to moderate traffic rates showing minimal packet loss.
High traffic rates (100Mbps and above) exhibit substantial packet loss, particularly with large
numbers of packets.
CPU and memory usage patterns are consistent with those observed in duration-based
tests.
7. Conclusion
Summary of Findings:
Scapy is suitable for low to moderate traffic rates, with minimal packet loss and stable resource
usage.
For high traffic rates (100Mbps and above), Scapy experiences significant packet loss, which
may impact the project's performance requirements.
Scapy can be used for packet capture in environments with traffic rates up to 10Mbps. For our IP
link analyzer project, alternative solutions should be considered to avoid packet loss issues.