Different Layers Lecture 20 10/15/2003 Jian Ren 1
The Network Layer 10/15/2003 Jian Ren 2
Network Layer Functions Transport packet from sending to receiving hosts Network layer protocols in every host, router Three important functions: Path determination: route taken by packets from source to dest. Forwarding: move packets from router s input to appropriate router output Call setup: some network architectures require router call setup along path before data flows 10/15/2003 Jian Ren 3
IP Addressing IP address: 32-bit identifier for host, router interface Interface: connection between host/router and physical link Router s typically have multiple interfaces Host may have multiple interfaces IP addresses associated with each interface 223.1.1.1 223.1.1.2 223.1.1.3 223.1.3.1 223.1.1.4 223.1.2.9 223.1.3.27 223.1.2.1 223.1.2.2 223.1.3.2 223.1.1.1 = 11011111 00000001 00000001 00000001 223 1 1 1 10/15/2003 Jian Ren 4
IP Addressing IP address: Network part (high order bits) Host part (low order bits) What s a network? (from IP address perspective) Device interfaces with same network part of IP address Can physically reach each other without intervening router 223.1.1.1 223.1.1.2 223.1.2.1 223.1.1.4 223.1.2.9 223.1.1.3 223.1.3.1 223.1.3.27 LAN 223.1.2.2 223.1.3.2 network consisting of 3 IP networks (for IP addresses starting with 223, first 24 bits are network address) 10/15/2003 Jian Ren 5
IP Addresses class-full addressing: class A 0network host B 10 network host C 110 network host 1.0.0.0 to 127.255.255.255 128.0.0.0 to 191.255.255.255 192.0.0.0 to 223.255.255.255 D 1110 multicast address 32 bits 224.0.0.0 to 239.255.255.255 10/15/2003 Jian Ren 6
ICMP: Internet Control Message Protocol Used by hosts, routers, gateways to communication network-level information Error reporting: unreachable host, network, port, protocol Echo request/reply (used by ping) Type Code description 0 0 echo reply (ping) 3 0 dest. network unreachable 3 1 dest host unreachable 3 2 dest protocol unreachable 3 3 dest port unreachable 3 6 dest network unknown 3 7 dest host unknown 4 0 source quench (congestion control - not used) 8 0 echo request (ping) 9 0 route advertisement 10 0 router discovery 11 0 TTL expired 12 0 bad IP header 10/15/2003 Jian Ren 7
DHCP: Dynamic Host Configuration Protocol Allows host to dynamically obtain its IP address from network server when it joins network Can renew its lease on address in use Allows reuse of addresses Support for mobile users who want to join network 10/15/2003 Jian Ren 8
DHCP Overview Host broadcasts DHCP discover msg DHCP server responds with DHCP offer msg Host requests IP address: DHCP request msg DHCP server sends address: DHCP ack msg 10/15/2003 Jian Ren 9
NAT: Network Address Translation Motivation: local network uses just one IP address as far as outside word is concerned One IP address is used for all devices Can change addresses of devices in local network without notifying outside world Can change ISP without changing addresses of devices in local network Devices inside local net not explicitly addressable, visible by outside world (a security plus). 10/15/2003 Jian Ren 10
NAT rest of Internet 138.76.29.7 10.0.0.4 local network (e.g., home network) 10.0.0/24 10.0.0.1 10.0.0.2 10.0.0.3 All datagrams leaving local network have same single source NAT IP address: 138.76.29.7, different source port numbers Datagrams with source or destination in this network have 10.0.0/24 address for source, destination (as usual) 10/15/2003 Jian Ren 11
The Transport Layer 10/15/2003 Jian Ren 12
Transport Services and Protocols Provide logical communication between app processes running on different hosts Transport protocols run in end systems Example protocols TCP UDP 10/15/2003 Jian Ren 13
Transport vs. network layer Network layer Logical communication between hosts Transport layer Logical communication between processes Relies on, and enhances network layer services 10/15/2003 Jian Ren 14
Transport Layer Protocols Reliable, in-order delivery: TCP Flow control Congestion control Connection setup Unreliable, unordered delivery: UDP Services not available: Delay guarantees Bandwidth guarantees 10/15/2003 Jian Ren 15
UDP: User Datagram Protocol UDP segments may be: Lost Delivered out of order to app Connectionless: No handshaking between UDP sender, receiver Each UDP segment handled independently of others Why is there a UDP? No connection establishment (which can add delay) Simple: no connection state at sender, receiver Small segment header No congestion control: UDP can blast away as fast as desired 10/15/2003 Jian Ren 16
UDP Often used for streaming multimedia apps Loss tolerant Rate sensitive Other UDP uses DNS SNMP Reliable transfer over UDP: add reliability at application layer Application-specific error recovery! 10/15/2003 Jian Ren 17
TCP: Overview Point-to-point: One sender, one receiver Reliable, in-order byte steam Full duplex data: Bi-directional data flow in same connection Connection-oriented: Handshaking (exchange of control msgs) init s sender, receiver state before data exchange Flow controlled: Sender will not overwhelm receiver socket door application writes data TCP send buffer application reads data TCP receive buffer socket door segment 10/15/2003 Jian Ren 18
TCP seq. # s and ACKs Seq. # s: Byte stream number of first byte in segment s data ACKs: Seq # of next byte expected from other side Cumulative ACK User types C host ACKs receipt of echoed C Host A Host B Seq=42, ACK=79, data = C Seq=79, ACK=43, data = C Seq=43, ACK=80 host ACKs receipt of C, echoes back C simple telnet scenario time 10/15/2003 Jian Ren 19
TCP Reliable Data Transfer TCP creates reliable data transfer service on top of IP s unreliable service TCP uses single retransmission timer Retransmissions are triggered by: Timeout events Duplicate acks 10/15/2003 Jian Ren 20
TCP Flow Control Receiver side of TCP connection has a receive buffer Flow control Sender won t overflow receiver s buffer by transmitting too much, too fast Speed-matching service Matching the send rate to the receiving app s drain rate 10/15/2003 Jian Ren 21
TCP Fairness Goal: if K TCP sessions share same bottleneck link of bandwidth R, each should have average rate of R/K TCP connection 1 TCP connection 2 bottleneck router capacity R 10/15/2003 Jian Ren 22