1 / 75

UDP dan TCP

Learn about TCP (Transmission Control Protocol) and UDP (User Datagram Protocol), including their differences, features, and common application scenarios.

charlesdye
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 • Connection less, best effort • 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 • Endpoints identified by ports • servers have well-known ports • see /etc/services on Unix • Optional checksum • psuedo header + UDP header + data TCP

  5. 0 16 31 SrcPort DstPort Checksum Length 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 data dalam octets. Jumlah bytes termasuk header dan data. 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. 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

  9. 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

  10. 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

  11. TCP Format TCP

  12. 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

  13. 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

  14. 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

  15. 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

  16. Koneksi • Transport layer bertanggung jawab terhadap layer di atasnya untuk sambungan end-to-end connection • Diperlukan: • Connection setup • Connection tear-down TCP

  17. Connection Establishment Three-way Handshake TCP

  18. Setting Up Koneksi • Ketika suatu aplikasi di client ingin berhubungan dengan suatu aplikasi (layanan) di server (host lain), maka client tersebut harus men-set up sambungan Transport Layer ke layanan server tersebut • Mengapa harus three-way handshake? • Karena setting up a connection is not as easy as it seems (tidak semudah yang diduga) TCP

  19. Setting Up Koneksi • Contoh yang buruk (Naïve) : • Source mengirim suatu connection setup packetke Destination • Destination mengirim balik acknowledgmentterhadap connection setuppackettadi, dan kemudian terjadi koneksi TCP

  20. Naïve • Dapat terjadi duplikasiconnection request(CR) atau accept connection(AC) • Anggap bahwa jaringan mempunyai tunda yang lama (karena ramai, congestion) TCP

  21. Penyelesaian • Dengan sequence number dan 3-way-handshake • Sequence number harus berulang pada suatu nilai yang besar untuk supaya yakin bahwa tidak ada sequencenumber yang sama TCP

  22. 3-way handshake: kasus 1 • Successful Connection : TCP

  23. 3-way handshake: Kasus 2 • Duplikasi CR TCP

  24. 2-way handshake • Problem Duplikasi SYN TCP

  25. 3 way handshake • Duplikasi CR dan ACK TCP

  26. Fixing 2-way handshake • Assume sender and receiver have sameclock • Use time of clock to pick sequence numbers • can reject based on clock value • Assume receiver can remember all oldsequence numbers • can recall last SYN and reject TCP

  27. 3 way handshake: kasus 4 • Simultanous Open TCP

  28. 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

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

  30. 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

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

  32. 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

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

  34. 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

  35. 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

  36. 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

  37. 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

  38. 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

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

  40. TCP Flow Control TCP

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

  42. 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

  43. 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

  44. The Small Packet Problem (SPP) TCP

  45. 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

  46. Nagle’s Algorithm TCP

  47. 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

  48. 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

  49. Silly Window Syndrome (SWS) TCP

  50. 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

More Related