RTL8139 NIC driver: how to test ?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
karuon
Posts: 22
Joined: Sat Jun 29, 2013 6:16 am

RTL8139 NIC driver: how to test ?

Post by karuon »

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.
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: RTL8139 NIC driver: how to test ?

Post by bluemoon »

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:

Code: Select all

-netdev type=tap,id=br0 -device rtl8139,netdev=br0
Once you start getting IRQ, make sure you initialize the RX buffer with physical address.
karuon
Posts: 22
Joined: Sat Jun 29, 2013 6:16 am

Re: RTL8139 NIC driver: how to test ?

Post by karuon »

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.
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: RTL8139 NIC driver: how to test ?

Post by bluemoon »

My if interface is configured with:

Code: Select all

auto br0
iface br0 inet dhcp
        bridge_ports eth0
        bridge_stp off
        bridge_fd 0
        bridge_maxwait 0
You may also read more on https://help.ubuntu.com/community/KVM/Networking.
karuon wrote:Still, ping does not work and I don't understand why.
Do you ping to a specific unicast IP or multi-cast address? Are you sure the packet get routed to correct NIC?
karuon
Posts: 22
Joined: Sat Jun 29, 2013 6:16 am

Re: RTL8139 NIC driver: how to test ?

Post by karuon »

bluemoon wrote:Do you ping to a specific unicast IP or multi-cast address?
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:Are you sure the packet get routed to correct NIC?
Unfortunately,

Code: Select all

tcpdump -i tap0
displays nothing while pinging.

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
pinging 192.168.1.166 does not work according to tcpdump output. I think the problem is here. By the way, even after setting tap0 up,

Code: Select all

ip link show
says it is down. And no error is displayed by

Code: Select all

ip link set dev tap0 up
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: RTL8139 NIC driver: how to test ?

Post by bluemoon »

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.
karuon
Posts: 22
Joined: Sat Jun 29, 2013 6:16 am

Re: RTL8139 NIC driver: how to test ?

Post by karuon »

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.
Post Reply