Bài giảng mạng máy tính và internet chương 3 trần quang hải bằng

43 379 0
Bài giảng mạng máy tính và internet  chương 3   trần quang hải bằng

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Chương Giao thức tầng giao vận (transport layer) Trần Quang Hải Bằng Faculty of Information Technology University of Communication and Transport (Unit 2) Office location: Administration building, Block D3, Room Office phone: 38962018 Cell phone: N/A Email: tqhbang@utc2.edu.vn 06/02- 24/03/2012 Chương Giao thức tầng giao vận (transport layer) Ch3 The Transport Layer Transport Layer Services & Principles Multiplexing/Demultiplexing Connectionless Transport (UDP) Principles of Reliable Data Transfer (RDT) Connection-oriented Transport (TCP) Congestion Control Sử dụng TCP hay UDP 06/02- 24/03/2012 Chương Giao thức tầng giao vận (transport layer) Transport Layer Services & Principles application transport network data link physical a ic nd le network data link physical network data link physical rt po Chương Giao thức tầng giao vận (transport layer) network data link physical s an tr Các msg từ tầng application gửi xuống chia nhỏ thành đoạn (segments) Transport protocol thực thi trạm cuối (end system) nd -e application: messages transport: segments (đoạn) 06/02- 24/03/2012 network data link physical network data link physical g lo Cung cấp phương tiện truyền thông logic (logical communication) applications PDUs application transport network data link physical Transport & Network layers Network layer: Truyền thông logic trạm làm việc (host) PDUs = packets (gói) IP (Internet Protocol) giao thức truyền không tin cậy Transport layer: Tạo phương thức truyền thơng logic ứng dụng (application/process) Nhận gói tin từ tầng Network gửi lên 06/02- 24/03/2012 Household analogy: 12 kids sending letters to 12 kids processes = kids app messages = letters in envelopes hosts = houses transport protocol = Ann and Bill network-layer protocol = postal service Chương Giao thức tầng giao vận (transport layer) Transport Protocols TCP (Transmission Control Protocol) Connection-oriented (có liên kết) Flow control (điều khiển luồng) Congestion control (điều khiển chống nghẽn mạng) reliable transport protocol (tin cậy) UDP (User Datagram Protocol) Connectionless Khơng có kiểm sốt luồng kiểm sốt nghẽn mạng unreliable transport protocol 06/02- 24/03/2012 Chương Giao thức tầng giao vận (transport layer) Ch3 The Transport Layer Transport Layer Services & Principles Multiplexing/Demultiplexing Connectionless Transport (UDP) Principles of Reliable Data Transfer (RDT) Connection-oriented Transport (TCP) Congestion Control Sử dụng TCP hay UDP Chương Giao thức tầng giao vận (transport layer) 06/02- 24/03/2012 Multiplexing/demultiplexing (mux/demux) sender P3 application-layer data segment header segment Ht M Hn segment receiver M M P4 application transport network P1 M application transport network sender M P2 application transport network Multiplexing (dồn kênh): Các msgs từ apps (P1, P2) chia nhỏ đóng gói thành segments (thêm header) dồn kênh diễn sending hosts Demultiplexing (phân kênh): Các segments nhận được gửi tới apps tương ứng (P3, P4) phân kênh diễn receiving hosts 06/02- 24/03/2012 Chương Giao thức tầng giao vận (transport layer) Dồn chia kênh nào? source port number: ứng dụng gửi liệu destination port number: ứng dụng nhận liệu Port number: 0-1023: well-known port number (đã giữ cho apps phổ biến) 1024 – 65535 32 bits source port # dest port # other header fields application data (message) TCP/UDP segment format Chương Giao thức tầng giao vận (transport layer) 06/02- 24/03/2012 Mux/demux: Ví dụ host A source port: x dest port: 23 server B source port:23 dest port: x Source IP: C Dest IP: B source port: y dest port: 80 port use: simple telnet app Web client host A Web client host C Source IP: A Dest IP: B source port: x dest port: 80 Source IP: C Dest IP: B source port: x dest port: 80 Web server B port use: Web server 06/02- 24/03/2012 Chương Giao thức tầng giao vận (transport layer) 10 Ch3 The Transport Layer Transport Layer Services & Principles Multiplexing/Demultiplexing Connectionless Transport (UDP) Principles of Reliable Data Transfer (RDT) Connection-oriented Transport (TCP) Congestion Control Sử dụng TCP hay UDP 06/02- 24/03/2012 11 Chương Giao thức tầng giao vận (transport layer) Connectionless Transport (UDP) User Datagram Protocol [RFC 768] “no frill”, “bare bones” Internet transport protocol cần thủ tục thông tin điều khiển cần “best effort” service: liệu mát, sai sót ln “cố gắng hết sức” để giảm thiểu Connectionless: Khơng có chế bắt tay (handshaking): thiết lập liệu kết thúc Không nắm giữ trạng thái Các segments xử lý độc lập với 06/02- 24/03/2012 Chương Giao thức tầng giao vận (transport layer) truyền 12 UDP: Segment structure source port dest port length application data checksum: mã kiểm tra lỗi (phục vụ cho chế nhận biết lỗi – error detection) 06/02- 24/03/2012 32 bits Length, in bytes of UDP segment, including header source port # dest port # length checksum Application data (message) UDP segment format Chương Giao thức tầng giao vận (transport layer) 13 UDP segment - example Sender’s MAC address Receiver’s MAC address 06/02- 24/03/2012 Type of upper layer’s protocol ( 0x0800 = IP ) Chương Giao thức tầng giao vận (transport layer) 14 UDP segment – example (cnt.) IP’s Header 06/02- 24/03/2012 Chương Giao thức tầng giao vận (transport layer) 15 UDP segment – example (cnt.) UDP’s header 06/02- 24/03/2012 Chương Giao thức tầng giao vận (transport layer) 16 UDP segment – example (cnt.) Data of applicaton layer 06/02- 24/03/2012 Chương Giao thức tầng giao vận (transport layer) 17 UDP checksum Mã kiểm tra phục vụ cho chế nhận biết lỗi Sender: Coi segment chuỗi số nguyên 16-bit checksum = số bù (1’s complement) tổng số ngun Receiver: Tính tốn checksum segment nhận So sánh với checksum chứa trường checksum segment nhận sai khác tức có lỗi 06/02- 24/03/2012 Chương Giao thức tầng giao vận (transport layer) 18 UDP checksum: example Phép cộng số 16-bit liên tiếp phép cộng có nhớ Kiểm tra checksum: Lấy tổng số 16-bit (có nhớ) cộng với checksum: Kết 1111 1111 1111 1111 khơng có lỗi, khác có lỗi 1 1 0 1 0 1 0 1 1 1 1 1 1 wraparound 1 1 1 1 1 1 sum 1 1 1 1 1 1 0 checksum 1 0 0 0 0 1 (bù 1) 06/02- 24/03/2012 Chương Giao thức tầng giao vận (transport layer) 19 Ch3 The Transport Layer Transport Layer Services & Principles Multiplexing/Demultiplexing Connectionless Transport (UDP) Principles of Reliable Data Transfer (RDT) Connection-oriented Transport (TCP) Congestion Control Sử dụng TCP hay UDP 06/02- 24/03/2012 Chương Giao thức tầng giao vận (transport layer) 20 TCP segment – example (cnt.) TCP’s Header Check sum Pointer urgent data 06/02- 24/03/2012 Chương Giao thức tầng giao vận (transport layer) 57 TCP segment – example (cnt.) TCP’s Header TCP’s Options (20 bytes) 06/02- 24/03/2012 Chương Giao thức tầng giao vận (transport layer) 58 TCP: Reliable Data Transfer (retransmission) Host A Host B timeout Seq=9 2, b ytes d ata =1 ACK 00 X loss Seq=9 2, b ytes d ata =100 ACK time 06/02- 24/03/2012 lost ACK scenario Chương Giao thức tầng giao vận (transport layer) 59 TCP flow control Các apps xử lý liệu chậm, gói tin nhận đưa vào đệm (receiver buffer) Flow control: kiểm sốt khơng receiver buffer bị tràn sender gửi nhiều gói tin q Receiver: Thơng báo cho sender biết kích thước RcvWidow (free buffer): trường rcv window size TCP segment headers Sender: Ln nắm kích thước tối đa gói tin truyền tiếp 06/02- 24/03/2012 Chương Giao thức tầng giao vận (transport layer) 60 TCP Connection management TCP: Connection-oriented Khởi tạo giá trị: sequence number buffers, flow control information Client:Connection initiator (khởi tạo liên kết: socket) Server: Chấp nhận kết nối Three way handshaking: Bước 1: client gửi TCP SYN control segment tới server Bước 2: server nhận SYN segment trả lời SYNACK segment Bước 3: client nhận SYNACK segment trả lời ACK segment (có thể có liệu kèm) 06/02- 24/03/2012 Chương Giao thức tầng giao vận (transport layer) 61 06/02- 24/03/2012 Chương Giao thức tầng giao vận (transport layer) 62 TCP Connection management: ngắt liên kết 06/02- 24/03/2012 client server closing FIN ACK closing FIN timed wait Bước 1: client (phía muốn ngắt liên kết) gửi TCP FIN segment Bước 2: server (phía cịn lại) nhận FIN, gửi ACK, ngắt liên kết, gửi tiếp FIN segment Bước 3: client nhận FIN, trả lời ACK timed wait (chờ lúc liên kết đóng hẳn) Bước 4: server nhận ACK, đóng liên kết ACK closed closed Chương Giao thức tầng giao vận (transport layer) 63 TCP Connection management (cont.) TCP client lifecycle 06/02- 24/03/2012 TCP server lifecycle Chương Giao thức tầng giao vận (transport layer) 64 Ch3 The Transport Layer Transport Layer Services & Principles Multiplexing/Demultiplexing Connectionless Transport (UDP) Principles of Reliable Data Transfer (RDT) Connection-oriented Transport (TCP) Congestion Control Sử dụng TCP hay UDP 06/02- 24/03/2012 Chương Giao thức tầng giao vận (transport layer) 65 Congestion control Nghẽn mạng điều khó tránh khỏi!!! Khi mạng bị nghẽn, gói tin bị trễ hay bị Hai hướng tiếp cận: End-end congestion control: Thông tin mức độ nghẽn mạng suy từ lượng tin bị mát trình truyền Network-assited congestion control: Routers cung cấp thơng tin phản hồi tình trạng nghẽn mạng tới end systems Bit thông báo nghẽn mạng đừng gửi hoăc xin chờ lát Tốc độ tối đa cho phép gửi (maximum rate allowed) TCP sử dụng phương pháp end-end congestion control 06/02- 24/03/2012 Chương Giao thức tầng giao vận (transport layer) 66 Causes/costs of congestion: scenario senders, receivers 01 router, buffers vô hạn no retransmission Host A λout λin : original data Host B unlimited shared output link buffers large delays when congested maximum achievable throughput 06/02- 24/03/2012 Chương Giao thức tầng giao vận (transport layer) 67 Causes/costs of congestion: scenario one router, buffers có hạn sender gửi lại packet bị Host A λin : original data λout λ'in : original data, plus retransmitted data Host B 06/02- 24/03/2012 finite shared output link buffers Chương Giao thức tầng giao vận (transport layer) 68 Causes/costs of congestion: scenario always: λ = λ (goodput) out in “perfect” retransmission only when loss: λ > λout in retransmission of delayed (not lost) packet makes λin larger (than perfect case) for same λ out “costs” of congestion: more work (retrans) for given “goodput” unneeded retransmissions: link carries multiple copies of pkt 06/02- 24/03/2012 69 Chương Giao thức tầng giao vận (transport layer) Causes/costs of congestion: scenario senders multihop paths timeout/retransmit Q: what happens as λ in and λ increase ? in Host A λin : original data λout λ'in : original data, plus retransmitted data finite shared output link buffers Host B 06/02- 24/03/2012 Chương Giao thức tầng giao vận (transport layer) 70 Causes/costs of congestion: scenario H o s t A λ o u t H o s t B Another “cost” of congestion: Khi thực drop packet đường truyền dung lượng đường truyền sử dụng để gửi tin tới điểm bị drop vơ ích Chương Giao thức tầng giao vận (transport layer) 06/02- 24/03/2012 71 TCP Congestion Control end-end control (no network assistance) Sender điều khiển lượng liệu gửi theo quy tắc: LastByteSent-LastByteAcked ≤ {CongWin, ReceiverWnd} Công thức xấp xỉ: rate = CongWin RTT Bytes/sec Giá trị CongWin ln biến đổi tính tốn theo khả truyền tải mạng 06/02- 24/03/2012 Làm sender đánh giá tình trạng nghẽn? loss event = timeout or duplicate ACKs TCP sender reduces rate (CongWin) after loss event Cơ chế đánh giá nghẽn: AIMD Slow start conservative after timeout events Chương Giao thức tầng giao vận (transport layer) 72 TCP AIMD (additive-increase, multiplicative-decrease) multiplicative decrease: cut CongWin in half after loss event additive increase: increase CongWin by MSS every RTT in the absence of loss events: probing congestion window 24 Kbytes 16 Kbytes Kbytes time Long-lived TCP connection 06/02- 24/03/2012 Chương Giao thức tầng giao vận (transport layer) 73 TCP Slow Start When connection begins, CongWin = MSS When connection begins, increase rate exponentially fast until first loss event Example: MSS = 500 bytes & RTT = 200 msec initial rate = 20 kbps Available bandwidth may be >> MSS/RTT desirable to quickly ramp up to respectable rate 06/02- 24/03/2012 Chương Giao thức tầng giao vận (transport layer) 74 TCP Slow Start (more) When connection begins, increase rate exponentially until first loss event: done by incrementing CongWin for every ACK received Summary: initial rate is slow but ramps up exponentially fast RTT double CongWin every RTT Host A Host B one segm ent two segm ents four segm ents time 06/02- 24/03/2012 Chương Giao thức tầng giao vận (transport layer) 75 Refinement After dup ACKs: CongWin is cut in half window then grows linearly But after timeout event: CongWin instead set to MSS; window then grows exponentially to a threshold, then grows linearly 06/02- 24/03/2012 Philosophy: • dup ACKs indicates network capable of delivering some segments • timeout before dup ACKs is “more alarming” Chương Giao thức tầng giao vận (transport layer) 76 Refinement (more) Q: When should the exponential increase switch to linear? A: When CongWin gets to 1/2 of its value before timeout Implementation: Variable Threshold At loss event, Threshold is set to 1/2 of CongWin just before loss event 06/02- 24/03/2012 Chương Giao thức tầng giao vận (transport layer) 77 Summary: TCP Congestion Control When CongWin is below Threshold, sender in slowstart phase, window grows exponentially When CongWin is above Threshold, sender is in congestion-avoidance phase, window grows linearly When a triple duplicate ACK occurs, Threshold set to CongWin/2 and CongWin set to Threshold When timeout occurs, Threshold set to CongWin/2 and CongWin is set to MSS 06/02- 24/03/2012 Chương Giao thức tầng giao vận (transport layer) 78 TCP throughput (or transmission rate) Gía trị throughout (số packet gửi / giây) TCP tính theo Window size RTT bao nhiêu? Khơng tính giai đoạn slowstart Gọi W giá trị window size xuất gói Khi window size = W, throughput = W/RTT Ngay sau có nghẽn (lost), window size giảm xuống = W/2 throughput = W/2RTT Throughout trung bình là: 0.75 W/RTT Throughout TB = 3W/4RTT 06/02- 24/03/2012 Chương Giao thức tầng giao vận (transport layer) 79 TCP Futures Hỏi: Giả sử MSS = 1500 byte, RTT = 100µs , Cần gửi với tốc độ 10 Gbps (throughput=109 bps) Vậy giá trị Windowsize phải ? Trả lời: window size W = 83,333 in-flight segments Throughput tính theo loss rate: 1.22 ⋅ MSS RTT L Trong L = loss rate 06/02- 24/03/2012 Chương Giao thức tầng giao vận (transport layer) 80 Delay modeling Q: How long does it take to receive an object from a Web server after sending a request? Ignoring congestion, delay is influenced by: TCP connection establishment data transmission delay slow start 06/02- 24/03/2012 Notation, assumptions: Assume one link between client and server of rate R S: MSS (bits) O: object size (bits) no retransmissions (no loss, no corruption) Window size: First assume: fixed congestion window, W segments Then dynamic window, modeling slow start Chương Giao thức tầng giao vận (transport layer) 81 Fixed congestion window (1) First case: WS/R > RTT + S/R: ACK for first segment in window returns before window’s worth of data sent delay = 2RTT + O/R 06/02- 24/03/2012 Chương Giao thức tầng giao vận (transport layer) 82 Fixed congestion window (2) Second case: WS/R < RTT + S/R: wait for ACK after sending window’s worth of data sent delay = 2RTT + O/R + (K-1)[S/R + RTT - WS/R] 06/02- 24/03/2012 Chương Giao thức tầng giao vận (transport layer) Transport Layer 3-83 83 Ch3 The Transport Layer Transport Layer Services & Principles Multiplexing/Demultiplexing Connectionless Transport (UDP) Principles of Reliable Data Transfer (RDT) Connection-oriented Transport (TCP) Congestion Control Sử dụng TCP hay UDP 06/02- 24/03/2012 Chương Giao thức tầng giao vận (transport layer) 84 Một số so sánh TCP/UDP Có liên kết, lưu trữ trạng thái liên kết (quản lý liên kết) Điểm-điểm Có độ trễ (delay): thiết lập, quản lý liên kết, luồng, nghẽn… Segment header lớn (20 bytes) Bị giới hạn tốc độ truyền (congestion control) 06/02- 24/03/2012 Không liên kết, không lưu trữ trạng thái Điểm-điểm, quảng bá Độ trễ thấp Segment header nhỏ (8 bytes) Không giới hạn tốc độ truyền 85 Chương Giao thức tầng giao vận (transport layer) Các app thực tế Application App protocol Transport protocol Electronic mail SMTP TCP Remote terminal access Telnet TCP Web HTTP TCP File transfer FTP TCP Remote file server NFS typically UDP Streaming multimedia proprietary typically UDP Internet telephony proprietary typically UDP SNMP typically UDP Routing protocol RIP typically UDP Name translation DNS typically UDP Network management 06/02- 24/03/2012 Chương Giao thức tầng giao vận (transport layer) 86 ... start_timer Chương Giao thức tầng giao vận (transport layer) 34 RDT3.0 in action 06/02- 24/ 03/ 2012 Chương Giao thức tầng giao vận (transport layer) 35 RDT3.0 in action (cont) 06/02- 24/ 03/ 2012 Chương. .. Vậy giá trị Windowsize phải ? Trả lời: window size W = 83, 333 in-flight segments Throughput tính theo loss rate: 1.22 ⋅ MSS RTT L Trong L = loss rate 06/02- 24/ 03/ 2012 Chương Giao thức tầng giao... delay = 2RTT + O/R + (K-1)[S/R + RTT - WS/R] 06/02- 24/ 03/ 2012 Chương Giao thức tầng giao vận (transport layer) Transport Layer 3- 83 83 Ch3 The Transport Layer Transport Layer Services & Principles

Ngày đăng: 04/12/2015, 07:21

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan