Simplest way to test PCI nw driver

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
User avatar
Robert
Member
Member
Posts: 25
Joined: Wed Jan 13, 2021 8:49 am

Simplest way to test PCI nw driver

Post by Robert »

Hi!

I'm writing a nw card driver for my OS.
I've stuck at a programming problem, and don't have
a consistent test to check my modifications.
Could you tell me a simple way to send raw
packets from a host process to guest QEMU VM?
Nw hw is an e1000 or something similar, standard card.
Thanks in advance
User avatar
bzt
Member
Member
Posts: 1584
Joined: Thu Oct 13, 2016 4:55 pm
Contact:

Re: Simplest way to test PCI nw driver

Post by bzt »

Robert wrote:Could you tell me a simple way to send raw packets
I don't think that's possible. Not in a simple way anyway. Try using simple one packet protocols instead, like ICMP or UDP. Check out "ping", "mtr" and "nc -u" (netcat).
Otherwise tcpdump can save pcap files, and there's a way to replay a pcap with bit-twist or tcpreplay. So if you manually create a pcap file with a hex editor, you can send raw packets, but that's not simple nor easy to do at all.

Cheers,
bzt
xeyes
Member
Member
Posts: 212
Joined: Mon Dec 07, 2020 8:09 am

Re: Simplest way to test PCI nw driver

Post by xeyes »

Robert wrote:Hi!

I'm writing a nw card driver for my OS.
I've stuck at a programming problem, and don't have
a consistent test to check my modifications.
Could you tell me a simple way to send raw
packets from a host process to guest QEMU VM?
Nw hw is an e1000 or something similar, standard card.
Thanks in advance
It should be possible to write a script or program to send raw pocket from the host. Probably can't be too malformed though like not having IP headers, etc. You aren't trying to reinvent a different networking standard from that level up right? Standard NICs are unlikely to accept pockets without IP headers either so that either ways won't work.

Then, you can probably find some inspirations from viewtopic.php?f=1&t=39828 about how to get the pockets into Qemu.

Good luck!
User avatar
Robert
Member
Member
Posts: 25
Joined: Wed Jan 13, 2021 8:49 am

Re: Simplest way to test PCI nw driver

Post by Robert »

So if I'd like to create a tap device to connect VM's nw interface and my package sender python script, how should I do it (it doesn't work for me now)

my idea:
sudo /etc/qemu-ifup tapdev
qemu ... -net tap,ifname=tapdev,script=0,downscript=no
And open /dev/tapdev as a binary file
Post Reply