You are on page 1of 34

Introduction to TCP/IP

TCP/IP protocol family


IP : Internet Protocol
UDP : User Datagram Protocol

TCP : Transmission Control Protocol


HTTP, FTP

ISO/OSI Network Model (Dont need to know this)


Seven network layers
Layer 1 : Physical cables Layer 2 : Data Link ethernet Layer 3 : Network IP Layer 4 : Transport TCP/UDP Layer 5 : Session Layer 6 : Presentation Layer 7 : Application
3 You dont need to know the layers just the idea that it is layered

TCP/IP Network Model


Different view 4 layers
Layer 1 : Link (we did not look at details) Layer 2 : Network Layer 3 : Transport Layer 4 : Application

OSI: Open Systems Interconnect

OSI Model

7th Application Layer

OSI and Protocol Stack


TCP/IP Hierarchy Protocols
Application Layer

6th Presentation Layer

5th Session Layer 4th Transport Layer


3rd Network Layer 2nd Link Layer 1st Physical Layer Link Layer Transport Layer Network Layer

Link Layer : includes device driver and network interface card Network Layer : handles the movement of packets, i.e. Routing Transport Layer : provides a reliable flow of data between two hosts Application Layer : handles the details of the particular application

Packet Encapsulation
The data is sent down the protocol stack Each layer adds to the data by prepending headers

22Bytes 20Bytes 20Bytes

4Bytes 6

64 to 1500 Bytes

IP
Responsible for end to end transmission Sends data in individual packets Maximum size of packet is determined by the networks
Fragmented if too large

Unreliable
Packets might be lost, corrupted, duplicated, delivered out of order
7

IP addresses
4 bytes
e.g. 163.1.125.98 Each device normally gets one (or more) In theory there are about 4 billion available

But

Routing
How does a device know where to send a packet?
All devices need to know what IP addresses are on directly attached networks If the destination is on a local network, send it directly there

Routing (cont)
If the destination address isnt local
Most non-router devices just send everything to a single local router Routers need to know which network corresponds to each possible IP address

10

IP Datagram
0 Vers TTL 4 Len Identification Protocol 8 TOS Flags 16 19 24 Total Length Fragment Offset Header Checksum 31 Source Internet Address Destination Internet Address Options... Data... Field Vers Len TOS T. Length Ident. Flags Frag Off Purpose IP version number Length of IP header (4 octet units) Type of Service Length of entire datagram (octets) IP datagram ID (for frag/reassembly) Dont/More fragments Fragment Offset Field TTL Protocol Purpose Time To Live - Max # of hops Higher level protocol (1=ICMP, 6=TCP, 17=UDP) Checksum Checksum for the IP header Source IA Originators Internet Address Dest. IA Final Destination Internet Address Options Source route, time stamp, etc. Data... Higher level protocol data Padding

11 We only looked at the IP addresses, TTL and protocol #

Source
Application

IP Routing
Router
Network Link

Destination
Application Transport Network Link

Transport
Network Link

Routing Table Destination IP address IP address of a next-hop router Flags Network interface specification

12

UDP
Thin layer on top of IP Adds packet length + checksum
Guard against corrupted packets

Also source and destination ports


Ports are used to associate a packet with a specific application at each end

Still unreliable:
Duplication, loss, out-of-orderness possible
13

UDP datagram
0 Source Port Length Application data 16 Destination Port Checksum 31

Field Source Port Destination Port Length Checksum

Purpose 16-bit port number identifying originating application 16-bit port number identifying destination application Length of UDP datagram (UDP header + data) Checksum of IP pseudo header, UDP header, and data

14

TCP
Reliable, full-duplex, connectionoriented, stream delivery
Interface presented to the application doesnt require data in individual packets Data is guaranteed to arrive, and in the correct order without duplications
Or the connection will be dropped

Imposes significant overheads


15

Applications of TCP
Most things!
HTTP, FTP,

Saves the application a lot of work, so used unless theres a good reason not to

16

TCP implementation
Connections are established using a three-way handshake Data is divided up into packets by the operating system Packets are numbered, and received packets are acknowledged Connections are explicitly closed
(or may abnormally terminate)
17

TCP Packets
Source + destination ports Sequence number (used to order packets) Acknowledgement number (used to verify packets are received)

18

TCP Segment
10 16 19 24 Source Port Destination Port Sequence Number Acknowledgment Number Flags Options... Data... Window Urgent Pointer Padding

31

Len

Reserved Checksum

Field Source Port Destination Port Sequence Number Acknowledgment # Len Flags Window Checksum Urgent Pointer Options

Purpose Identifies originating application Identifies destination application Sequence number of first octet in the segment Sequence number of the next expected octet (if ACK flag set) Length of TCP header in 4 octet units TCP flags: SYN, FIN, RST, PSH, ACK, URG Number of octets from ACK that sender will accept Checksum of IP pseudo-header + TCP header + data Pointer to end of urgent data Special TCP options such as MSS and Window Scale

You just need to know port numbers, seq and ack are added

19

TCP : Data transfer


Client

Host

Timer

Send Packet 1 Start Timer ACK would normally Arrive at this time Time Expires

Packet Lost

Packet should arrive ACK should be sent

Timer

Retransmit Packet1 Start Timer Receive ACK 1 Cancel Timer

Receive Packet 1 Send AXK 1

20

IPv6
128 bit addresses
Make it feasible to be very wasteful with address allocations

Lots of other new features


Built-in autoconfiguration, security options,

Not really in production use yet


21

Internet Protocol Version 6 (IPv6) is the latest revision of the Internet Protocol (IP), the communications protocol that routes traffic across the Internet. It is intended to replace IPv4, which still carries the vast majority of Internet traffic as of 2013. IPv6 was developed by the Internet Engineering Task Force (IETF) to deal with the long-anticipated problem of IPv4 address exhaustion.
22

IPv6 uses a 128-bit address, allowing for 2128, or approximately 3.41038 addresses, or more than 7.91028 times as many as IPv4. IPv6 addresses consist of eight groups of four hexadecimal digits separated by colons, for example 2001:0db8:85a3:0042:1000:8a2e:0370:7334 .
23

the IPv4-mapped IPv6 addresses. In these addresses, the first 80 bits are zero, the next 16 bits are one, and the remaining 32 bits are the IPv4 address. One may see these addresses with the first 96 bits written in the standard IPv6 format, and the remaining 32 bits written in the customary dot-decimal notation of IPv4. For example, ::ffff:192.0.2.128 represents the IPv4 address 192.0.2.128. A deprecated format for IPv4-compatible IPv6 addresses was ::192.0.2.128

24

HTTP Basics
Protocol for client/server communication
The heart of the Web Very simple request/response protocol
Client sends request message, server replies with response message

Relies on URI naming mechanism Version 1.1 developed to enhance performance, caching, compressio

25

HTTP Request Messages


GET retrieve document specified by URL PUT store specified document under given URL POST give information (eg. annotation) to the server DELETE remove document specified by URL

26

HTTP Request Format


request-line ( request request-URI HTTP-version) headers (0 or more) <blank line> body (only for POST request)

First type of HTTP message: requests


Client browsers construct and send message

Typical HTTP request:


GET http://www.cs.wisc.edu/index.html HTTP/1.0
27

HTTP Response Format


status-line (HTTP-version response-code response-phrase) headers (0 or more) <blank line> body

Second type of HTTP message: response


Web servers construct and send response messages

Typical HTTP response:


HTTP/1.0 301 Moved Permanently Location: http://www.wisc.edu/cs/index.html
28

HTTP Response Codes


1xx Informational request received, processing 2xx Success action received, understood, accepted 3xx Redirection further action necessary 4xx Client Error bad syntax or cannot be fulfilled 5xx Server Error server failed
29

HTTP Headers
Both requests and responses can contain a variable number of header fields
Consists of field name, colon, space, field value 17 possible header types divided into three categories
Request Response Body

30

HTTP/1.0 Network Interaction


Clients make requests to port 80 on servers
Uses DNS to resolve server name

Clients make separate TCP connection for each URL


Some browsers open multiple TCP connections
Netscape default = 4

Server returns HTML page


Many types of servers with a variety of implementations Apache is the most widely used
Freely available in source form

31

HTTP/1.0 is a stop and wait protocol


Separate TCP connection for each file

HTTP/1.1 Performance Enhancements

Connect setup and tear down is incurred for each file Inefficient use of packets Server must maintain many connections in TIME_WAIT

Resulted in HTTP/1.1 specification focused on performance enhancements


Persistent connections Enhanced caching options Support for compression
32

Client request GET /index.html HTTP/1.1 Host: www.example.com. Server response


HTTP/1.1 200 OK Date: Mon, 23 May 2005 22:38:34 GMT Server: Apache/1.3.3.7 (Unix) (Red-Hat/Linux) Last-Modified: Wed, 08 Jan 2003 23:11:55 GMT Etag: "3f80f-1b6-3e1cb03b Accept-Ranges: none Content-Length: 438 Connection: close Content-Type: text/html; charset=UTF-8
33

The ETag (entity tag) header is used to determine if a cached version of the requested resource is identical to the current version of the resource on the server. Content-Type specifies the Internet media type of the data conveyed by the HTTP message, while Content-Length indicates its length in bytes. The HTTP/1.1 webserver publishes its ability to respond to requests for certain byte ranges of the document by setting the header AcceptRanges: bytes. This is useful, if the client needs to have only certain portions of a resource sent by the server. When Connection: close is sent in a header, it means that the web server will close the TCPconnection immediately after the transfer of this response.
UTF-8 (UCS Transformation Format8-bit) is a variable-width encoding that can represent every character in the Unicode character set.UTF-8 uses one byte for any ASCII characters.

34

You might also like