Monday, November 12, 2012

Notes - The Transport Service

The following are notes from Computer Networks written by Tanenbaum 5th edition.
  • Introduction to transport service and its service to application layer
Services Provided to the Upper Layers
  • provide efficient, reliable, and cost-effective data transmission to users
  • software/hardware within layer is called transport entity
    • located in the os kernel, or library package in network apps, separate user process or network interface card
    • links application or session layer to network layer
  • two types of transport service
    • both have 3 phases
      • establishment
      • data transfer
      • release
    • Addressing and flow control similar to network layer
  • difference between network and transport layer despite similarities?
    • transport code is all run on users machines
    • network runs on routers
    • users have little control over network layer
      • if packets lost or mangled, transport layer corrects for errors and asks for retransmit
      • if connection lost, transport layer sets up new link
    • makes transport service more reliable than network
  • programmers can write code that works on a variety of networks without dealing with reliability of network
  • bottom 4 layers
    • transport service provider
  • upper layers
    • transport service user
Transport Service Primitives
  • many programs require transport entities, but few require network services/entities because those are hidden
  • five primitives
    • LISTEN
      • block until process tries to connect
    • CONNECT
      • attempts to establish a connection
    • SEND
      • sends data/information
    • RECEIVE
      • blocks until data packet arrives
    • DISCONNECT
      • releases connection
  • segments
    • messages sent from transport entity to transport entity
    • TCP or UDP will use this term, older protocols may call segments TPDU(Transport Protocol Data Unit)
  • segments exchanged by transport layer are contained in 
    • packets exchanged by network layer
    • packets contained in frames exchanged by data link layer
  • when frame arrives
    • data link layer processes frame header, if match
    • passes contents up to network, if packet header match
    • pass up to transport layer
  • Client-Server
    • CONNECT call causes connection request segment sent to server
    • on arrivale transport checks to see if server blocked
    • if it is unblocks server and sends connection accepted segment back to client
    • when connection accepted arrives client unblocked
    • data can be now be sent and receive with SEND RECEIVE
  • In transport even one direction data exchange is more complicated than network layer, every data packet gets ack eventually
    • control segments also gets ack, managed by transport entities
    • transport entities don't need to worry about timer/retransmit
  • When connection no longer needed DISCONNECT primitive
    • asymmetric disconnect either can issue disconnect
    • symmetric variant each side closed separately
Berkeley Sockets
  • socket primitives used for TCP
  • Server side
    • The SOCKET primitive creates new endpoint, allocates space for it within transport entity
      • returns ordinary file descriptor, kind of like OPEN on a file
      • sockets don't have network addresses
    • BIND primitive assign sockets network address
      • remote clients can now connect
    • LISTEN primitive allocates space to queue to incoming calls for several clients to try to connect
      • not blocking call
    • ACCEPT primitive returns file descriptor for read and write
      • creates a new socket with same properties as original and returns file descriptor for it
      • server can now fork process or thread
  • Client Side
    • SOCKET primitive to be created, but BIND not necessary
    • CONNECT primitive blocks the caller and starts connection
    • both sides can now use SEND and RECEIVE
  • Connection release is symmetric
    • CLOSE connection is released
  • socket API is often used with TCP to create a reliable byte stream
  • DCCP(Datagram Congestion Controlled Protocol)
    • version of UDP with congestion control Kohler et al 2006
  • sockets probably not final word, structure for congestion control suboptimal because applied separately to each stream, and one stream per object
  • SCTP(Stream Control Transmission Protocol)
  • SST(Structured Stream Transport)
An Example of Socket Programming: An Internet File Server
Client
Server

  • Server code
    • includes standard headers
    • defines SERVER_PORT
    • any number will work between 1024 and 65535, 1023 below is reserved
    • local server code begins
      • call to memset sets data structure to 0
      • htonl and htons convert values to standard format so code runs correctly on both little endian machines and big endian machines
      • server creates sockets and checks for errors
      • setsockopt is needed to allow port to be reused so run indefinitely
      • now ip address is bound to socket, check to see if bind succeed
      • then call to listen to server's willingness to accept incoming call, and tell system ot hold up to QUEUE_SIZE
      • server enters main loop which never leaves
        • call to accept locks, if accept call succeeds 
        • returns socket descriptor that can read and write to pipes, unidirectional
        • sockets bidirectional
        • after connection established, the server reads file name
        • if name not available, block to wait for file name
        •  when file name received open file and alternately, read blocks and write them to socket until file copied, then waits for next file
  • Client Code
    • invoked, only works if server is already running
    • if call success file transfer to internet written to f after which client exits
    • starts with right number of arguments
      • socket created and initialized
      • client attempts to establish TCP connection using CONNECT
      • procedure fatal prints error and exits, since compile separately can't share code of fatal

No comments:

Post a Comment