Transmission Control Protocol (End-to-End Protocols)
Jaringan Komputer (IKI-20240) Johny Moningka (
[email protected]) Fakultas Ilmu Komputer Universitas Indonesia
Semester 2003/2004 Versi: 1.1
Agenda Apa yang telah dipelajari: Teknologi yang menghubungkan kumpulan komputer => jaringan: • Direct links, packet switching, internet protocol (IP)
Selanjutnya: Ekstensi koneksi dan penyampaian paket “host-to-host” => untuk komunikasi antar komputer yang terhubung dengan jaringan. Komunikasi aplikasi => antar proses melalui “communication channel”. Problem: Getting processes to communicate! (Ch. 5) User Datagram Protocol (UDP) Transmission Control Protocol (TCP) Fasilkom UI v-1.1
1
Review: Layered Ingat: tujuan jaringan komputer, menghubungkan aplikasi => saling berkomunikasi Layer bawah mendukung komunikasi antar aplikasi untuk mencapai tujuan tsb. IP => hanya menyampaikan paket data ke host (bukan ke aplikasi, tidak ada alamat proses pada IP address).
Transport Layer (OSI) => mendukung koneksi antar aplikasi (proses) Fasilkom UI v-1.1
End-System Mengapa disebut transport layer end-to-end protocol? Transport layer: hanya berada pada host (endsystem) End-system => user; asumsi: kontrol terakhir pengiriman data berada pada aplikasi. Services ke berbagai proses aplikasi Suatu host dapat mempunyai lebih dari satu proses (aplikasi) yang aktif Kebutuhan berbagai aplikasi berbeda; mis. reliable delivery vs unreliable delivery (low overhead) Fasilkom UI v-1.1
2
Problems: Getting process to communicate! Kebutuhan aplikasi (reliable data stream): multiple koneksi per-host (sharing): lebih dari satu aplikasi aktif dapat mengirim messages ke jaringan (multiplexing) garansi penyampaian “message”, notifikasi jika terjadi error (mis. target aplikasi tidak aktif) error control: pemeriksaan kesalahan, berurut, dan sekali saja (tidak ada duplikasi) message size: tidak terbatas dengan ukuran paket (model stream) flow control: sinkronisasi antara aplikasi (proses) pengirim dan penerima Fasilkom UI v-1.1
Transmission Control Protocol (TCP) TCP menyediakan byte-stream services Aplikasi mengirim dalam urutan (stream) bytes, tidak ada batas antar data (tergantung program) TCP memilah streams dalam bentuk segments (paket) Aplikasi menerima dalam urutan bytes
Application process
W rite Bytes
…
…
Application process
TCP
Read Bytes
TCP
Send buffer
Receive buffer
Segment
Segment
…
Segment
T ransmit segments Fasilkom UI v-1.1
3
TCP: Characteristics TCP is connection oriented 3 fase: connection setup, transfer data (bytestreams), disconnect TCP is reliable: Membagi data (bytes) dari aplikasi dalam kelompok segments (messages) Kontrol kesalahan pada setiap segments • ACK delivery data • Checksum deteksi kesalahan pada data • Nomor urut (sequence bytes) jika terjadi duplikasi atau segment hilang.
Retransmisi (sliding window) untuk mengatur pengiriman segments Fasilkom UI v-1.1
Transport vs. Data Link Layers OSI Ref.: keduanya reliable delivery data transmission Data Link: hanya menghubungkan dua nodes yang terhubung langsung (vs. Transport, melalui networks). Potentially connects many different hosts need explicit connection establishment and termination Potentially long delay in network need to be prepared for arrival of very old packets Potentially different network capacity need to be prepared for network congestion need not contribute to network congestion Fasilkom UI v-1.1
4
Encapsulation of User Data User Data 20 bytes of TCP header
TCP Header Figure 8.26
20 bytes of IP header
IP Header
User data are encapsulated in TCP Segments. A TCP Segment is the unit of data for user messages
Fasilkom UI v-1.1
TCP Segment Format 0
4
10
16
Source Port
24
31
Destination Port Sequence Number Acknowledgement Number
Header Length
Reserved
UAP R S F R C S S Y I GKH T NN
Checksum
Window Size Urgent Pointer
Options
Padding
Data Figure 8.20 Fasilkom UI v-1.1
5
TCP Segment Format (1) Source / Destination Ports (16b unsinged int): Identifikasi (address) proses (aplikasi): source & sink user application Sequence (Acknowledgement) Numbers (32b unsigned int): Number of first byte sent (expected from other side) in the segment to other side Acknowledgement Number is byte expected next (ACK) Header Length: in 32b words Reserved (0) Fasilkom UI v-1.1
TCP Segment Format (2) Flags: Informasi sesuai jenis paket TCP URG: urgent pointer is valid ACK: Acknowledgement number is valid PSH: deliver data received by receiving TCP immediately RST: Receving TCP must abort connection SYN: Connection Request; FIN: Sender has no more data to send to receiving TCP; (“Advertised”) Window Size: amount of data receiver is willing to accept. Fasilkom UI v-1.1
6
TCP Segment Format (3) Urgent Pointer (if URG flag is set) points to last byte of “urgent” data; any data from beginning of segment to up are “urgent”
Fasilkom UI v-1.1
TCP Segment Structure (Summary) 32 bits URG: urgent data ACK: ACK # valid PSH: push data now (generally not used) RST, SYN, FIN: connection estab (setup, teardown commands) Internet checksum (as in UDP)
source port #
dest port #
sequence number acknowledgement number head not UAP R S F len used
checksum
counting by bytes of data (not segments!)
rcvr window size ptr urgent data
Options (variable length)
# bytes rcvr willing to accept
application data (variable length)
Fasilkom UI v-1.1
7
TCP: Connection Setup Active Open Umum: koneksi diawali dari client => mengirim tipe messages SYN (connection setup) ke server. Passive Open Server mendengar untuk koneksi dari client Server membalas dengan mengirim tipe message SYN+ACK
Fasilkom UI v-1.1
Connection Establishment Two way handshake A send SYN, B replies with ACK-SYN • SYN hilang, timeout dan retransmisi
Bagaimana jika muncul “delayed” SYN (false connection)? Kemungkinan delayed SYN menyebabkan duplikasi SYNs => receiver ? Mana yang valid Gunakan Three Way Handshake Gunakan identifikasi SYN dengan bilangan tertentu => Initial Sequence Number • Gunakan SYN dan ISN • Balasan ACK harus “menunjuk” ISN yang sama
RFC 793: ISN harus increment setiap 4 mikro-detik. Fasilkom UI v-1.1
8
TCP Connection Management TCP sender, receiver establish “connection” before exchanging data segments Initialize TCP variables: sequence numbers buffers, flow control info (e.g., RcvWindow)
Three way handshake: Step 1: client end system sends TCP SYN control segment to server specifies initial sequence number
Step 2: server end system receives SYN, replies with SYNACK control segment ACKs received SYN allocates buffers specifies server→ receiver initial sequence number.
Fasilkom UI v-1.1
TCP: Connection Setup Reliability 3-way handshake Sequence Numbers: x, y (full duplex) Message types (Flag): Synchronize (SYN), Acknowledge (ACK)
Active participant (client) SYN,
Passive participant (server) Sequ ence Num
=
x
y, m= ceNu n e u x+1 , Seq e nt = ACK m + g d N e SY owl Ackn ACK, Ackn ow
ledgm ent =
y+ 1 Fasilkom UI v-1.1
9
Data Transfer: Sequence Numbers and ACKs Simple telnet scenario
Sequence Numbers: Host B Host A byte stream “number” of first User SN(42 ), AC byte in segment’s types B ACKs data( ‘ K(79), C’ ) ‘C’ data receipt of , ‘C’; ) ACKs: K(43 C A echoes , 9) seq. # of next byte SN(7 ata( ‘C’ ) back ‘C’ d expected from host ACKs other side SN(43) receipt , ACK( cumulative ACK 80) of echoed Example next figure: ‘C’ telnet interaction; time
Fasilkom UI v-1.1
TCP Connections: Graceful Close Host B
Host A FIN, SN(508 6)
TIME_WAIT
Step 1: client end system sends TCP FIN control segment to server (client knows when input has finished) Step 2: server receives FIN, replies with ACK. Closes connection, sends FIN.
087) ACK(5 , ) 3 5 4 ( FIN, SN ACK(454) Figure 8.27
closed Fasilkom UI v-1.1
10
TCP: Reliability Deteksi kesalahan: TCP Checksum Retransmisi segment kembali jika terjadi kesalahan Kontrol kesalahan: Penerima memberikan ACK untuk segment (byte) yang telah diterima Timer (jika ACK atau segment hilang) Flow control Kita ingin mengirim lebih dari satu segment (utilisasi koneksi), tanpa menunggu ACK segment sebelumnya Pengaturan supaya sender yang cepat tidak “overflow” receiver => sinkronisasi
Fasilkom UI v-1.1
TCP: Flow control TCP Sliding Window + Flow Control: ( acknowledgment, SequenceNum, AdvertisedWindow )
Data (SequenceNum) Sender
Receiver Acknowledgment + AdvertisedWindow
Fasilkom UI v-1.1
11
TCP: Advertised Window (Flow Control) Flow control Mencegah sender mengirim terlalu banyak sehingga melebihi kapasitas menerima dari receiver Negosiasi (informasi) ke sender => status dan kapasistas buffer dari receiver (proses) Menggunakan informasi: Advertised Window (field pada header TCP paket): • Max. ukuran buffer receiver – (sisa bytes yang belum dibaca oleh aplikasi) • Dinamik, tergantung kecepatan aplikasi memproses data pada buffer receiver.
Fasilkom UI v-1.1
12