Above we read merely about the theory of networking, about the basic ideas, about communication protocols and standards. Now, let us see, how all of this is being handled by the Linux Kernel 2.6:
The main interface between the kernel and userspace is the set of
system calls. There are about
system calls. Network related
system calls include:
writes to socket
write()on a socket and all the data is copied from the process space into the send socket buffer
/proc/sys/net/core/netdev_max_backlog). Once it is full, it waits for being totally empty to allow again an enqueue() (netif_rx(), net/core/dev.c).
/proc is the POSIX complient mount point for the Virtual Filesystem for the processes.
/proc/cpuinfo: processor information
/proc/meminfo: memory status
/proc/version: kernel version and build information
/proc/cmdline: kernel command line
/proc/<pid>/environ: calling environment
/proc/<pid>/cmdline: process command line
See → http://gettys.wordpress.com/2010/11/29/home-router-puzzle-piece-one-fun-with-your-switch/ for some "fun" with all the queues.
So you can install hardware capable of Ethernet (usually a network card or more precisely an Ethernet card) on two hosts, connect them with a standardized cable, like a Category 5 cable and communicate with one another over Ethernet as far as your software supports Ethernet Sooner or later the sausage will get to the Ethernet thingy of the network stack, this will prepare the data conforming to the Ethernet standard, then will deliver the frames to the network card drivers and this will make the hardware, the network card, transmit the data.
The NIC on the other side will receive the signal, relay it to the Ethernet thingy of the network stack, this will create one huge data out of the Ethernet frames and relay it to the software.
When a packet is enqueued on an interface with
dev queue xmit (in
enqueue operation of the packet scheduler is triggered and
qdisc wakeup is being called (in
net/pkt_sched.h) to send the packet on that device.
A transmit queue is associated with each device. When a network packet is ready for transmission, the "networking code" will call the driver's
hard_start_xmit()-function to let it know, a packet is waiting. The driver will then put that packet into the
transmit queue of the hardware.
You find the sources for the whole TCP/IP protocol suite implementation