The Journey of a Packet Through the Linux Network Stack

Slides:



Advertisements
Similar presentations
Florida State UniversityCOP Advanced Unix Programming Raw Sockets Datalink Access Chapters 25, 26.
Advertisements

Device Layer and Device Drivers
COMS W6998 Spring 2010 Erich Nahum
1 IP Forwarding Relates to Lab 3. Covers the principles of end-to-end datagram delivery in IP networks.
Computer Networks20-1 Chapter 20. Network Layer: Internet Protocol 20.1 Internetworking 20.2 IPv IPv6.
CE363 Data Communications & Networking Chapter 7 Network Layer: Internet Protocol.
Network Layer – IPv4 Dr. Sanjay P. Ahuja, Ph.D.
CSE 461: IP/ICMP and the Network Layer. Next Topic  Focus:  How do we build large networks?  Introduction to the Network layer  Internetworks  Service.
NETWORK LAYER (1) T.Najah AlSubaie Kingdom of Saudi Arabia Prince Norah bint Abdul Rahman University College of Computer Since and Information System NET331.
LINUX NETWORK IMPLEMENTATION Jianyong Zhang. Introduction The layer structure of network: 1) BSD socket layer: general data structure for different protocols.
Internet Control Protocols Savera Tanwir. Internet Control Protocols ICMP ARP RARP DHCP.
Top-Down Network Design Chapter Thirteen Optimizing Your Network Design Copyright 2010 Cisco Press & Priscilla Oppenheimer.
CSE551: Computer Network Review r Network Layers r TCP/UDP r IP.
Shivkumar Kalyanaraman Rensselaer Polytechnic Institute 1 TCP/IP Stack Introduction: Looking Under the Hood! Shiv Kalyanaraman Rensselaer Polytechnic Institute.
Internet Control Message Protocol (ICMP). Introduction The Internet Protocol (IP) is used for host-to-host datagram service in a system of interconnected.
Page: 1 Director 1.0 TECHNION Department of Computer Science The Computer Communication Lab (236340) Summer 2002 Submitted by: David Schwartz Idan Zak.
Institute of Technology Sligo - Dept of Computing Semester 2 Chapter 9 The TCP/IP Protocol Suite Paul Flynn.
1 Network Packet Generator Final Presentation Presenting: Igor Brevdo Eugeney Ryzhyk, Supervisor: Mony Orbach.
IP-UDP-RTP Computer Networking (In Chap 3, 4, 7) 건국대학교 인터넷미디어공학부 임 창 훈.
CS 356 Systems Security Spring Dr. Indrajit Ray
Connecting Networks © 2004 Cisco Systems, Inc. All rights reserved. Defining the IP Packet Delivery Process INTRO v2.0—4-1.
© Janice Regan, CMPT 128, CMPT 371 Data Communications and Networking Network Layer ICMP and fragmentation.
Internet Protocol (IP)
1 ECE453 – Introduction to Computer Networks Lecture 12 – Network Layer (IV)
Top-Down Network Design Chapter Thirteen Optimizing Your Network Design Oppenheimer.
1 IP Forwarding Relates to Lab 3. Covers the principles of end-to-end datagram delivery in IP networks.
TCOM 515 IP Routing Lab Lecture 1. Class information Instructor: Wei Wu –Lecture and Lab session 2 – Instructor:
IP Forwarding.
CDPA 網管訓練 駭客任務 2 Ethernet Switching ARP, IP, LAN, Subnet IP Header, Routing ICMP
Fall 2005Computer Networks20-1 Chapter 20. Network Layer Protocols: ARP, IPv4, ICMPv4, IPv6, and ICMPv ARP 20.2 IP 20.3 ICMP 20.4 IPv6.
Suez Canal University – Faculty of Computers & Informatics - Cisco Local Academy Network Fundamentals.
TCOM 515 IP Routing. Syllabus Objectives IP header IP addresses, classes and subnetting Routing tables Routing decisions Directly connected routes Static.
1 IP : Internet Protocol Computer Network System Sirak Kaewjamnong.
Chapter 81 Internet Protocol (IP) Our greatest glory is not in never failing, but in rising up every time we fail. - Ralph Waldo Emerson.
Internet Protocol ECS 152B Ref: slides by J. Kurose and K. Ross.
Internetworking Internet: A network among networks, or a network of networks Allows accommodation of multiple network technologies Universal Service Routers.
Internetworking Internet: A network among networks, or a network of networks Allows accommodation of multiple network technologies Universal Service Routers.
Internet Protocols. Address Resolution IP Addresses are not recognized by hardware. If we know the IP address of a host, how do we find out the hardware.
1 Network Layer Lecture 16 Imran Ahmed University of Management & Technology.
An initial study on Multi Path Routing Over Multiple Devices in Linux 2.4.x kernel Towards CS522 term project By Syama Sundar Kosuri.
1 Kyung Hee University Chapter 8 Internet Protocol (IP)
CSC 600 Internetworking with TCP/IP Unit 5: IP, IP Routing, and ICMP (ch. 7, ch. 8, ch. 9, ch. 10) Dr. Cheer-Sun Yang Spring 2001.
Mr. Mark Welton.  Quality of Service is deployed to prevent data from saturating a link to the point that other data cannot gain access to it  QoS allows.
Chapter 8 Internet Protocol (IP)
Linux Operations and Administration Chapter Eight Network Communications.
1 12-Jan-16 OSI network layer CCNA Exploration Semester 1 Chapter 5.
1 Computer Communication & Networks Lecture 19 Network Layer: IP and Address Mapping Waleed Ejaz.
Internet Protocol Version 4 VersionHeader Length Type of Service Total Length IdentificationFragment Offset Time to LiveProtocolHeader Checksum Source.
1 CSE 5346 Spring Network Simulator Project.
Cisco Confidential © 2013 Cisco and/or its affiliates. All rights reserved. 1 Cisco Networking Training (CCENT/CCT/CCNA R&S) Rick Rowe Ron Giannetti.
Net7: IP 協定 Internet Protocol 授課教師:雲林科技大學 張慶龍 老師.
1 Internetworking: IP Packet Switching Reading: (except Implementation; pp )
Packet Switch Network Server client IP Ether IPTCPData.
IP - Internet Protocol No. 1  Seattle Pacific University IP: The Internet Protocol Kevin Bolding Electrical Engineering Seattle Pacific University.
Graciela Perera Department of Computer Science and Information Systems Slide 1 of 18 INTRODUCTION NETWORKING CONCEPTS AND ADMINISTRATION CSIS 3723 Graciela.
© 2003, Cisco Systems, Inc. All rights reserved.
Instructor Materials Chapter 6: Network Layer
Introduction to TCP/IP networking
sudo ./snull_load Two interfaces created: sn0, sn1
Top-Down Network Design Chapter Thirteen Optimizing Your Network Design Copyright 2010 Cisco Press & Priscilla Oppenheimer.
Chapter 6: Network Layer
Chapter 6: Network Layer
Byungchul Park ICMP & ICMPv DPNM Lab. Byungchul Park
IP Forwarding Relates to Lab 3.
Internet Protocol (IP)
Network Core and QoS.
Net 323 D: Networks Protocols
Network Architecture Models: Layered Communications
Review of Internet Protocols Network Layer
Network Core and QoS.
Presentation transcript:

The Journey of a Packet Through the Linux Network Stack … plus hints on Lab 9

Assumptions IP version 4 Codes are from Kernel 2.6.9.EL Ideas are similar

Linux High-Level Network Stack Interface to users TCP/UDP/IP etc… Queue for device Image from http://affix.sourceforge.net/affix-doc/c190.html

Receiving a Packet (Device) Network card receives a frame Driver handles the interrupt issues an interrupt Frame  RAM Allocates sk_buff (called skb) Frame  skb

Aside: sk_buff (skbuff.h) Generic buffer for all packets Pointers to skb are passed up/down Can be linked together Transport Header (TCP/UDP/ICMP) Network Header (IPv4/v6/ARP) MAC Header Raw

sk_buff (cont.) struct sk_buff *next struct sk_buff *prev struct sk_buff_head *list struct sock *sk … union {tcphdr; udphdr; …} h; Transport Header union {iph; ipv6h;arph;…} nh; Network Header union {raw} mac; MAC Header …. DATA

sk_buff (cont.) “Understanding Linux Network Internals”, Christian Benvenuti

Receiving a Packet (Device) Driver (cont.) calls device independent core/dev.c:netif_rx(skb) puts skb into CPU queue issues a “soft” interrupt CPU calls core/dev.c:net_rx_action() removes skb from CPU queue passes to network layer e.g. ip/arp In this case: IPv4 ipv4/ip_input.c:ip_rcv()

Receiving a Packet (IP) ip_input.c:ip_rcv() checks Length >= IP Header (20 bytes) Version == 4 Checksum Check length again calls route.c:ip_route_input() calls ip_rcv_finish()

Aside: Finish/Slow suffix Division into two stages is common Usually called “slow” The first stage cache The second stage table

Receiving a Packet (routing) ipv4/route.c:ip_route_input() ipv4/route.c:ip_route_input_slow() Destination == me? YES ip_input.c:ip_local_deliver() NO Calls ip_route_input_slow() Can forward? Forwarding enabled? Know route? NO Sends ICMP

Forwarding a Packet Forwarding is per-device basis Receiving device! Enable/Disable forwarding in Linux: /proc file system ↔ Kernel read/write normally (in most cases) /proc/sys/net/ipv4/conf/<device>/forwarding /proc/sys/net/ipv4/conf/default/forwarding /proc/sys/net/ipv4/ip_forwarding

Forwarding a Packet (cont.) ipv4/ip_forward.c:ip_forward() .... a few more calls core/dev.c:dev_queue_xmit() Default queue: priority FIFO sched/sch_generic.c:pfifo_fast_enqueue() Others: FIFO, Stochastic Fair Queuing, etc. IP TTL > 1 YES Decreases TTL NO Sends ICMP

Priority Based Output Scheduling pfifo_fast_enqueue() Again, per-device basis Queue Discipline (Qdisc: pkt_sched.c) Not exactly a priority queue Uses three queues (bands) 0 “interactive” 1 “best effort” 2 “bulk” Priority is based on IP Type of Service (TOS) Normal IP packet  1 “best effort”

Queue Discipline: Qdisc http://linux-ip.net/articles/Traffic-Control-HOWTO/classless-qdisc.html

Mapping IP ToS to Queue IP ToS: PPPDTRCX PPP  Precedence Linux = ignore Cisco = Policy-Based Routing (PBR) D  Minimizes Delay T  Maximizes Throughput R  Maximizes Reliability C  Minimizes Cost X  Reserved

Mapping IP ToS to Queue (cont.) Linux Priority Band 0x0 1 0x2 2 0x4 0x6 0x8 0xA 0xC 0xE 0x10 6 0x12 0x14 0x16 0x18 4 0x1A 0x1C 0x1E pfifo_fast_enqueue() maps IP ToS to one of three queues IP ToS: PPPDTRCX Mapping array: prior2band * Linux priority != band

Queue Selection sch_generic.c Mapping array Band “0” (first in Qdisc) Change band

Queue Selection (cont.) Kernel 2.6.9.EL Qdisc … sk_buff_head band 0 list = ((struct sk_buff_head*)qdiscdata sk_buff_head band 1 +prior2band[skb->priority&TC_PRIOR_MAX] sk_buff_head band 2 …

Sending Out a Packet pfifo_fast_dequeue() Removes the oldest packet from the highest priority band The packet that was just enqueued! Passes it to the device driver

Lab 9 Part 1&2 Setup Destination Bottleneck link: 10Mbps Linux Router (Your HDD) Virtual 1 Virtual 2

Lab 9 Part 2 Default: no IP forwarding Enable IP forwarding /proc/… Only one router Default route on “destination”

Lab 9 Part 2 Route??? Destination ping reply Bottleneck link: 10Mbps Linux Router (Your Linux) ping echo Virtual 1 Virtual 2

Lab 9 Part 3 Scenario Destination TCP UDP Linux Router (Your Linux) 10Mbps UDP Linux Router (Your Linux) Virtual 1 Virtual 2

Lab 9 Part 3 (cont.) Problem with TCP v.s. UDP? TCP is too “nice” Proposed solution: Modify kernel TCP  higher priority

Lab 9 Part 4 Goal: compile the modified kernel Print out TCP/UDP when sending or forwarding a packet /proc/sys/kernel/printk Start up with the new kernel! Press any key on boot  OS list Select 2.6.9

Lab 9 Part 5 Goal: change the kernel scheduling Idea: place TCP in the higher priority band pfifo_fast_enqueue() Default  IP ToS Change it to TCP v.s. UDP (+others) Options: UDP++ or TCP-- Do NOT change IP ToS!

Lab 9 Part 5 (cont.) TCP UDP

Lab 9 Part 5 (cont.)

Lab 9 Part 5 (cont.) Remember: take printk() out! boot into 2.6.9 enable forwarding What happen? Compare to Part 2?