1 / 69

UDP dan TCP

UDP dan TCP. Risanuri Hidayat. Nomor Protokol di dalam IP. End-to-End Protocols. Underlying best-effort network drop messages re-orders messages delivers duplicate copies of a given message limits messages to some finite size delivers messages after an arbitrarily long delay

nickel
Download Presentation

UDP dan TCP

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. UDP dan TCP Risanuri Hidayat TCP

  2. Nomor Protokol di dalam IP TCP

  3. End-to-End Protocols • Underlying best-effort network • drop messages • re-orders messages • delivers duplicate copies of a given message • limits messages to some finite size • delivers messages after an arbitrarily long delay • Common end-to-end services • guarantee message delivery • deliver messages in the same order they are sent • deliver at most one copy of each message • support arbitrarily large messages • support synchronization • allow the receiver to flow control the sender • support multiple application processes on each host TCP

  4. UDP • UDP = User Datagram Protocol, minimalistic transport protocol • Connection less, best effort (same best-effort service model as IP) • messages of up to 64KB • Tidak memerlukan setting connection • Header sangat sederhana/simple dibanding TCP • Source dan Destination port sama dengan TCP punya • Datagram/paket/servis yang bisa bebas (unreliable) dan tidak urut(unordered) • Tidak ada flow control, dan does not provide congestion control • Endpoints identified by ports • servers have well-known ports • see /etc/services on Unix • Optional checksum • psuedo header + UDP header + data • advantage over TCP: does not increase endto-end delay over IP • application example: video/audio streaming TCP

  5. 0 16 31 SrcPort DstPort Length Checksum Data UDP • Port, menunjukkan layanan aplikasi (= TCP) • valid port numbers antara 0 – 65535 (16 bit) • static port numbersadalah port yang telah terregister (reserved),dynamicport merupakan yang unregistered.Sesuai persetujuan, nilai port di atas 49151 adalah dynamic ports. • (Aplikasi) Pengirim mengirim paket UDP melalui Source Port. (Aplikasi) penerima menerima (permintaan) aplikasi melalui Destination Port. TCP

  6. UDP • Length, menunjukkan panjang header & data dalam octets. Ukuran maksimum secara teoritis adalah 65535 bytes (16 bit). Meskipun demikian, beberapa implementasi membatasi Length ini menjadi lebih kecil, kadang-kadang hanya sampai8192 bytes. • Checksums, untuk check kesalahan. Pada UDP, checksummerupakan pilihan. Jika checksum ini tidak diperlukan maka nilai di-reset (nol semua). • Pada TCP, checksums merupakan keharusan. TCP

  7. Mengapa pakai UDP • Packet oriented • Not a byte stream, packet integrity • Tidak perlu set up koneksi, bisa lebih cepat • Throughput lebih besar, karena UDP paket lebih mudah diproses di bagian Pengirim • User tidak begitu peduli dengan reliabilitas (ketahanan paket) • User ingin menggunakan Transport Protocol sendiri • E.g. For video TCP

  8. Port • Need to decide which application gets which packets • Solution: map each socket to a port • Client must know server’s port • Separate 16-bit port address space for UDP and TCP • (src IP, src port, dst IP, dst port) uniquely identifies TCP connection • Well known ports (0-1023): everyone agrees which services run on these ports • e.g., ssh:22, http:80 • on UNIX, must be root to gain access to these ports (why?) • ephemeral ports(most 1024-65535): given to clients • e.g. chatclient gets one of these • EECS 122 Walrand 8 TCP

  9. TCP • TCP = Transmission Control Protocol • TCP berada di atas IP, mengirim paket dengan fungsi-fungsi yang sangat berguna • Streams. TCP data terorganisir sebagai stream of bytes, seperti file. Bentuk-bentuk datagram tidak akan kelihatan di sini. • Reliable delivery. Sequence numbers digunakan untuk mengurutkan data-data yang dikirim dan diterima. TCP akan mengirim lagi suatu data yang rusak atau hilang. • Network adaptation. TCP secara dinamis mempelajari tunda (delay)pengiriman akibat jaringandan berusaha memaksimumkan throughputtanpa membebani jaringan tersebut. • Flow control. TCP mengatur data buffers, dan koordinasi dengan trafik sehingga buffer-nya tidak pernah overflow. Pengirim yang cepat akan memperlambat kirimannya untuk menyesuaikan dengan penerima. TCP

  10. TCP • TCP merupakan end-to-end reliableconnection,yang IP sendiri belum support • Koneksi TCP sering dikenal dengan nama “socket” • Socket dapat dianggap sebagai pipa penghubung bi-directional antara dua host. • Untuk menyambung socket diperlukan IP penerima dan nomor port-nya • Ports (bisa dianggap layanan) memungkinkan suatu host menghubungi host lain dengan lebih dari satu hubungan (lebih dari satu layanan) • Nomor port sampai 1024 telah terpakai (Lihat di UNIX /etc/service) TCP

  11. Application process Application process W rite Read bytes bytes … … TCP TCP Send buffer Receive buffer … Segment Segment Segment T ransmit segments TCP Overview • Full duplex • Flow control: keep sender from overrunning receiver • Congestion control: keep sender from overrunning network • Transmission Control Protocol • Connection-oriented • Byte-stream • app writes bytes • TCP sends segments • app reads bytes TCP

  12. TCP Format TCP

  13. TCP Format • Source dan Destination port, merupakan aplikasi (layanan). Bersamaan dengan IP address disebut juga dengan Socket • Seq. Number, nomor urutan. Sebagai contoh, jika SN suatu segment = 1343 dan segment tersebut berisi data 512 octets, maka segment selanjutnya akan mempunyai SN = 1856 (=1343+512). • Ack Number, menunjukkan next paket yang diharapkan diterima oleh destination. Jika Source menerima AN yang tidak cocok dengan next SN-nya (milik Source), maka Source tahu ada paket yang hilang (rusak) dan tahu juga paket mana yang hilang (rusak) tersebut. TCP

  14. TCP Format • Header length(4 bit), panjang Header dalam 32 bit • 0, (6 bit) diset = 0 semua • Flag (6 bit), digunakan untuk data flow dan connection control. Flag meliputi Urgent (URG), ACK, Push (PSH), Reset (RST), Synchronize (SYN), dan Final (FIN). • Adv. Window, untuk flow control, menunjukkan berapa bytes yang akan dikirim setelah ACK diterima. • Cheksum, meliputi Header dan Data • Urgent pointer, menunjukkan posisi urgent data pada TCP paket (URG harus diset = 1) TCP

  15. TCP Format • Flag bits • URG = Urgent pointer field in use • ACK = Indicates whether frame contains acknowledgement • PSH = Data sudah di “pushed”. It should be delivered tohigher layers right away. • RST = Koneksi di-Reset (diulangi dari awal) • SYN = Untuk memulai koneksi • FIN = Untuk mengakhiri koneksi TCP

  16. Data (SequenceNum) Sender Receiver Acknowledgment + AdvertisedWindow TCP Format • Each connection identified with 4-tuple: • (SrcPort, SrcIPAddr, DsrPort, DstIPAddr) • Sliding window + flow control • acknowledgment, SequenceNum, AdvertisedWinow • Flags • SYN, FIN, RESET, PUSH, URG, ACK • Checksum • pseudo header + TCP header + data TCP

  17. TCP • Service • Steps • 3-Way Handshake • State Diagram: 1 • State Diagram: 2 • Header • Sliding Window Protocol TCP

  18. TCP Service • Connection Establishment • Data Transfer, Reliable byte stream delivery • from (IPa, TCP Port 1) to (IPb, TCP Port 2) • Indication if connection fails: Reset • Terminate connection TCP

  19. Host A Host B SYN (SN=x) Start Conn 3WH SYN&ACK(SN=y, ACK=x) DATA(SN=x, ACK=y) Data Transfer ACK(ACK=x+y+1) FIN Close 1 FIN ACK Close 2 FIN FIN ACK TCP Service TCP

  20. Host A Host B SYN (SN=x) ACK&SYN(ACK=x+1 SN=y) (ACK=y+1 SN=x+1) Three Way Handshake 3WH Connection Establishment (CE) connect() listen() accept() • Goal: agree on a set of parameters: the start sequence number for each side • Starting sequence numbers are random. TCP

  21. 10 0 4 16 31 SrcPort = 1427 (05 93) DstPort = 8080 (1f 90) SequenceNum = 0 (9b 84 a7 24) Acknowledgment = 0 (00 00 00 00) 000000 000010 AdvWindow=16384 (40 00) 28 (70) Checksum (55f4) UrgPtr (00 00) Options (variable) Data CE (Frame 1) TCP

  22. Connection Tear-Down • Two types of connection tear-down: • Asymmetric Release: • Either host may terminate the connection • TCP: Symmetric Release: • Both sides keep a unidirectional connection to theother • For each connection, the source tears it down whenno more packets will be sent TCP

  23. Problem 1: Data lost • In asymmetric tear-down, data may be lost: TCP

  24. Problem 1: Data lost • Partial solution: • Use 3-way handshake for connection tear-down • Destination host starts a timer after it receives adisconnect request (DR) • The destination finally releases the connection once itsacknowledgement is also acknowledged • If no return acknowledgement arrives within the timeoutinterval, the connection is disconnected TCP

  25. Problem #2: Lost tear-downrequests • What if all disconnect requests are lost? TCP

  26. Problem #2: Lost tear-downrequests • Solution: • Require a host to close a connection if nopackets have been received for a specifiedamount of time • Hosts transmit keep-alive packets to keep aconnection open when they have no data tosend TCP

  27. TCP Connection Tear-down • Two double handshakes: TCP

  28. Flow and Error Control • The transport layer, like the data link layer, mustprovide a flow-controlled and error-controlled link • The data link layer is hop-by-hop (node-to-node),while the transport layer is end-to-end • The same flow and error control protocols used inthe data link layer may be used with the transportlayer • One additional concern: packet resequencing TCP

  29. Sending application Receiving application TCP TCP LastByteWritten LastByteRead LastByteAcked LastByteSent NextByteExpected LastByteRcvd Sliding Window Revisited • Sending side • LastByteAcked < = LastByteSent • LastByteSent < = LastByteWritten • buffer bytes between LastByteAcked and LastByteWritten • Receiving side • LastByteRead < NextByteExpected • NextByteExpected < = LastByteRcvd +1 • buffer bytes between NextByteRead and LastByteRcvd TCP

  30. Sliding Window with Out of OrderArrivals • Sender side window is unaffected by out of orderreception of packets at the receiver • Receiver side window, however, behavesdifferently when packets are able to arrive out oforder • New techniques required TCP

  31. Sliding Window with Out of OrderArrivals • Procedure for receiver-side sliding window: • Packets with sequence numbers outside the slidingwindow are discarded • When a packet arrives out of order, place a mark by thepacket’s sequence number in the window • When the first packet in the sliding window arrives,adjust the start of the sliding window up to the nextunmarked sequence number. Generateacknowledgements for each of the sequence numbersthe sliding window just passed. TCP

  32. TCP Flow Control • TCP uses a modified version of the slidingwindow • In acknowledgements, TCP uses the“Window size” field to tell the sender howmany bytes it may transmit • TCP uses bytes, not packets, as sequencenumbers TCP

  33. TCP Flow Control • Important information in TCP/IP packet headers TCP

  34. TCP Flow Control TCP

  35. TCP Flow Control • Piggybacking: Allows more efficient bidirectionalcommunication TCP

  36. TCP Flow Control Problems • The Small Packet Problem • Occurs when the source sends many smallpackets • The Silly Window Syndrome • Occurs when the destination reads a smallnumber of bytes at a time from its buffer TCP

  37. The Small Packet Problem (SPP) • Consider an interactive application where the source hostsends each keystroke one at a time to the destination host • Each keystroke is 1 byte. After adding TCP/IP overhead, a 41-byte packet is generated • When the destination receives the packet, it returns a 40-byteacknowledgement packet • When the destination removes the byte from its buffer, a 40-bytewindow update packet is sent • Some applications echo the typed character back to the source,creating another 41-byte packet TCP

  38. The Small Packet Problem (SPP) TCP

  39. How TCP Solves the SPP • Nagle’s Algorithm: • When data is sent one byte at a time, send only the firstbyte • Buffer all remaining bytes until the first one isacknowledged • After receiving the acknowledgement, send all thebuffered bytes in one packet • This algorithm reduces the amount of bandwidthrequired to support interactive applications TCP

  40. Nagle’s Algorithm TCP

  41. Problems with Nagle’sAlgorithm • Works find if protocol is round trip oriented • Send packet, wait for response • What if protocol has several small packets? • Type ahead with telnet over a slow link. • X-windows data (plot point, draw-line) • Socket option to turn off Nagle in Unix. TCP

  42. Silly Window Syndrome (SWS) • Consider an application where the source sends in largeblocks of data but the destination reads bytes from itsbuffer 1 byte at a time • Each time the destination reads a byte from its buffer, it returns awindow update to the source • The source sees that it is only free to send 1 more byte so it sends asingle byte • This process repeats itself until all the data has been sent, 1 byte ata time TCP

  43. Silly Window Syndrome (SWS) TCP

  44. How TCP Solves the SWS • Clark’s Solution: • Prevent the receiver application from reading only 1byte from its TCP buffer • The receiver application should only read from the TCPbuffer when it has sufficient application buffer space tohandle a larger chunk of data • The sender may also help by refusing to send small datapackets TCP

  45. TCP Retransmission • When a packet remains unacknowledged for aperiod of time, TCP assumes it is lost andretransmits it • TCP tries to calculate the round trip time (RTT)for a packet and its acknowledgement • From the RTT, TCP can guess how long it shouldwait before timing out • RTT computation not part of the TCP specification! TCP

  46. Round Trip Time (RTT) • RTT = Time for packet to arrive at destination+Time for ACK to return from destination TCP

  47. RTT TCP

  48. Smoothing the RTTmeasurement • First, we must smooth the round trip time due tovariations in delay within the network: • SRTT = a SRTT + (1-a) RTTarriving ACK • The smoothed round trip time (SRTT) weightspreviously received RTTs by the a parametera is typically equal to 0.875 TCP

  49. Calculating the Retransmission Timeout Interval • The timeout value is then calculated bymultiplying the smoothed RTT by somefactor (greater than 1) called b • Timeout = b ´ SRTT • This coefficient of b is included to allow forsome variation in the round trip times. TCP

  50. Smoothing the RTTmeasurementExample • Initial SRTT = 1.50, a = 0.875, b = 4.0 TCP

More Related