Packetdrill
细读P4论文(Programming Protocol-Independent Packet Processors)
Install and Usage
下载地址:https://github.com/google/packetdrill
1 | root |
添加环境变量(方便执行,不必须)
1 | vim /root/.bashrc |
将编译出的packetdrill可执行文件拷贝到/usr/local/bin目录下。
1 | cp /home/kun/Downloads/packetdrill-master/gtests/net/packetdrill/packetdrill /usr/local/bin |
执行+tcpdump监测
编写test.pkt文件:
1 | 0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3 |
打开终端1,用tcpdump监测8080端口(bind默认绑定端口):
1 | root@ubuntu:~# sudo tcpdump -i any port 8080 -nn |
打开终端2执行上面的pkt测试脚本:
1 | packetdrill test.pkt |
这时终端1监测到的信息如下:
1 | 13:33:36.573132 IP 192.0.2.1.49941 > 192.168.22.185.8080: Flags [S], seq 0, win 4000, options [mss 1000], length 0 |