Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I send data packets into the network without using sockets?

I want to send data packets into the network bypassing the Linux network stack. I mean is there any way where I can interrupt the network card driver and place a frame in the network card buffer directly to send it in the network? I am a newbie in Linux Kernel hacking so any guideline on how I can get started will be very helpful.

like image 504
mushfek0001 Avatar asked May 04 '13 17:05

mushfek0001


People also ask

How do you make a raw socket?

Creating a Raw Socket To create a socket of type SOCK_RAW, call the socket or WSASocket function with the af parameter (address family) set to AF_INET or AF_INET6, the type parameter set to SOCK_RAW, and the protocol parameter set to the protocol number required.

What is the use of raw sockets?

The raw socket interface provides direct access to lower layer protocols, such as the Internet Protocol (IP) and Internet Control Message Protocol (ICMP or ICMPv6). You can use raw sockets to test new protocol implementations.

What are packet sockets?

Description. Packet sockets are used to receive or send packets at the device driver (OSI Layer 2) level. These allow users to implement protocol modules in user space on top of the physical layer.

What is raw packets?

Raw packet is used when you dont have any, the first bytes captured are directly the IPv6 or IPv4 header. Raw IP; the packet begins with an IPv4 or IPv6 header, with the "version" field of the header indicating whether it's an IPv4 or IPv6 header.


1 Answers

You would be better off if you used some virtual device like TAP. You can easily hack a control interface into the TAP kernel module, via which you can then pass frames ready to be sent out to the driver. That approach can be compared to the performance of a regular socket application as the baseline. Since in the end the TAP device will "send" out egress frames via a character device, you can easily write a test application measuring performance and latency.

like image 95
ldx Avatar answered Oct 13 '22 11:10

ldx