Linux Networking Overview COMS W 6998 5 Spring

  • Slides: 17
Download presentation
Linux Networking Overview COMS W 6998 -5 Spring 2010

Linux Networking Overview COMS W 6998 -5 Spring 2010

Outline l l l Layering in Networks ISO Network Model IP Network Model Linux

Outline l l l Layering in Networks ISO Network Model IP Network Model Linux Kernel Outline Network Subsystem Outline

Layer-Based Communication Models End systems Application Instance (N+1) Intermediate system (N+1)-Protocols End systems Application

Layer-Based Communication Models End systems Application Instance (N+1) Intermediate system (N+1)-Protocols End systems Application Instance (N+1) (N)-protocol Instance (N) Layer (N+1) Layer (N) (N-1)-protocol Instance (N-1) Transmission medium Layer (N-1)

Concepts in Layered Model l Protocols l l l Rules that two parties talk

Concepts in Layered Model l Protocols l l l Rules that two parties talk and understand each other Horizontal interface Services l l l Functions provided by a lower layer to the neighboring upper layer Vertical interface Service interface (function calls)

ISO/OSI Reference Model ISO/OSI Reference model Application Presentation Session Transport l l Network l

ISO/OSI Reference Model ISO/OSI Reference model Application Presentation Session Transport l l Network l Data link l Physical l Application: Protocols for different applications, HTTP, SMTP, FTP, etc Presentation layer: Regulating data presentation (formatting, ASN/1) Session : Handling structured message exchange, multiplexing sessions Transport: End-to-end functions between applications. Flow control, packet ordering, etc. Network: Connecting networks. Packet routing/forwarding Data link layer: Moving data between two directly connected stations. Flow control, error detection, etc. Shared medium: access control. LLC/MAC Physical: Media types, coding methods, bit sequences vs. physical signals

ISO vs. The Internet ISO/OSI reference model 7 6 5 4 3 2 1

ISO vs. The Internet ISO/OSI reference model 7 6 5 4 3 2 1 Internet reference model Application Presentation Application (HTTP, SMTP, SSH) Session Transport (TCP/UDP) Network Internet (IPv 4/v 6) Data link Physical Data link (802. x, PPP, SLIP)

Design Principles l Optimize for the common case l l Never touch/copy data l

Design Principles l Optimize for the common case l l Never touch/copy data l l E. g. , TCP header prediction E. g. , checksum offload Mistakes can be made at each layer l Use common facilities at each layer l l Buffer management, hash tables, timers Use best-of-breed practices in these facilities

Kernel Structure vim apache sshd User Shared C Library Kernel System Call Interface Process

Kernel Structure vim apache sshd User Shared C Library Kernel System Call Interface Process Mgmt Memory Mgmt Device Control File System Network Subsys CPU Support Code MMU Support Code Character device drivers Block device drivers Network device drivers Block Devices Network Devices CPU RAM Character Devices Hardware

Kernel Structure l Process management l l Memory management l l Creating, destroying, putting

Kernel Structure l Process management l l Memory management l l Creating, destroying, putting to sleep, waking up, and scheduling processes. Allocates memory to processes; maps virtual memory to physical memory; enforces protection File system l l l In UNIX, almost everything is handled over the file system interface. Device drivers can be addressed as files /proc file system allows us to access data and parameters in the kernel

Kernel Structure (2) l Device drivers l l l Abstract away the underlying hardware

Kernel Structure (2) l Device drivers l l l Abstract away the underlying hardware and allow us to access the hardware with well-defined APIs The use of kernel modules allow device drivers to be dynamically loaded/unloaded Networking l l l Provides communication between end hosts Incoming packets are asynchronous events and have to be collected and identified, before a process can handle them. Many network operations occur asynchronously and cannot be associated to a specific process. Instead, interrupts and timers are used extensively.

Kernel Structure vim apache COMS W 6998 sshd Shared C Library Kernel System Call

Kernel Structure vim apache COMS W 6998 sshd Shared C Library Kernel System Call Interface Process Mgmt Memory Mgmt Device Control File System Network Subsys CPU Support Code MMU Support Code Character device drivers Block device drivers Network device drivers Block Devices Network Devices CPU RAM Character Devices User Hardware

Network Subsystem Application Synch & Atomic Ops Interrupts U/K copy ip_proto System Call Interface

Network Subsystem Application Synch & Atomic Ops Interrupts U/K copy ip_proto System Call Interface sock Sockets VFS Mem Alloc socket sk_buff Soft IRQs Hash Tables net_device Wait Queues Lists Notifiers Timers User PCI DMA UDP TCP IPV 4 IPV 6 SCTP ARP ICMP bridging Kernel data link layer E 1000 driver Intel E 1000 Hardware

Network-specific facilities l sk_buff: l l net_device: l l Core data structure that represents

Network-specific facilities l sk_buff: l l net_device: l l Core data structure that represents a network interface (e. g. , an Intel E 1000 Ethernet NIC). proto_ops: l l Core networking data structure for managing data (i. e. , packets) Data structure for different IP protocol families l SOCK_STREAM, SOCK_DGRAM, SOCK_RAW l Virtual functions for bind(), accept(), connect(), etc. struct sock/ struct socket: l Core data structures for representing sockets

Kernel facilities (1) l Timers l l Hash tables l l Library for safely

Kernel facilities (1) l Timers l l Hash tables l l Library for safely transferring data across the user/kernel boundary Memory allocation l l Facility for creating associations (e. g. , 4 -tuple TCP connection block), looking them up, deleting them User/kernel copying l l Facility for scheduling work in the future (e. g. , retransmitting a lost TCP segment) Mechanism for the network subsystem to obtain memory (e. g. , pinned pages for arriving packets to land in) Linked lists l What you think

Kernel facilities (2) l Atomic operations and synchronization l l Interrupts l l “Software

Kernel facilities (2) l Atomic operations and synchronization l l Interrupts l l “Software interrupts” that are asynchronously executed in response to a hardware interrupt Wait Queues l l Hardware interface for notifying OS of an event (e. g. , a packet arrival) Soft IRQs l l Mechanisms for managing concurrency correctly Mechanism for processes/threads/tasks to wait for an event, put themselves to sleep, or wake another process up Notifiers l Publish/subscribe system for notifying other systems about an event (e. g. , interface goes down)

That’s the big picture… l l Later lectures will delve into the details Not

That’s the big picture… l l Later lectures will delve into the details Not enough time to cover everything Suggestions about what to cover welcome Or how to cover it l l Bottom-up or top-down? Use your project to cover something interesting and/or important to you

For next week l l Install a distribution inside a VM Download/build/install the appropriate

For next week l l Install a distribution inside a VM Download/build/install the appropriate 2. 6. 31 kernel source in the VM l l Enable kgdb, kprobes, oprofile, magic sysreq, debugfs If this is difficult for you, you probably are in the wrong class. .