![Page 1: introduction to linux kernel tcp/ip ptocotol stack](https://reader035.vdocuments.pub/reader035/viewer/2022081717/55614ed6d8b42a8a7d8b4df9/html5/thumbnails/1.jpg)
Introduction to Linux Kernel TCP/IP procotol stack
雕梁核心系统服务器平台组[email protected]
[email protected]://www.pagefault.info
2011/01/15
![Page 2: introduction to linux kernel tcp/ip ptocotol stack](https://reader035.vdocuments.pub/reader035/viewer/2022081717/55614ed6d8b42a8a7d8b4df9/html5/thumbnails/2.jpg)
AgendaIntroduction
Networking code in the Linux kernel tree
L2 (Link Layer)
L3 (Network Layer)
L4 (Transport Layer)
Config and benchmark tools
Resource
![Page 3: introduction to linux kernel tcp/ip ptocotol stack](https://reader035.vdocuments.pub/reader035/viewer/2022081717/55614ed6d8b42a8a7d8b4df9/html5/thumbnails/3.jpg)
Introduction
Sourcehttp://git.kernel.org/net-next-2.6 and net-2.6
DeveloperAlan Cox, David Miller, Eric Dumazet, Patrick Mchardy etc.
Traffic directionsinput , forward and output
LayerL2(Link Layer)/L3(Network Layer)/L4(Transport Layer)
Device interfacePCI/PCI-E
![Page 4: introduction to linux kernel tcp/ip ptocotol stack](https://reader035.vdocuments.pub/reader035/viewer/2022081717/55614ed6d8b42a8a7d8b4df9/html5/thumbnails/4.jpg)
Networking code in the Linux kernel tree
Net-Kernel source tree
![Page 5: introduction to linux kernel tcp/ip ptocotol stack](https://reader035.vdocuments.pub/reader035/viewer/2022081717/55614ed6d8b42a8a7d8b4df9/html5/thumbnails/5.jpg)
Big picture
![Page 6: introduction to linux kernel tcp/ip ptocotol stack](https://reader035.vdocuments.pub/reader035/viewer/2022081717/55614ed6d8b42a8a7d8b4df9/html5/thumbnails/6.jpg)
Link layerFrame type
802.3/802.2/802.2-SNAP/EthernetInput
DriverNAPI
Poll + InterruptSoft interrupt
GROfeed packet to network stack
RPS/RFSmake steer in SMP
Protocol handleruse eth_type_transPacket_type list
![Page 7: introduction to linux kernel tcp/ip ptocotol stack](https://reader035.vdocuments.pub/reader035/viewer/2022081717/55614ed6d8b42a8a7d8b4df9/html5/thumbnails/7.jpg)
Link layerOutput
Traffic ControlSoft interrupt
Transmit SKBScatter/Gather DMA
Free skbXPS
multiqueueavoid cache line bouncingimprove locality
BridgeVirtual device, must bind one or more real deviceSpanning Tree Protocol
![Page 8: introduction to linux kernel tcp/ip ptocotol stack](https://reader035.vdocuments.pub/reader035/viewer/2022081717/55614ed6d8b42a8a7d8b4df9/html5/thumbnails/8.jpg)
Link Layer bigmap
![Page 9: introduction to linux kernel tcp/ip ptocotol stack](https://reader035.vdocuments.pub/reader035/viewer/2022081717/55614ed6d8b42a8a7d8b4df9/html5/thumbnails/9.jpg)
Network Layer(IP)Input
Protocol handlernet_protocol array
defragmentHashtable
Each IP packet being defragmented save in a liststored in kernel memory until they are totally processed
Outputfragment
MTUScatter/Gather IOudp
neighboring
![Page 10: introduction to linux kernel tcp/ip ptocotol stack](https://reader035.vdocuments.pub/reader035/viewer/2022081717/55614ed6d8b42a8a7d8b4df9/html5/thumbnails/10.jpg)
Network Layer(IP)Forward
process ip optionigonore defragmentation
Router Alert optionRoute
Forwarding Information Base(routing table)cache
NetfilterHOOK point
NF_IP_LOCAL_OUT/ NF_IP_LOCAL_IN etc..Management
Long-living IP peer information AVL tree
IP statistics per cpu data ipstats_mib/proc/net/snmp
![Page 11: introduction to linux kernel tcp/ip ptocotol stack](https://reader035.vdocuments.pub/reader035/viewer/2022081717/55614ed6d8b42a8a7d8b4df9/html5/thumbnails/11.jpg)
Network Layer Bigmap
![Page 12: introduction to linux kernel tcp/ip ptocotol stack](https://reader035.vdocuments.pub/reader035/viewer/2022081717/55614ed6d8b42a8a7d8b4df9/html5/thumbnails/12.jpg)
Transport Layer (tcp)Init
bind callback (sock_create)Three handshrek
accept queuesyn tablecreate new socket fd and change state
Manage socketinet_ehash_bucket
TCP_ESTABLISHED <= sk->sk_state < TCP_CLOSEinet_bind_hashbucket
local binding port infolistening_hash
socket in TCP_LISTEN state
![Page 13: introduction to linux kernel tcp/ip ptocotol stack](https://reader035.vdocuments.pub/reader035/viewer/2022081717/55614ed6d8b42a8a7d8b4df9/html5/thumbnails/13.jpg)
Transport Layer (tcp)Output
Tcp pushCongestion control
state transitioncongestion windowspacket count
Inputfast path and slow pathInterrupt context/ Process contextsk_backlog/receive_queue/prequeue
Tcp state transitionKernel control
TimerRetransmit/keep-alive/time-wait etc
![Page 14: introduction to linux kernel tcp/ip ptocotol stack](https://reader035.vdocuments.pub/reader035/viewer/2022081717/55614ed6d8b42a8a7d8b4df9/html5/thumbnails/14.jpg)
TCPBigmap
![Page 15: introduction to linux kernel tcp/ip ptocotol stack](https://reader035.vdocuments.pub/reader035/viewer/2022081717/55614ed6d8b42a8a7d8b4df9/html5/thumbnails/15.jpg)
Config and Benchmark Tools
Ethtooloffload fetures
Benchmark and test toolsNetperf/pktgenMpstat/tcpstat
Proc FileSystem
/proc/net/proc/sys/net
ipv4core
Sys FileSystem/sys/class/net/ethx
![Page 16: introduction to linux kernel tcp/ip ptocotol stack](https://reader035.vdocuments.pub/reader035/viewer/2022081717/55614ed6d8b42a8a7d8b4df9/html5/thumbnails/16.jpg)
Resource
http://kernelnewbies.org http://kernel.org http://www.kernelplanet.org https://lkml.org http://vger.kernel.org/vger-lists.html http://www.pagefault.info/?tag=kernel