Network Applications user socket BSD Sockets kernel sock

Network Applications user socket BSD Sockets kernel sock INET Sockets TCP sk_buff UDP IP ARP PPP SLIP Ethernet

sys_socketcall() send ip_queue_xmit sys_send() sock->ops->sendmsg dev_queue_xmit inet_sendmsg() sk->prot->sendmsg tcp_sendmsg() do_dev_queue_xmit dev->hard_start_xmit el 3_start_xmit() do_tcp_sendmsg() tcp_send_skb sk->prot->queue_xmit


do_tcp_sendmsg() • Allocate sk_buff • construct hardware and IP header – sk->prot->build_header() • ip_build_header • construct TCP header

ip_queue_xmit() • Partially initialize skb (sk_buff) • check “free” value – free == 1: don’t free, keep skb on the sk send list – free == 0: after device send out, it will be freed • compute checksum • if lookback: call ip_lookback() • if fragmentation: call if_fragment() • call dev_queue_xmit()

do_dev_queue_xmit() • • • Lock device check if transmission find the corresponding list queue the skb in the tail of list dequeue the first skb in the list and call the dev->hard_start_xmit()

el 3_interrupt() el 3_rx() netif_rx() net_bh() pt_prev->fun() ip_rcv() ipprot->handler() tcp_rcv tcp_data() tcp_queue() sk->data_ready() def_callback 2()

Function Illustration • el 3_interrupt() – get the device interface – call el 3_rx() • el 3_rx() – allocate sk_buff – determine the packet’s protocol ID – call netif_rx()

Function Illustration (Cont. ) • netif_rx() – check if backlog_size is appropriate – if no => drop – else enqueue in the system backlog list – call mark_bh()

Function Illustration (Cont. ) • net_bh() – dev_transmit(): check each network interface if anyone is ready to transmit – _sbk_unlink(): dequeue the sk_buff from the backlog list – search the two system list for packet type • ptype_all: ETH_P_ALL • ptype_base[]: main protocol list – call pt_prev->func() : i. e. ip_rcv()

Function Illustration (Cont. ) • ip_rcv() – correction checking – ip_options_compile: ip options preprocessing – ip_defrag() – if my packet • ip_option_processing • check if raw ip • find the protocol and call ipprot->handler(): tcp_rcv() – else ip_forward()

Function Illustration (Cont. ) • tcp_rcv() – _tcp_v 4_lookup(): find the upper INET sock structure – call tcp_data() • tcp_data() – handle the data – call tcp_queue

Function Illustration (Cont. ) • tcp_queue() – tcp_insert_skb(): add a sk_buff to the tcp receive queue (sk->receive_queue) – sk->data_ready(): def_callback 2() • def_callback 2() – wake up the sleeping process

sys_socketcall() sys_recv() inet_recvmsg() tcp_recvmsg()
- Slides: 14