160 likes | 350 Views
Introduction to TCP/IP. Yusuke Matsuoka / Herwin Chan EE201A Spring/2003 UCLA. OSI Model. TCP/IP Hierarchy. Protocols. 7 th Application Layer. 6 th Presentation Layer. Application Layer. 5 th Session Layer. 4 th Transport Layer. Transport Layer. Network Layer. 3 rd Network Layer.
E N D
Introduction to TCP/IP Yusuke Matsuoka / Herwin Chan EE201A Spring/2003 UCLA
OSI Model TCP/IP Hierarchy Protocols 7th Application Layer 6th Presentation Layer Application Layer 5th Session Layer 4th Transport Layer Transport Layer Network Layer 3rd Network Layer 2nd Link Layer Link Layer 1st Physical Layer OSI and Protocol Stack OSI: Open Systems Interconnect 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 64 to 1500 Bytes
Ethernet • Computer <-> Computer communication on same network • Each device has unique MAC address (48-bit) example: 00-C0-4F-48-47-93 Ethernet Packet: Dest. address Source address Type Preamble Data CRC 8bytes 6bytes 6bytes 2bytes 64 - 1500bytes 4bytes MAC: Media Access Control
ARP : Address Resolution Protocol • ARP provides mapping 32bit IP address <-> 48bit MAC address 128.97.89.153 <-> 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 • Unreliable … connectionless datagram delivery service • Responsible for routing of data through intermediate networks and computers 0123 4567 1111 2345 1111 6789 2222 0123 2222 4567 2233 8901 11 8901 IP header: 1 :ICMP 6 :TCP 17 :UDP
IP Routing Source • Routing Table Destination IP address IP address of a next-hop router Flags Network interface specification Destination Application Application Transport Router Transport Network Network Network Link Link Link
ICMP : Internet Control Message Protocol • Used to report problems with delivery of IP Datagrams within an IP network • Used by Ping, Tracerout commands Types and Codes • Echo Request (type=8, code=0) • Echo Reply(type=0, code=0) • Destination Unreachable(type=3, code=0) • Time Exceeded(type=11, code=0) : Time-to-Live =0 ICMP Message 20bytes 4bytes IP Header ICMP Header ICMP Data Type Code Checksum 1byte 1byte 2bytes
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Source Port Destination Port Sequence Number Acknowledgement Number DataOffset - - - - Window Checksum Urgent Pointer Options (0 to 10 Words of 32 Bits) TCP Payload TCP : Transmission Control Protocol • Connection-Oriented, Reliable, Byte Stream Service Protocol • Set up connection • Transfer data • Close connection TCP Header Format
TCP : Connection Client Host Client Host Send SYN seq=x Send FIN seq=x Receive FIN segment Send ACK x+1 Receive SYN segment Send SYN seq=y, ACK x+1 Receive ACK segment Receive SYN +ACK segment Send FIN seq=y, ACK x+1 Receive FIN + ACK segment Send ACK y+1 Send ACK y+1 Receive ACK segment Receive ACK segment Establishing a TCP Connection Closing a TCP Connection
TCP : Data transfer Client Host Send Packet 1 Start Timer Packet Lost Packet should arrive ACK should be sent Timer ACK would normally Arrive at this time Time Expires Retransmit Packet1 Start Timer Receive Packet 1 Send AXK 1 Timer Receive ACK 1 Cancel Timer
HTTP : Hyper Text Transfer Protocol • Stateless Transaction Protocol Each transaction creates a new connection Steps in Transaction • Establish connection • Request Method <URL> <CR> • Response Response Code <Data> <CR> • Close connection
HTTP • Common Request Methods GET, PUT, POST • Response Categories Informational :100 Successful :200 Redirection :300 Client Error :400 (eg. 404 Not found) Server Error :500
Example: Access www.ee.ucla.edu Server Client Http request GET “http://www.ee.ucla.edu”<CR> • Appl • HTTP • Appl • HTTP Http response 200 “” <CR> <html file in MIME format> • Transp • TCP • Transp • TCP Initiate connection (hdshk) Package data (add TCP header) send http request packet Assemble response (break into several packets) Send http response packets Close connection (hdshk) send data to next hop • Net • IP • Net • IP • Net • IP Relay data ARP to provide IP/MAC translation Link ethernet Link ethernet Link ethernet Router(s)
References • “TCP/IP Illustrated, Volume 1 The Protocols “ by W. Richard Stevens (http://yenigul.net/tcpip) • “Internet Working with TCP/IP Volume 1” by Douglas E. Comer • “Sams Teach Yourself TCP/IP in 24 Hours” by Joe Casad. Published by Sams. (http://www.informit.com)