Introduction to TCP/IP Yusuke Matsuoka / Herwin Chan EE0A Spring/003 UCLA
OSI and Protocol StackOSI: Open Systems Interconnect OSI Model TCP/IP Hierarchy Protocols 7 th Application Layer 6 th Presentation Layer 5 th Session Layer 4 th Transport Layer 3 rd Network Layer nd Link Layer st Physical Layer Application Layer Transport Layer Network Layer Link Layer Link Layer card Network Layer Routing : includes device driver and network interface : handles the movement of packets, i.e.
Packet Encapsulation 3 The data is sent down the protocol stack Each layer adds to the data by prepending headers Bytes0Bytes0Bytes 4Bytes 64 to 500 Bytes
Ethernet 4 Computer <-> Computer communication on same network Each device has unique MAC address (48-bit) example: 00-C0-4F-48-47-93 Ethernet Packet: Preamble Dest. address Source address Type Data CRC 8bytes 6bytes 6bytes bytes 64-500bytes 4bytes MAC: Media Access Contro
5 ARP : Address Resolution Protocol ARP provides mapping 3bit IP address <-> 48bit MAC address 8.97.89.53 <-> 00-C0-4F-48-47-93 ARP cache maintains the recent mappings from IP addresses to MAC addresses Protocol. ARP request broadcast on Ethernet. Destination host ARP layer responds
IP: Internet Protocol 6 Unreliable connectionless datagram delivery service Responsible for routing of data through intermediate networks and computers IP header: 03 4567 890 345 6789 03 4567 33 890 :ICMP 6 :TCP 7 :UDP
IP Routing 7 Source Application Transport Network Link Router Network Link Destination Application Transport Network Link Routing Table Destination IP address IP address of a next-hop router Flags Network interface specification
ICMP : Internet Control Message 8 Protocol Used to report problems with delivery of IP Datagrams within an IP network Used by Ping, Tracerout commands ICMP Message 0bytes 4bytes Types and Codes Echo Request (type=8, code=0) Echo Reply(type=0, code=0) IP Header Destination Unreachable(type=3, code=0) ICMP Header ICMP Data Type Code Checksum byte byte bytes Time Exceeded(type=, code=0) : Time-to-Live =0
9 TCP : Transmission Control Protocol Connection-Oriented, Reliable, Byte Stream Service Protocol. Set up connection. Transfer data 3. Close connection TCP Header Format 0 3 4 5 6 7 8 9 0 Data Offset Source Port 3 4 5 6 7 Sequence Number 8 Acknowledgement Number 9 0 3 4 5 Destination Port Window Checksum Options (0 to 0 Words of 3 Bits) TCP Payload Urgent Pointer 6 7 8 9 3 0 3
TCP : State Diagram 0
TCP : Connection Clien t Send SYN seq=x Receive SYN +ACK segment Send ACK y+ Host Receive SYN segment Send SYN seq=y, ACK x+ Receive ACK segment Clien t Send FIN seq=x Receive ACK segment Receive FIN + ACK segment Send ACK y+ Host Receive FIN segment Send ACK x+ Send FIN seq=y, ACK x+ Receive ACK segment Establishing a TCP Connection Closing a TCP Connection
TCP : Data transfer Timer Clien t Send Packet Start Timer ACK would normally Arrive at this time Packet Lost Host Packet should arrive ACK should be sent Time Expires Timer Retransmit Packet Start Timer Receive Packet Send AXK Receive ACK Cancel Timer
3 HTTP : Hyper Text Transfer Protocol Stateless Transaction Protocol Each transaction creates a new connection Steps in Transaction. Establish connection. Request Method <URL> <CR> 3. Response Response Code <Data> <CR> 4. Close connection
HTTP 4 Common Request Methods GET, PUT, POST Response Categories Informational :00 Successful :00 Redirection :300 Client Error :400 (eg. 404 Not found) Server Error :500
5 Example: Access www.ee.ucla.edu Client Appl HTTP Transp TCP Net IP Link ethernet Http request GET http://www.ee.ucla.edu <CR> Http response 00 <CR> <html file in MIME format> Initiate connection (hdshk) Package data (add TCP header) send http request packet Assemble response (break into several packets) Send http response packets send data to next hop Close connection (hdshk) Relay data ARP to provide IP/MAC translation Net IP Link ethernet Router(s) Server Appl HTTP Transp TCP Net IP Link ethernet
References 6 TCP/IP Illustrated, Volume The Protocols by W. Richard Stevens (http://yenigul.net/tcpip ) Internet Working with TCP/IP Volume by Douglas E. Comer Sams Teach Yourself TCP/IP in 4 Hours by Joe Casad. Published by Sams. (http://www. informit.com)