简体   繁体   中英

How to add scapy traffic in mininet?

I know that we can use scapy to create packet but how to detect this packet in controller of mininet (It can be any controller like POX, Pyretic, Frenetic, RYU, etc). Can anyone explain this with the proper code to run in mininet environment?

What you can use is to add listeners in your controller and capture packets:

core.openflow.addListenerByName("FlowStatsReceived", self._handle_flowstats_received)
core.openflow.addListenerByName("PortStatsReceived", self._handle_portstats_received)
core.openflow.addListenerByName("QueueStatsReceived", self._handle_qeuestats_received)
And in some class methods later

For a full example check https://github.com/tsartsaris/pythess-SDN/blob/master/pythess.py

Or you can execute a shell code in one host and send traffic using iperf to another host in mininet and then try to capture it using tcpprobe. This way will be much easier. Here is the pseudo code:

sudo cat /proc/net/tcpprobe > tcprobe.dat &
#get the cat process ID to later kill it
pid=$!
iperf -c [Host1 ip] -t 10 -Z reno > Raw_Goodput.dat
#kill the logger
kill $pid

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM