linux lover wrote:
I am newbie to Linux kernel
programming. I want to write my own virtual network
device driver that take every packets from IP layer
just print the contents of packet(header part with its
starting addresses only) and send it to actual device
driver for packet transmission and at receiving end
receive packet from NIC card again print the header
addresses and send it to upper layer for normal packet
I require help about where can i get
resources or any book for writing virtual network
driver with SAMPLE EXAMPLES?
Another mail gave you pointers to driver programming.
Here are links to TUN/TAP, a virtual ethernet (or point-to-point) device
driver in the Linux kernel.
With TAP you have a virtual ethernet device, where the device driver is
replaced with a userspace application (that you write) that receives all
data sent to the tap device (for instance tap0) from the linux kernel
This data contains ethernet header + all other payload (like IP-header +
IP data with either TCP/UDP or arp-packets)..
Your userspace app may also send data to a tap-device and this data will
be sent to the linux network stack like it came from a real ethernet device.
So your userspace app may do whatever it want with the data, it may
print out the contents of the IP layer and forward the data to another
PC using the real ethernet device (eth0, or another network medium).
The other PC may do the opposite, i.e. receive the data from the
ethernet device and send then to the tap device.
Your application may even encapsulate the data send between the two PC
in any protocol you may like (you got tunneling).
If you wanted to do all in kernel mode this is not what you want, but
tun/tap code may give you some tips on how to create a virtual ethernet
See these links:
Roar B. Rotvik