1 / 19

EEC-484/584 Computer Networks

This lecture covers the basics of UDP and TCP protocols in computer networks. Topics include segment header structure, connection management, and the differences between UDP and TCP. The lecture also discusses the uses of UDP and provides examples of checksum calculations.

dosse
Download Presentation

EEC-484/584 Computer Networks

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. EEC-484/584Computer Networks Lecture 15 Wenbing Zhao wenbing@ieee.org (Part of the slides are based on Drs. Kurose & Ross’s slides for their Computer Networking book, and on materials supplied by Dr. Louise Moser at UCSB and Prentice-Hall)

  2. Outline • UDP • TCP • Segment header structure • Connection management EEC-484/584: Computer Networks

  3. “No frills,” “bare bones” Internet transport protocol “Best effort” service, UDP segments may be: Lost Delivered out of order to app Connectionless: No handshaking between UDP sender, receiver Each UDP segment handled independently of others UDP: User Datagram Protocol EEC-484/584: Computer Networks

  4. Why is There a UDP? • No connection establishment (which can add delay) • Simple: no connection state at sender receiver • Small segment header • No congestion control: UDP can blast away as fast as desired EEC-484/584: Computer Networks

  5. Often used for streaming multimedia apps Loss tolerant Rate sensitive Other UDP uses DNS SNMP Reliable transfer over UDP: add reliability at application layer UDP 32 bits source port # dest port # Length, in bytes of UDP segment, including header checksum length Application data (message) UDP segment format EEC-484/584: Computer Networks

  6. Sender: treat segment contents as sequence of 16-bit integers checksum: addition (1’s complement sum) of segment contents sender puts checksum value into UDP checksum field Receiver: compute checksum of received segment check if computed checksum equals checksum field value: NO - error detected YES - no error detected. But maybe errors nonetheless? UDP Checksum Goal: detect “errors” (e.g., flipped bits) in transmitted segment EEC-484/584: Computer Networks

  7. Internet Checksum Example • When adding numbers, a carryout from the most significant bit needs to be added to the result • Example: add two 16-bit integers 1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1 wraparound sum checksum To know more: http://www.netfor2.com/udpsum.htm http://www.netfor2.com/checksum.html EEC-484/584: Computer Networks

  8. Full duplex data: Bi-directional data flow in same connection MSS: maximum segment size Connection-oriented: Handshaking (exchange of control msgs) init’s sender, receiver state before data exchange Flow controlled: Sender will not overwhelm receiver Point-to-point: One sender, one receiver Reliable, in-order byte steam: No “message boundaries” Pipelined: TCP congestion and flow control set window size Send & receive buffers TCP: Overview EEC-484/584: Computer Networks

  9. TCP: Overview • TCP connection is byte stream, not message stream, no message boundaries • TCP may send immediately or buffer before sending • Receiver stores the received bytes in a buffer EEC-484/584: Computer Networks

  10. 32 bits source port # dest port # sequence number acknowledgement number head len not used Receive window U A P R S F checksum Urg data pnter Options (variable length) application data (variable length) TCP Segment Structure URG: urgent data (generally not used) counting by bytes of data (not segments!) ACK: ACK # valid PSH: push data now (generally not used) # bytes rcvr willing to accept RST, SYN, FIN: connection estab (setup, teardown commands) A TCP segment must fit into an IP datagram! Internet checksum (as in UDP) EEC-484/584: Computer Networks

  11. The TCP Segment Header • Source port and destination port: identify local end points of the connection • Source and destination end points together identify the connection • Sequence number: identify the byte in the stream of data that the first byte of data in this segment represents • Acknowledgement number: the next sequence number that the sender of the ack expects to receive • Ack # = Last received seq num + 1 • Ack is accumulative: an ack of 5 means 0-4 bytes have been received • TCP header length– number of 32-bit words in header EEC-484/584: Computer Networks

  12. The TCP Segment Header • URG– indicates urgent pointer field is set • Urgent pointer– points to the seq num of the last byte in a sequence of urgent data • ACK– acknowledgement number is valid • SYN– used to establish a connection • Connection request: ACK = 0, SYN = 1 • Connection confirm: ACK=1, SYN = 1 • FIN– release a connection, sender has no more data • RST– reset a connection that is confused • PSH– sender asked to send data immediately EEC-484/584: Computer Networks

  13. The TCP Segment Header • Receiver window size–number of bytes that may be sent beyond the byte acked • Checksum–add the header, the data, and the conceptual pseudoheader as 16-bit words, take 1’s complement of sum • For more info: http://www.netfor2.com/tcpsum.htmhttp://www.netfor2.com/checksum.html • Options– provides a way to add extra facilities not covered by the regular header • E.g., communicate buffer sizes during set up EEC-484/584: Computer Networks

  14. Sequence numbers: byte stream “number” of first byte in segment’s data ACKs: seq # of next byte expected from other side cumulative ACK time TCP Sequence Numbers and ACKs Host B Host A User types ‘C’ Seq=42, ACK=79, data = ‘C’ host ACKs receipt of ‘C’, echoes back ‘C’ Seq=79, ACK=43, data = ‘C’ host ACKs receipt of echoed ‘C’ Seq=43, ACK=80 simple telnet scenario EEC-484/584: Computer Networks

  15. TCP Connection Management TCP sender, receiver establish “connection” before exchanging data segments • Initialize TCP variables: • Sequence numbers • Buffers, flow control info (e.g. RcvWindow) • Client: connection initiator Socket clientSocket = new Socket("hostname","port number"); • Server: contacted by client Socket connectionSocket = welcomeSocket.accept(); EEC-484/584: Computer Networks

  16. TCP Connection Management Three way handshake: Step 1:client host sends TCP SYN segment to server • specifies initial sequence number • no data Step 2:server host receives SYN, replies with SYN/ACK segment • server allocates buffers • specifies server initial sequence number Step 3: client receives SYN/ACK, replies with ACK segment, which may contain data EEC-484/584: Computer Networks

  17. TCP Connection Management client server Three way handshake: • SYN segment is considered as 1 byte • SYN/ACK segment is also considered as 1 byte accept connect SYN (seq=x) SYN/ACK (seq=y, ACK=x+1) ACK (seq=x+1, ACK=y+1) EEC-484/584: Computer Networks

  18. Closing a connection: client closes socket:clientSocket.close(); Step 1:client end system sends TCP FIN control segment to server Step 2:server receives FIN, replies with ACK. Closes connection, sends FIN. TCP Connection Management client server close FIN ACK close FIN ACK timed wait closed EEC-484/584: Computer Networks

  19. Step 3:client receives FIN, replies with ACK. Enters “timed wait” - will respond with ACK to received FINs Step 4:server, receives ACK. Connection closed. Note:with small modification, can handle simultaneous FINs TCP Connection Management client server closing FIN ACK closing FIN ACK timed wait closed closed EEC-484/584: Computer Networks

More Related