Skip to content

The scapy sniff can not work correctly? #79

@ChengjunJia

Description

@ChengjunJia

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions