p4app icon indicating copy to clipboard operation
p4app copied to clipboard

The scapy sniff can not work correctly?

Open ChengjunJia opened this issue 4 years ago • 0 comments

Hi, all. I want to use scapy to write my own client and server in multi_switch_mininet.p4app. However, I find that if I modify the echo_server.py to enable sniff() function and enable the pcap_dump in p4app.json. The pcap results will contain a strange packet: an IPv4+ICMP packet which container total IP+UDP packet in its payload! But from the sniff() result, the host received a UDP packet instead of IPv4+ICMP packet.

Here is the echo_server.py codes:

import socket, sys
from scapy.all import *
import time

print("Start to sniff packets...")
sniffed = sniff(iface="h1-eth0", filter="ip", prn=custom_action, count = 5)
for pkt in sniffed:
        pkt.show()
time.sleep(5)

And here is the echo_client.py codes:

import socket, sys
from scapy.all import *
import os

srv_addr = (sys.argv[1], int(sys.argv[2]))
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.sendto(sys.argv[3], srv_addr)

Anyone has any idea? Besides, the pcap result is a little confusing for me. s1-eth1_out.pcap means that the packets leave the s1 from eth1 or go into s1 from eth1?

ChengjunJia avatar Sep 28 '20 08:09 ChengjunJia