introduction to linux kernel tcp/ip ptocotol stack

16
Introduction to Linux Kernel TCP/IP procotol stack 雕梁 核心系统服务器平台组 [email protected] [email protected] http://www.pagefault.info 2011/01/15

Upload: monad-bobo

Post on 24-May-2015

22.630 views

Category:

Documents


3 download

DESCRIPTION

introduction to linux kernel tcp/ip ptocotol stack

TRANSCRIPT

Page 1: introduction to linux kernel tcp/ip ptocotol stack

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

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

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

Networking code in the Linux kernel tree

Net-Kernel source tree

Page 5: introduction to linux kernel tcp/ip ptocotol stack

Big picture

Page 6: introduction to linux kernel tcp/ip ptocotol stack

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

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

Link Layer bigmap

Page 9: introduction to linux kernel tcp/ip ptocotol stack

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

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

Network Layer Bigmap

Page 12: introduction to linux kernel tcp/ip ptocotol stack

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

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

TCPBigmap

Page 15: introduction to linux kernel tcp/ip ptocotol stack

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

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