The Network Layer and the Transport Layer. IP, TCP and UDP

Similar documents
The Transport Layer. Part 1

The Transport Layer. Internet solutions. Nixu Oy PL 21. (Mäkelänkatu 91) Helsinki, Finland. tel fax.

The Network Layer. Internet solutions. Nixu Oy PL 21. (Mäkelänkatu 91) Helsinki, Finland. tel fax.

The Network Layer. Internet solutions. Nixu Oy PL 21. (Mäkelänkatu 91) Helsinki, Finland. tel fax.

TCP /IP Fundamentals Mr. Cantu

User Datagram Protocol

Chapter 2 - Part 1. The TCP/IP Protocol: The Language of the Internet

Vorlesung Kommunikationsnetze

Guide to Networking Essentials, 6 th Edition. Chapter 5: Network Protocols

Dongsoo S. Kim Electrical and Computer Engineering Indiana U. Purdue U. Indianapolis

EITF25 Internet Techniques and Applications L7: Internet. Stefan Höst

Layer 4: UDP, TCP, and others. based on Chapter 9 of CompTIA Network+ Exam Guide, 4th ed., Mike Meyers

ECE4110 Internetwork Programming. Introduction and Overview

IP - The Internet Protocol. Based on the slides of Dr. Jorg Liebeherr, University of Virginia

CCNA Exploration Network Fundamentals. Chapter 04 OSI Transport Layer

IP - The Internet Protocol

ICS 451: Today's plan

TCP/IP Protocol Suite

Networking Technologies and Applications

ECE 650 Systems Programming & Engineering. Spring 2018

TSIN02 - Internetworking

TCP/IP Networking. Part 4: Network and Transport Layer Protocols

UDP and TCP. Introduction. So far we have studied some data link layer protocols such as PPP which are responsible for getting data

Network Model. Why a Layered Model? All People Seem To Need Data Processing

Introduction to Internet. Ass. Prof. J.Y. Tigli University of Nice Sophia Antipolis

Lecture 11: Networks & Networking

EE 610 Part 2: Encapsulation and network utilities

Concept Questions Demonstrate your knowledge of these concepts by answering the following questions in the space that is provided.

Introduction to Internetworking

TSIN02 - Internetworking

Introduction to Networks and the Internet

RMIT University. Data Communication and Net-Centric Computing COSC 1111/2061. Lecture 2. Internetworking IPv4, IPv6

Guide To TCP/IP, Second Edition UDP Header Source Port Number (16 bits) IP HEADER Protocol Field = 17 Destination Port Number (16 bit) 15 16

Just enough TCP/IP. Protocol Overview. Connection Types in TCP/IP. Control Mechanisms. Borrowed from my ITS475/575 class the ITL

Chapter 09 Network Protocols

CSCI-1680 Network Layer: IP & Forwarding Rodrigo Fonseca

Applied Networks & Security

CSCI-1680 Network Layer: IP & Forwarding Rodrigo Fonseca

Packet Header Formats

Internet Layers. Physical Layer. Application. Application. Transport. Transport. Network. Network. Network. Network. Link. Link. Link.

Debian/GNU Linux Networking

CHAPTER-2 IP CONCEPTS

Outline. IP Address. IP Address. The Internet Protocol. o Hostname & IP Address. o The Address

Lecture 11: IP routing, IP protocols

Introduction to TCP/IP networking

IP Protocols. ALTTC/Oct

ECE 4450:427/527 - Computer Networks Spring 2017

ICS 351: Networking Protocols

TSIN02 - Internetworking

6.1 Internet Transport Layer Architecture 6.2 UDP (User Datagram Protocol) 6.3 TCP (Transmission Control Protocol) 6. Transport Layer 6-1

Inter-networking. Problem. 3&4-Internetworking.key - September 20, LAN s are great but. We want to connect them together. ...

QUIZ: Longest Matching Prefix

CC231 Introduction to Networks Dr. Ayman A. Abdel-Hamid. Internet Protocol Suite

Network Layer. The Network Layer. Contents Connection-Oriented and Connectionless Service. Recall:

Network Layer. Recall: The network layer is responsible for the routing of packets The network layer is responsible for congestion control

CSCI-1680 Network Layer: IP & Forwarding John Jannotti

CCNA 1 Chapter 7 v5.0 Exam Answers 2013

TCP/IP Networking. Training Details. About Training. About Training. What You'll Learn. Training Time : 9 Hours. Capacity : 12

Lecture 3: The Transport Layer: UDP and TCP

Introduction to Network. Topics

05 Transmission Control Protocol (TCP)

OSI Transport Layer. objectives

EC441 Fall 2018 Introduction to Computer Networking Chapter4: Network Layer Data Plane

Interconnecting Networks with TCP/IP. 2000, Cisco Systems, Inc. 8-1

TSIN02 - Internetworking

Lecture 8. Reminder: Homework 3, Programming Project 2 due on Thursday. Questions? Tuesday, September 20 CS 475 Networks - Lecture 8 1

Transport Layer. Application / Transport Interface. Transport Layer Services. Transport Layer Connections

TSIN02 - Internetworking

Chapter 12 Network Protocols

ET4254 Communications and Networking 1

CS475 Networks Lecture 8 Chapter 3 Internetworking. Ethernet or Wi-Fi).

The Internet Protocol. IP Addresses Address Resolution Protocol: IP datagram format and forwarding: IP fragmentation and reassembly

Lecture 8. Basic Internetworking (IP) Outline. Basic Internetworking (IP) Basic Internetworking (IP) Service Model

Hands-On Ethical Hacking and Network Defense

The Interconnection Structure of. The Internet. EECC694 - Shaaban

CPSC 826 Internetworking. The Network Layer: Routing & Addressing Outline. The Network Layer

Sirindhorn International Institute of Technology Thammasat University

Interconnecting Networks with TCP/IP

Chapter 4 Network Layer

II. Principles of Computer Communications Network and Transport Layer

EEC-684/584 Computer Networks

Part 4. Wide Area Networks (WAN)

CSC 634: Networks Programming

internet technologies and standards

EEC-682/782 Computer Networks I

2/22/2008. Outline Computer Networking Lecture 9 IP Protocol. Hop-by-Hop Packet Forwarding in the Internet. Internetworking.

CS 356: Computer Network Architectures. Lecture 14: Switching hardware, IP auxiliary functions, and midterm review. [PD] chapter 3.4.1, 3.2.

Internet Protocols (chapter 18)

IP: Addressing, ARP, Routing

ELEC / COMP 177 Fall Some slides from Kurose and Ross, Computer Networking, 5 th Edition

Network layer: Overview. Network layer functions IP Routing and forwarding NAT ARP IPv6 Routing

Transport Layer. <protocol, local-addr,local-port,foreign-addr,foreign-port> ϒ Client uses ephemeral ports /10 Joseph Cordina 2005

TCP/IP Protocol Suite and IP Addressing

ELEC / COMP 177 Fall Some slides from Kurose and Ross, Computer Networking, 5 th Edition

SEN366 (SEN374) (Introduction to) Computer Networks

9th Slide Set Computer Networks

Lecture 17 Overview. Last Lecture. Wide Area Networking (2) This Lecture. Internet Protocol (1) Source: chapters 2.2, 2.3,18.4, 19.1, 9.

Network layer: Overview. Network Layer Functions

Information Network Systems The network layer. Stephan Sigg

6. The Transport Layer and protocols

Transcription:

The Network Layer and the Transport Layer IP, TCP and UDP

Verkkokerros Internet-protokolla (IP) toteuttaa verkkokerroksen Tietoliikennepaketit välitetään erilaisten fyysisten kerrosten ylitse koneelta koneelle IP tarjoaa "best effort"-tyyppisen epäluotettavan välityspalvelun Ylemmät kerrokset välittävät datan oikealle sovellukselle, IP tuo sen vain koneelle Verkkokerroksen osoiteavaruus on globaali Toimiakseen verkkokerros tarvitsee: Kehystyksen linkkikerrokselta Lähiverkoissa muunnoksen IP-osoitetta vastaavaan MACosoitteeseen (ARP) Point-to-point -verkoissa tiedon linkkien takana sijaitsevista IPverkoista (reititysprotokollat) Konfiguraatiotiedot (DHCP) 2

IP IP = The Internet Protocol Defined in RFC 791 IP sends simple datagrams over network. It provides unreliable and connectionless delivery service. unreliable = no guarantees, ICMP error messages connectionless = each packet is treated as a separate case Large IP packets may be fragmented and reassembled in transmission In practice path MTU discovery is used instead Maximum Transmission Unit 3

IP Packet Format 0 16 bits 31 Vers TTL Hdr length Identification TOS Protocol Options... Source IP address Destination IP address Data Flags Total length Fragment offset Header checksum Padding Normal size for IP header is 20 bytes, plus options & padding. 4

IP Addresses IP address identifies a network interface. A host can have several interfaces. Current length is 32 bits (IPv4). Future length is 128 bits (IPv6). General syntax: 4 components separated by dots ("dotted quad") decimal numbers (0-255) for example: 193.210.18.18 Addresses have two components, the network id and the host id. 5

CIDR (Classless Inter Domain Routing) Arbitrary length host and network fields instead of A, B and C classes Commonly used to make superblocks of C classes for routing (a.k.a. supernetting) In the future may be used to split unused A classes Network mask marks the boundary For example 130.223.236.0/22 netmask is 255.255.252.0 The number after the slash (/) tells how many bits in the mask are 1, the rest are 0 Host IP address AND network mask = network's IP address RFC 1518, 1519 6

Special Addresses 0.0.0.0 is used for "any" or "no" IP address 255.255.255.255 is local broadcast address 127 followed by hostid is the loopback address E.g. 127.0.0.1 NetID followed by all zeros is the network address E.g. 222.1.16.0/24 NetID followed by all ones is network broadcast address E.g. 222.1.16.255/24 7

Special Addresses On the Internet there is an agreement that some addresses are not routed to the backbone 10.0.0.0/8 192.168.0.0/16 172.16.0.0/12 These addresses are called private networks and used for NAT (Network Address Translation) 8

Subnetting Large networks are often divided into smaller units Subnetting hides the details of internal network organization for example, 150.78.0.0/16 (2 16-2 hosts) could be subnetted to 150.78.0.0/24 (28 subnets with 2 8-2 hosts in each) Host IP address AND network mask = network IP address NetID SubnetID HostID Default netmask Subnet mask 9

IP on LAN Usually one physical segment = one IP network Each IP network has a network address and a broadcast address Problem: IP addresses only make sense to the TCP/IP protocol suite, not to the hardware interface Solution: ARP maps IP addresses to hardware addresses If a booting host doesn t know its IP address, DHCP (or RARP, BOOTP) can be used 10

IP on LAN Host interfaces must be activated Loopback interface: ifconfig lo 127.0.0.1 Ethernet interface: ifconfig eth0 194.197.118.42 broadcast \ 194.197.118.255 netmask 255.255.255.0 Other interfaces Default route route add default 194.197.118.1 11

ARP (Address Resolution Protocol) A host finds other hosts by broadcasting an ARP query for the IP address The host with correct IP address replies with its hardware address The address pair is added to receivers dynamic ARP cache Features: proxy ARP, gratuitous ARP RFC 826 12

ARP, an Example gato tsilven 15$ arp -a jalopeno.nixu.fi (194.197.118.20) at 08:00:20:74:F1:2C [ether] on eth0 fajitas.nixu.fi (194.197.118.21) at 08:00:20:18:06:14 [ether] on eth0 tapas.nixu.fi (194.197.118.24) at 08:00:09:6D:B6:44 [ether] on eth0 gato tsilven 16$ ping 194.197.118.37 PING 194.197.118.37 (194.197.118.37): 56 data bytes 64 bytes from 194.197.118.37: icmp_seq=0 ttl=64 time=3.0 ms 64 bytes from 194.197.118.37: icmp_seq=1 ttl=64 time=0.7 ms --- 194.197.118.37 ping statistics --- 2 packets transmitted, 2 packets received, 0% packet loss round-trip min/avg/max = 0.7/1.8/3.0 ms gato tsilven 17$ arp -a jalopeno.nixu.fi (194.197.118.20) at 08:00:20:74:F1:2C [ether] on eth0 sueno.nixu.fi (194.197.118.37) at 00:60:08:54:2D:D9 [ether] on eth0 fajitas.nixu.fi (194.197.118.21) at 08:00:20:18:06:14 [ether] on eth0 tapas.nixu.fi (194.197.118.24) at 08:00:09:6D:B6:44 [ether] on eth0 13

ARP, an Example bash-2.02# tcpdump -i eth0 -n -t -q\ host 194.197.118.42 tcpdump: listening on eth0 arp who-has 194.197.118.37 tell 194.197.118.42 arp reply 194.197.118.37 is-at 0:60:8:54:2d:d9 194.197.118.42 > 194.197.118.37: icmp: echo request 194.197.118.37 > 194.197.118.42: icmp: echo reply 194.197.118.42 > 194.197.118.37: icmp: echo request 194.197.118.37 > 194.197.118.42: icmp: echo reply 6 packets received by filter 0 packets dropped by kernel 14

Bootstrapping an IP Host in the LAN RARP (Reverse ARP), a host broadcasts its hardware address and receives an IP address to use as its own BOOTP (Bootstrap Protocol) is better: IP address and other information can be given Both now replaced by DHCP (Dynamic Host Configuration Protocol) 15

DHCP DHCP (Dynamic Host Configuration Protocol) extends BOOTP: automatic assignment of (permanent) IP addresses dynamic assignment for a limited time Extends vendor-specific area from 64 to 312 bytes RFC 1531 Supports distributed configuration Message forwarding or local servers Not a trivial service to configure for large installations 16

DHCP Messages are sent using UDP over IP Server in port 67, client in port 68 The DHCP server on the LAN segment is found using a broadcast First packet to 255.255.255.255 from 0.0.0.0 (client does not know its own address) Message types: DISCOVER, OFFER, REQUEST, DECLINE, ACK, NAK, RELEASE The server returns all necessary information IP address, netmask, gateway to the client DNS server s address also Address assignment for limited time or permanently The IP address can be from a pool or static 17

DHCP Event Diagram Server1 Client Server 2 DHCPDISCOVER DHCPDISCOVER DHCPOFFER DHCPREQUEST DHCPOFFER DHCPREQUEST DHCPACK DHCPRELEASE 18

Static Routing When host has an IP datagram to send, it checks the routing table for the correct destination When a host receives an IP datagram, it checks datagram s destination address if there is a match, IP layer delivers the datagram to correct protocol module else the datagram is silently discarded A (Unix) system can be configured to act as a router in addition to acting as a host routers can forward IP datagrams from one of its interfaces to another 19

Router Router is a network component, which passes traffic between networks Two or more network interfaces connected to networks or to other routers For each and every given destination address, router must be able to make routing decision Where (to what interface) I send this packet? Routing decision might also be: No such destination, cannot send This applies also to workstations and servers even though they usually have only one network interface Routing decisions are based on routing table Data structure, which contains information about possible destinations 20

Routing table Can be fixed (configured by hand to each device) Static routing Common at the edges of the network, workstations, servers Not feasible on big and redundant networks Usually very robust Can also be dynamic Configured by hand at some point of the network distributed automatically Routers exchange information using routing protocols Routing protocol events (routing updates) affect directly to routing table. This causes interesting dynamic problems Debugging can be painful 21

Routing table Internet s0 R e0 193.209.237.0/24 Common case: LAN connected to Internet using serial line Routing table is very simple, a typical case for static routing: Destination 193.209.237.0/24 * Next hop e0 s0 Comment Local LAN (Ethernet) Serial line to Internet (default route) 22

...Routing table When amount of routers and redundant links increase to non-trivial numbers, something more flexible is needed Static routing can not handle redundant links nor link faults Except on some environments (and even there unreliable) 193.209.237.0/24 Inet L2, 2Mbps R1 L1, 2 Mbps s0 s1 R3 R2 L2, 64 kbps e0 194.197.118.0/25 23

...Routing table Routing table for router R3 Destination Next hop Cost Comment 194.197.118.0/24 e0 0 Directly connected 193.209.237.0/24 s0 1 Fastest route 193.209.237.0/24 s1 10 Backup via R2 * s0 1 Fastest route via R1 * s1 10 Slower Cost added to routing table, prioritization of redundant routes How we can know which links are up? Routing protocol again! 24

...Routing table What if we can not have default route at all? Internet "backbone" Multihomed network Internet connections from many (> 1) ISPs In this case routing table will be very big And it changes practically all the time Practical example on Internet router (1999-04-15) 69000 prefixes (routes) Routes consume 16MB of memory Realistic minimum memory for router 64MB 25

Routing protocols Routers can talk to other routers and find out the network topology Which paths are available to which networks Which path should be preferred Routing protocols transport information, not IP packets Routing protocols can be divided by algorithm or by area By algorithm: No routing protocol (static routes) Link state protocols (SPF) Distance vector protocols (Bellman-Ford) By area: Routing protocols used internally by one AS, Interior Gateway Protocols Routing protocols used between ASes, Exterior Gateway Protocols 26

IPv6 A new version of the Internet Protocol exists The major advantage is longer address fields 128 bits long Some minor advantages More streamlined header structure Support for IPSec security Deployment has started Asian operators have a shortage of IPv4 addresses 3G telephone networks are designed to use IPv6 3GPP R5 defines all IPv6 network Supported by almost all new network software/hardware 27

The Transport Layer Part 1

Kuljetuskerroksen tehtävä Kuljetuskerros yhdistää sovelluksia Verkkokerros välittää viestejä koneelta toiselle Kuljetuskerros lisää tarkemman osoitteen koneen sisällä Kuljetuskerros toteutetaan eri protokollilla, jotka ovat vaihtoehtoisia TCP tarjoaa luotettavan tavuvirran palveluna sovellukselle UDP tarjoaa epäluotettavan viestinvälityksen palveluna 29

UDP UDP = User Datagram Protocol Defined in RFC-768 UDP packet syntax Source port Length Data Destination port UDP checksum Port is a 16-bit application identifier number. Checksum is calculated over both the header and the data. UDP checksum is optional. 30

UDP UDP datagram is encapsulated into an IP datagram. IP header UDP header UDP data Unreliable datagram-oriented transportation layer protocol offers little extra functionality besides port numbers simple, fast, light-weight, easy to implement Applications using UDP: DNS, Radius, NTP, SNMP 31

A UDP (DNS) Session Snoop 23 riku@mole $ dig a tapas.nixu.fi @194.197.118.20 ;; got answer: ;; QUESTIONS: ;; tapas.nixu.fi, type = A, class = IN ;; ANSWERS: tapas.nixu.fi. 3600 A 194.197.118.24 ;; AUTHORITY RECORDS: nixu.fi. 3600 NS ns2.tele.fi. nixu.fi. 3600 NS ns.nixu.fi. nixu.fi. 3600 NS ns.tele.fi. ;; ADDITIONAL RECORDS: ns2.tele.fi. 35619 A 193.210.19.190 ns.nixu.fi. 3600 A 193.209.237.29 ns.tele.fi. 555991 A 193.210.19.19 ns.tele.fi. 555991 A 193.210.18.18 ;; Total query time: 88 msec ;; FROM: mole.nixu.fi to SERVER: 194.197.118.20 ;; MSG SIZE sent: 31 rcvd: 175 24 riku@mole $ 32

DNS Query, Ethernet Header ETHER: Packet 1 arrived at 11:19:24.80 ETHER: Packet size = 73 bytes ETHER: Destination = 8:0:20:74:f1:2c, Sun ETHER: Source = 0:0:3b:80:e:93, ETHER: Ethertype = 0800 (IP) 33

DNS Query, IP Header IP: Version = 4 IP: Header length = 20 bytes IP: Type of service = 0x00 IP: xxx.... = 0 (precedence) IP:...0... = normal delay IP:... 0... = normal throughput IP:....0.. = normal reliability IP: Total length = 59 bytes IP: Identification = 35734 IP: Flags = 0x4 (do not fragment) IP: Fragment offset = 0 bytes IP: Time to live = 255 seconds/hops IP: Protocol = 17 (UDP) IP: Header checksum = 7e65 IP: Source address = 194.197.118.22, mole.nixu.fi IP: Destination address = 194.197.118.20, jalopeno.nixu.fi IP: No options 34

DNS Query, UDP Header UDP: Source port = 38325 UDP: Destination port = 53 (DNS) UDP: Length = 39 UDP: Checksum = E34A 35

DNS Query, Headers and Data 0: 0800 2074 f12c 0000 3b80 0e93 0800 4500.. t.,..;...e. 16: 003b 8b96 4000 ff11 7e65 c2c5 7616 c2c5.;..@...~e..v... 32: 7614 95b5 0035 0027 e34a 000a 0100 0001 v...5.'.j... 48: 0000 0000 0000 0574 6170 6173 046e 6978...tapas.nix 64: 7502 6669 0000 0100 0100 u.fi... From now on only relevant portions of the headers will be displayed 36

DNS Reply Headers ETHER: Packet size = 217 bytes ETHER: Destination = 0:0:3b:80:e:93, ETHER: Source = 8:0:20:74:f1:2c, Sun ETHER: Ethertype = 0800 (IP) IP: Total length = 203 bytes IP: Flags = 0x4 (do not fragmnet) IP: Protocol = 17 (UDP) IP: Header checksum = 8ed6 IP: Source address = 194.197.118.20, jalopeno.nixu.fi IP: Destination address = 194.197.118.22, mole.nixu.fi UDP: Source port = 53 UDP: Destination port = 38325 UDP: Length = 183 UDP: Checksum = AD48 37

DNS Reply Headers and Data 0: 0000 3b80 0e93 0800 2074 f12c 0800 4500..;... t.,..e. 16: 00cb 7a95 4000 ff11 8ed6 c2c5 7614 c2c5..z.@...v... 32: 7616 0035 95b5 00b7 ad48 000a 8580 0001 v..5...h... 48: 0001 0003 0004 0574 6170 6173 046e 6978...tapas.nix 64: 7502 6669 0000 0100 01c0 0c00 0100 0100 u.fi... --- some reply data deleted --- 208: 087b db00 04c1 d212 124f.{... 38

TCP TCP = Transmission Control Protocol Defined in RFC-793 Connection-oriented, reliable, byte-stream service Application data is broken into segments, which are sent as IP datagrams. Features: Checksums, timeouts and flow control Segment reassembly in correct order, discarding duplicate packets Applications using TCP: SMTP, HTTP (WWW), NNTP (News),... 39

TCP Segment Format Source port number Destination port number Sequence number Acknowledgment number Hdrlen Reserv. Flags Window size TCP checksum Urgent pointer Options (if any) Data (if any) Ports identify source and destination applications. Sequence number identifies the first byte of the segment. Acknowledge number is the next expected sequence number for incoming data. 40

TCP Segment Format Flags URG validates the urgent pointer. ACK acknowledges the synchronization. PSH marks that the data buffer should be flushed to the receiving application. Sometimes considered outdated. RST resets the connection. SYN marks the synchronization phase of connection. FIN ends connection. 41

TCP Segment Format Window Size is the number of bytes the receiver is willing to accept Urgent pointer points to the last byte of urgent data. Urgent data feature is used, for example, when a user presses the interrupt key during a telnet session. Options contain often maximum segment size at the start of connection, options can be also used to discover path MTU or to set window scale factor. 42

TCP Data Flow Receiver sends acknowledgment for each segment. If a packet gets lost, timeout will ensure it s retransmitted Client Server waiting for ack packet gets lost retransmission ACK 43

TCP Data Flow Normally a sliding window technique The window size is changeable, default size is around couple dozen kilobytes depending on the implementation. waiting for ack Client packet 1 packet 2 packet 3 ACK 1 & 2 ACK 3 Server 44

Establishing a TCP Connection The three-way handshake active open Client SYN SYN + ACK ACK Server passive open 45

Closing a TCP Connection Client Server active close FIN ACK FIN ACK passive close There may be data between the middle ACK and FIN So called half-close is utilized by some applications. Client says I am done sending data but I still want to receive 46

TCP shortcomings Window size Maximum window size 64 kb Max bandwidth = max window size / round trip time Error handling TCP assumes that lost packets are lost due to network congestion Internet is built on high-quality fixed trunk connections and LANs The solution is to make the sending window smaller than maximum size On modern wireless networks data is often lost to radio errors The correct solution would be to resend the same data again as soon as possible Instead TCP starts to send slower 47

A Snooped SMTP Session 24 riku@mole $ telnet jalopeno 25 Trying 194.197.118.20... Connected to jalopeno. Escape character is '^]'. 220-jalopeno.nixu.fi ESMTP Sendmail 8.6.12/8.6.12 ready at Sat, 5 Oct 1996 11:24:29 +0300 220 ESMTP spoken here QUIT 221 jalopeno.nixu.fi closing connection Connection closed by foreign host. 25 riku@mole $ 48

1. SYN Client->Server (Ethernet Header) ETHER: Packet 1 arrived at 10:58:0.62 ETHER: Packet size = 60 bytes ETHER: Destination = 8:0:20:74:f1:2c, Sun ETHER: Source = 0:0:3b:80:e:93, ETHER: Ethertype = 0800 (IP) 49

1. SYN Client->Server (IP Header) IP: Version = 4 IP: Header length = 20 bytes IP: Type of service = 0x00 IP: xxx.... = 0 (precedence) IP:...0... = normal delay IP:... 0... = normal throughput IP:....0.. = normal reliability IP: Total length = 44 bytes IP: Identification = 63629 IP: Flags = 0x4 (do not fragment) IP: Fragment offset = 0 bytes IP: Time to live = 255 seconds/hops IP: Protocol = 6 (TCP) IP: Header checksum = 1188 IP: Source address = 194.197.118.22, mole.nixu.fi IP: Destination address = 194.197.118.20, jalopeno.nixu.fi IP: No options 50

1. SYN Client->Server (TCP Header) TCP: Source port = 35620 TCP: Destination port = 25 (SMTP) TCP: Sequence number = 760886272 TCP: Acknowledgement number = 0 TCP: Data offset = 24 bytes TCP: Flags = 0x02 TCP:..0.... = No urgent pointer TCP:...0... = No acknowledgement TCP:... 0... = No push TCP:....0.. = No reset TCP:.....1. = Syn TCP:......0 = No Fin TCP: Window = 8760 TCP: Checksum = 0x17a1 TCP: Urgent pointer = 0 TCP: Options: (4 bytes) TCP: - Maximum segment size = 1460 bytes 51

1. SYN Client->Server (SMTP Data) SMTP: "" From now on only relevant portions of the headers will be displayed 52

2. SYN+ACK Server->Client ETHER: Destination = 0:0:3b:80:e:93, ETHER: Source = 8:0:20:74:f1:2c, Sun ETHER: Ethertype = 0800 (IP) IP: Flags = 0x4 (do not fragment) IP: Protocol = 6 (TCP) IP: Source address = 194.197.118.20, jalopeno.nixu.fi IP: Destination address = 194.197.118.22, mole.nixu.fi TCP: Source port = 25 TCP: Destination port = 35620 TCP: Sequence number = 2371738143 TCP: Acknowledgement number = 760886273 TCP: Flags = 0x12 (ACK, SYN) TCP: Options: (4 bytes) TCP: - Maximum segment size = 1460 bytes SMTP: "" 53

3. ACK Client->Server ETHER: Destination = 8:0:20:74:f1:2c, Sun ETHER: Source = 0:0:3b:80:e:93, ETHER: Ethertype = 0800 (IP) IP: Flags = 0x4 (do not fragment) IP: Protocol = 6 (TCP) IP: Source address = 194.197.118.22, mole.nixu.fi IP: Destination address = 194.197.118.20, jalopeno.nixu.fi TCP: Source port = 35620 TCP: Destination port = 25 (SMTP) TCP: Sequence number = 760886273 TCP: Acknowledgement number = 2371738144 TCP: Flags = 0x10 (ACK) TCP: No options SMTP: "" 54

4. Data Server->Client ETHER: Destination = 0:0:3b:80:e:93, ETHER: Source = 8:0:20:74:f1:2c, Sun ETHER: Ethertype = 0800 (IP) IP: Flags = 0x4 (do not fragment) IP: Protocol = 6 (TCP) IP: Source address = 194.197.118.20, jalopeno.nixu.fi IP: Destination address = 194.197.118.22, mole.nixu.fi TCP: Source port = 25 TCP: Destination port = 35620 TCP: Sequence number = 2371738144 TCP: Acknowledgement number = 760886273 TCP: Flags = 0x18 (ACK, PSH) SMTP: "220-jalopeno.nixu.fi ESMTP Sendmail 8.6.12/8.6.12 ready" 55

5. Reply Client->Server ETHER: Destination = 8:0:20:74:f1:2c, Sun ETHER: Source = 0:0:3b:80:e:93, ETHER: Ethertype = 0800 (IP) IP: Flags = 0x4 (do not fragment) IP: Protocol = 6 (TCP) IP: Source address = 194.197.118.22, mole.nixu.fi IP: Destination address = 194.197.118.20, jalopeno.nixu.fi IP: No options TCP: Source port = 35620 TCP: Destination port = 25 (SMTP) TCP: Sequence number = 760886273 TCP: Acknowledgement number = 2371738258 TCP: Flags = 0x10 (ACK) SMTP: "" 56

6. Data Client->Server ETHER: Destination = 8:0:20:74:f1:2c, Sun ETHER: Source = 0:0:3b:80:e:93, ETHER: Ethertype = 0800 (IP) IP: Flags = 0x4 (do not fragment) IP: Protocol = 6 (TCP) IP: Source address = 194.197.118.22, mole.nixu.fi IP: Destination address = 194.197.118.20, jalopeno.nixu.fi TCP: Source port = 35620 TCP: Destination port = 25 (SMTP) TCP: Sequence number = 760886273 TCP: Acknowledgement number = 2371738258 TCP: Flags = 0x18 (ACK, PSH) SMTP: "QUIT\r\n" 57

7. Ack Server->Client (Containing Data) ETHER: Destination = 0:0:3b:80:e:93, ETHER: Source = 8:0:20:74:f1:2c, Sun ETHER: Ethertype = 0800 (IP) IP: Flags = 0x4 (do not fragment) IP: Protocol = 6 (TCP) IP: Source address = 194.197.118.20, jalopeno.nixu.fi IP: Destination address = 194.197.118.22, mole.nixu.fi TCP: Source port = 25 TCP: Destination port = 35620 TCP: Sequence number = 2371738258 TCP: Acknowledgement number = 760886279 TCP: Flags = 0x18 (ACK, PSH) SMTP: "221 jalopeno.nixu.fi closing connection\r\n" 58

8. Server Starts Closing ETHER: Destination = 0:0:3b:80:e:93, ETHER: Source = 8:0:20:74:f1:2c, Sun ETHER: Ethertype = 0800 (IP) IP: Protocol = 6 (TCP) IP: Source address = 194.197.118.20, jalopeno.nixu.fi IP: Destination address = 194.197.118.22, mole.nixu.fi TCP: Source port = 25 TCP: Destination port = 35620 TCP: Sequence number = 2371738299 TCP: Acknowledgement number = 760886279 TCP: Data offset = 20 bytes TCP: Flags = 0x11 (ACK, FIN) SMTP: "" 59

9. Client Acks Previous Data ETHER: Destination = 8:0:20:74:f1:2c, Sun ETHER: Source = 0:0:3b:80:e:93, ETHER: Ethertype = 0800 (IP) IP: Protocol = 6 (TCP) IP: Source address = 194.197.118.22, mole.nixu.fi IP: Destination address = 194.197.118.20, jalopeno.nixu.fi TCP: Source port = 35620 TCP: Destination port = 25 (SMTP) TCP: Sequence number = 760886279 TCP: Acknowledgement number = 2371738300 TCP: Flags = 0x10 (ACK) SMTP: "" 60

10. Client Starts Closing as Well ETHER: Destination = 8:0:20:74:f1:2c, Sun ETHER: Source = 0:0:3b:80:e:93, ETHER: Ethertype = 0800 (IP) IP: Protocol = 6 (TCP) IP: Source address = 194.197.118.22, mole.nixu.fi IP: Destination address = 194.197.118.20, jalopeno.nixu.fi TCP: Source port = 35620 TCP: Destination port = 25 (SMTP) TCP: Sequence number = 760886279 TCP: Acknowledgement number = 2371738300 TCP: Flags = 0x11 (ACK, FIN) SMTP: "" 61

11.Server Acks Closing ETHER: Destination = 0:0:3b:80:e:93, ETHER: Source = 8:0:20:74:f1:2c, Sun ETHER: Ethertype = 0800 (IP) IP: Flags = 0x4 (do not fragment) IP: Protocol = 6 (TCP) IP: Source address = 194.197.118.20, jalopeno.nixu.fi IP: Destination address = 194.197.118.22, mole.nixu.fi TCP: Source port = 25 TCP: Destination port = 35620 TCP: Sequence number = 2371738300 TCP: Acknowledgement number = 760886280 TCP: Flags = 0x10 (ACK) SMTP: "" 62

Automatic Repeat Request

Reliable Communications with Retransmission How to transport data units over an unreliable data link in a reliable way? End to End E.g.. TCP Hop by Hop E.g..X.25, HDLC Answer: ARQ Automatic Repeat Request ARQ is an abstract concept, not a protocol itself Used in many protocols for reliable transmission There are several different versions of the basic concept 64

Basic ARQ Data (SDUs) is divided/packaged to packets (PDUs) that contain a header and checksum These are called information frames There are also empty packets called control frames And there is a timeout mechanism Sender 1. A packet is sent 3. A packet is re-sent after a timeout Packets in transit 2. A packet is lost Receiver 4. A simple acknowledgment is sent Problem: what if a frame is received and acknowledged after the timeout at sender s end? 65

ARQ Sequence Numbers It is possible for the sender and receiver to get out of synchronization A problem that all protocols must address Sender and receiver can be synchronized by having a sequence number in each frame In theory one bit sequence number would be sufficient for stop-and-wait ARQ Stop-and-wait means that only one frame is in transmission at one time One bit sequence number is not sufficient if the network may duplicate frames Stop and wait is not very efficient in most cases Larger sequence numbers allow multiple frames to be in transit 66

ARQ Control Frames ACK, acknowledgment NAK, negative acknowledgment ENQ, enquiry 67

ARQ Stop-and-Wait Frame Loss Handling One frame is sent at a time Rule: the information (data transporting) frames are ACKed, control frames not When a frame is lost: 1) Sender retransmits after timeout or 2) ENQ is replied with the last frame sent Sender sends ENQ after timeout Receiver sends last ACK sent Enables re-synchronization 68

Go-Back-N ARQ Frame Loss Handling A sufficiently large sequence number and a sliding window are used Receiver ACKs only frames in sequence When an information frame is lost, it and all frames sent after it must be retransmitted Frame loss is recognized either from timeout or the receiver sends a NAK when it receives a frame out of sequence The receiver requires a buffer the size of one frame The sender has to have a buffer that holds all frames that have been transmitted but not ACKed If the ACK control frame is lost, a later ACK can replace it This increases the efficiency of bandwidth usage compared to stop-and-wait ARQ Latency is a problem for stop-and-wait ARQ TCP implements this 69

Selective Repeat ARQ Frame Loss Handling When the receiver receives a frame out of sequence, it sends a NAK for the missing frame and that frame only is resent More complex for the receiver, requires a larger receive buffer This is more efficient for channels with large error rates than Go-Back-N ARQ 70