Hi !
I am currently trying to develop a network stack for my OS and I need a bit of your help. I started by writing a driver for RTL8139 network card. The problem is I have no idea how to check it works properly.
Actually, I did try to send some packets from my OS : I set up a tap device, specified it to Qemu (the VM I use for my tests) and tried to send ethernet frames from my OS. While listening on my tap with tcpdump, the sent packets seemed to be detected.
But now I'd like to check whether my NIC driver can process received packets. I unsuccessfully tried the following: associate IPv4 address 192.168.1.166 (which was unused, I did check) to my tap, ping it. The ping responded but no frame was received by my OS. However, I'm not sure this test is appropriate.
I'd like to be able to test my driver before developping the upper layers of my network stack. What do you suggest ?
Thanks in advance.
RTL8139 NIC driver: how to test ?
Re: RTL8139 NIC driver: how to test ?
Did you get IRQ triggered when you ping your OS with multi-cast packets?
If not, you may want to double check your qemu parameters and host's interface setting, you should get random junk packets with valid bridge mode.
I'm using this on linux:
Once you start getting IRQ, make sure you initialize the RX buffer with physical address.
If not, you may want to double check your qemu parameters and host's interface setting, you should get random junk packets with valid bridge mode.
I'm using this on linux:
Code: Select all
-netdev type=tap,id=br0 -device rtl8139,netdev=br0
Re: RTL8139 NIC driver: how to test ?
No, ping multicast does not work.
However, I have tried to create a bridge ; I added tap0 (my tap interface) and enp3s0 (my Ethernet interfavce) to this bridge and finally my driver seemed to receive packets. But it would be interested to test your method also: what do you put in your qemu-ifup script ?
Still, ping does not work and I don't understand why.
However, I have tried to create a bridge ; I added tap0 (my tap interface) and enp3s0 (my Ethernet interfavce) to this bridge and finally my driver seemed to receive packets. But it would be interested to test your method also: what do you put in your qemu-ifup script ?
Still, ping does not work and I don't understand why.
Re: RTL8139 NIC driver: how to test ?
My if interface is configured with:
You may also read more on https://help.ubuntu.com/community/KVM/Networking.
Code: Select all
auto br0
iface br0 inet dhcp
bridge_ports eth0
bridge_stp off
bridge_fd 0
bridge_maxwait 0
Do you ping to a specific unicast IP or multi-cast address? Are you sure the packet get routed to correct NIC?karuon wrote:Still, ping does not work and I don't understand why.
Re: RTL8139 NIC driver: how to test ?
Well, first I tried to ping 192.168.1.166 and then 224.0.0.1. But pinging 224.0.0.1 gives no response (maybe because no machine in my local network supports multicast ?).bluemoon wrote:Do you ping to a specific unicast IP or multi-cast address?
Unfortunately,bluemoon wrote:Are you sure the packet get routed to correct NIC?
Code: Select all
tcpdump -i tap0
But I think this problem is not specifically related to Qemu. When creating a tap device (tap0) this way:
Code: Select all
ip tuntap add user $USER mode tap
ip address add 192.168.1.166 dev tap0
ip link set dev tap0 up
Code: Select all
ip link show
Code: Select all
ip link set dev tap0 up
Re: RTL8139 NIC driver: how to test ?
You need to specify the NIC for such multi-cast group, otherwise it might get defaults to lo0.
The other method is manually join the group with setsockopt / IP_ADD_MEMBERSHIP, but it is unnecessary in this case.
Check it here: http://www.tldp.org/HOWTO/Adv-Routing-H ... icast.html
Note that a physical router may block multicast packets to non-subscribers, but it should work for direct connected machines and emulators.
The other method is manually join the group with setsockopt / IP_ADD_MEMBERSHIP, but it is unnecessary in this case.
Check it here: http://www.tldp.org/HOWTO/Adv-Routing-H ... icast.html
Note that a physical router may block multicast packets to non-subscribers, but it should work for direct connected machines and emulators.
Re: RTL8139 NIC driver: how to test ?
I've tried to specify a new route (224.0.0.0/4) using NIC tap0, but I still get nothing with tcpdump -i tap0 when I ping 224.0.0.1 for instance.