TCP-IP

download TCP-IP

of 16

description

TCP-IP

Transcript of TCP-IP

  • 1

    Introduction to TCP/IP

    Jaimon Jacob

    Asst. Professor in CS

  • 2

    OSI and Protocol Stack OSI: Open Systems Interconnect

    OSI Model TCP/IP Hierarchy Protocols

    7th

    Application Layer

    6th

    Presentation Layer

    5th

    Session Layer

    4th

    Transport Layer

    3rd

    Network Layer

    2nd

    Link Layer

    1st

    Physical Layer

    Application Layer

    Transport Layer

    Network Layer

    Link Layer

    Link Layer : includes device driver and network interface cardNetwork Layer : handles the movement of packets, i.e. RoutingTransport Layer : provides a reliable flow of data between two hostsApplication Layer : handles the details of the particular application

  • 3

    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

  • 4

    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

    Data CRCSourceaddress

    Type

    MAC: Media Access Control

    6bytes 6bytes 2bytes

    Preamble

    8bytes 64 - 1500bytes 4bytes

  • 5

    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

    1. ARP request broadcast on Ethernet

    2. Destination host ARP layer responds

  • 6

    IP: Internet Protocol

    Unreliable connectionless datagram delivery service

    Responsible for routing of data through intermediate networks and computers

    IP header:

    1 :ICMP6 :TCP17 :UDP

    118901

    11112345

    11116789

    22220123

    22224567

    223389010123 4567

  • 7

    IP Routing

    Routing Table

    Destination IP address

    IP address of a next-hop router

    Flags

    Network interface specification

    Application

    Transport

    Network

    Link

    Application

    Transport

    Network

    Link

    Network

    Link

    Source Destination

    Router

  • 8

    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

    ICMP Data

    ICMPHeader

    IPHeader

    4bytes20bytes

    Type Code Checksum

    1byte 1byte 2bytes

  • 9

    TCP : Transmission Control Protocol

    Connection-Oriented, Reliable, Byte Stream Service

    Protocol

    1. Set up connection

    2. Transfer data

    3. Close connection

    0 1 2 3 4 5 6 7 8 9 1

    0

    1

    1

    1

    2

    1

    3

    1

    4

    1

    5

    1

    6

    1

    7

    1

    8

    1

    9

    2

    0

    2

    1

    2

    2

    2

    3

    2

    4

    2

    5

    2

    6

    2

    7

    2

    8

    2

    9

    3

    0

    3

    1

    Source Port Destination Port

    Sequence Number

    Acknowledgement Number

    Data

    Offset

    - - - - Window

    Checksum Urgent Pointer

    Options (0 to 10 Words of 32 Bits)

    TCP Payload

    TCP Header Format

  • 10

    TCP : State Diagram

  • 11

    TCP : Connection

    HostClient

    Send SYN seq=x

    Receive SYN+ACK segment

    Send ACK y+1

    Receive SYN segmentSend SYN seq=y, ACK x+1

    Receive ACK segment

    HostClient

    Send FIN seq=x

    Receive FIN + ACK segmentSend ACK y+1

    Receive FIN segmentSend ACK x+1

    Receive ACK segment

    Establishing a TCP Connection Closing a TCP Connection

    Receive ACK segment

    Send FIN seq=y, ACK x+1

  • 12

    TCP : Data transfer

    HostClient

    Send Packet 1Start Timer

    Retransmit Packet1Start Timer

    Packet should arrive ACK should be sent

    ACK would normallyArrive at this time

    Receive Packet 1Send AXK 1

    Time Expires

    Receive ACK 1Cancel Timer

    Packet LostTimer

    Timer

  • 13

    HTTP : Hyper Text Transfer Protocol

    Stateless Transaction Protocol

    Each transaction creates a new connection

    Steps in Transaction

    1. Establish connection

    2. Request

    Method

    3. Response

    Response Code

    4. Close connection

  • 14

    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

  • 15

    Example: Access www.ee.ucla.edu

    Http requestGET http://www.ee.ucla.edu

    Http response200

    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

    Appl

    HTTP

    Transp

    TCP

    NetIP

    Linkethernet

    Close connection (hdshk)

    Relay data

    Client Server

    Router(s)

    NetIP

    Linkethernet

    Appl

    HTTP

    Transp

    TCP

    NetIP

    Linkethernet

    ARP to provide IP/MAC translation

  • 16

    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)

    http://yenigul.net/tcpiphttp://www.informit.com/