Page 1 of 1

Simplest way to test PCI nw driver

Posted: Sun Feb 28, 2021 7:49 am
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

Re: Simplest way to test PCI nw driver

Posted: Sun Feb 28, 2021 8:37 am
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

Re: Simplest way to test PCI nw driver

Posted: Sun Feb 28, 2021 6:49 pm
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!

Re: Simplest way to test PCI nw driver

Posted: Mon Mar 01, 2021 5:44 am
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