Networking Overview

Download Report

Transcript Networking Overview

Linux Networking
Overview
COMS W6998-5
Spring 2010
Outline





Layering in Networks
ISO Network Model
IP Network Model
Linux Kernel Outline
Network Subsystem Outline
Layer-Based Communication
Models
End systems
Application
Application
Instance
(N+1)
Instance
(N+1)
Intermediate system
(N+1)-Protocols
End systems
Application
Application
Instance
(N+1)
Instance
(N+1)
(N)-protocol
Instance (N)
Instance (N)
Layer (N+1)
Layer (N)
(N-1)-protocol
Instance (N-1)
Instance (N-1)
Transmission medium
Transmission medium
Layer (N-1)
Concepts in Layered Model

Protocols



Rules that two parties talk and understand each other
Horizontal interface
Services



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
Network

Data link

Physical

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
Internet reference model
7
Application
6
Presentation
Application
(HTTP, SMTP, SSH)
5
Session
4
Transport
Transport (TCP/UDP)
Network
Internet (IPv4/v6)
3
2
Data link
1
Physical
Data link
(802.x, PPP, SLIP)
Design Principles

Optimize for the common case


Never touch/copy data


E.g., TCP header prediction
E.g., checksum offload
Mistakes can be made at each layer

Use common facilities at each layer


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
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

Process management


Memory management


Creating, destroying, putting to sleep, waking up, and
scheduling processes.
Allocates memory to processes; maps virtual memory
to physical memory; enforces protection
File system



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)

Device drivers



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



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
W6998
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
Network Subsystem
Application
Synch
&
Atomic
Ops
Interrupts
U/K
copy
ip_proto
socket
sk_buff
Soft
IRQs
Hash
Tables
net_device
Wait
Queues
Lists
Notifiers
Timers
System Call Interface
sock
VFS
Mem
Alloc
User
PCI
Sockets
UDP
TCP
IPV4
IPV6
SCTP
ARP
ICMP
bridging
Kernel
data link layer
E1000
driver
E1000
driver
Intel E1000
Intel E1000
DMA
Hardware
Network-specific facilities

sk_buff:


net_device:


Core data structure that represents a network interface
(e.g., an Intel E1000 Ethernet NIC).
proto_ops:


Core networking data structure for managing data (i.e.,
packets)
Data structure for different IP protocol families
 SOCK_STREAM, SOCK_DGRAM, SOCK_RAW
 Virtual functions for bind(), accept(), connect(), etc.
struct sock/ struct socket:

Core data structures for representing sockets
Kernel facilities (1)

Timers


Hash tables


Library for safely transferring data across the user/kernel
boundary
Memory allocation


Facility for creating associations (e.g., 4-tuple  TCP
connection block), looking them up, deleting them
User/kernel copying


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

What you think
Kernel facilities (2)

Atomic operations and synchronization


Interrupts


“Software interrupts” that are asynchronously executed in
response to a hardware interrupt
Wait Queues


Hardware interface for notifying OS of an event (e.g., a packet
arrival)
Soft IRQs


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

Publish/subscribe system for notifying other systems about an event
(e.g., interface goes down)
That’s the big picture…




Later lectures will delve into the details
Not enough time to cover everything
Suggestions about what to cover welcome
Or how to cover it


Bottom-up or top-down?
Use your project to cover something
interesting and/or important to you
For next week


Install a distribution inside a VM
Download/build/install the appropriate 2.6.31
kernel source in the VM


Enable kgdb, kprobes, oprofile, magic sysreq,
debugfs
If this is difficult for you, you probably are in
the wrong class..