总的来说是跟着 hint 和 init 做
在 transmit 部份,主要知道有什么可以操作 (tx_mbufs and tx_ring) ,知道传入一个 mbuf 要从 ring 传出就好了,另外要知道 regs 怎么对网卡操作
在 recv 部份,第一次看官方 hint 的时候没想到一次 recv 可能接收多个包,所以就没有放在循环里面错了,后来看了中文文档才想到这一点,放在 while 里面遍历所有内容
其余的也是跟着 hint 做
实现不难,主要是理解
misc
tcpdump -XXnr packets.pcap
-XX: When parsing and printing, in addition to printing the headers of each packet, print the data of each packet, including its link level header, in hex and ASCII.
-n: Don’t convert addresses (i.e., host addresses, port numbers, etc.) to names.
-r: Read packets from file (which was created with the -w option or by other tools that write pcap or pcapng files).
测试
$ nettests
nettests running on port 25099
testing ping: OK
testing single-process pings: OK
testing multi-process pings: OK
testing DNS
DNS arecord for pdos.csail.mit.edu. is 128.52.129.126
DNS OK
all tests passed.
# make grade
== Test running nettests ==
$ make qemu-gdb
(7.6s)
== Test nettest: ping ==
nettest: ping: OK
== Test nettest: single process ==
nettest: single process: OK
== Test nettest: multi-process ==
nettest: multi-process: OK
== Test nettest: DNS ==
nettest: DNS: OK
== Test time ==
time: FAIL
Cannot read time.txt
Score: 99/100
make: *** [Makefile:336: grade] Error 1