版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、6 The Transport LayerThe Transport LayerThe Transport ServiceElements of Transport ProtocolsAddressing Connection Establishment Connection Release Flow Control and Buffering The Internet Transport ProtocolsUDP TCP Homework 6.1 The Transport ServiceThe Transport Service The transport layer is the hea
2、rt of the whole protocol hierarchyIt provides reliable data transport end to end (ETE)It masks the diversity of communication subnets, provide a common interface to the upper layerIt fulfills the key function of isolating the upper layers from the technology, design, and imperfections of the subnet
3、It provides multiple SAPs sharing one network linkThe Transport Function54321传输层提供应用进程间的逻辑通信主机 A主机 B应用进程应用进程路由器 1路由器 2AP1LAN2WANAP2AP3AP4IP 层LAN1AP1AP2AP4端口端口54321IP 协议的作用范围传输层协议 TCP 和 UDP 的作用范围AP3Services Provided to the Upper LayersThe network, transport, and application layers.Transport Protocol
4、Data UnitsThe nesting of TPDUs, packets, and frames.Primitives for a Simple Transport ServiceUnreliable (datagram) serviceThe connection-oriented transport service Berkeley Sockets Clientint main() int sock, bytes; char buf4096; /* buffer for incoming file */ struct sockaddr_in server; /* Servers SA
5、P */ sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); server.sin_family= AF_INET; server.sin_addr.s_addr = inet_addr(76); /* servers address */ server.sin_port= htons(12345); connect(sock, &server, sizeof(server); write(sock, ”abc.txt”, 8); / * Go get the file and write it to standard output. */ fo
6、r(;) bytes = read(sock, buf, sizeof(buf); /* read from socket */ if (bytes = 0) exit(0); /* check for end of file */ write(1, buf, bytes); /* write to standard output */ Serverint main() int fd, admin_sock, data_sock, bytes; char buf4096; /* buffer for outgoing file */ struct sockaddr_in server; /*
7、holds IP address */ server.sin_family = AF_INET; server.sin_addr.s_addr = htonl(INADDR_ANY); server.sin_port = htons(12345); admin_sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); bind(admin_sock, &server, sizeof(server); listen(admin_sock, 5); for(;) data_sock = accept(admin_sock, 0, 0); /* block
8、for connection request */ read(data_sock, buf, sizeof(buf); /* read file name from socket */ fd = open(buf, O_RDONLY); /* open the file to be sent back */ for(;) bytes = read(fd, buf, sizeof(buf); /* read from file */ if (bytes = 0) break; /* check for end of file */ write(data_sock, buf, bytes); /*
9、 write bytes to socket */ close(fd); /* closefile */ close(data_sock); /* close connection */ 6.2 Elements of Transport ProtocolsTransport Protocol & Data Link ProtocolBoth have to deal with error control, sequencing, flow controlEnvironment differencesAddressing of destinationsInitial connection es
10、tablishmentStorage capacity in the subnetAllocation of buffersElements of Transport ProtocolsAddressingConnection EstablishmentConnection ReleaseFlow Control and BufferingAddressingAddressingTSAPs, NSAPs and transport connections.AddressingGets the Servers TSAPWell-known TSAPLook up a name server or
11、 directory serverProcess serverIf there are many server processes, most of which are rarely used, it is wasteful to have each of them active (inetd)Process ServerConnection EstablishmentProblem Establishing a connection sounds easy One sends a CONNECTION REQUEST TPDU to the destination and wait for
12、a CONNECTION ACCEPTED replyProblemsNetwork can lose, store, and duplicate packetsThe initial sequence number The connection establishment TPDU could be delayed or duplicatedSolutionUsing throwaway transport addressesGiving each connection a connection identifier, but a crashed machine can not know w
13、hich identifier have been used Each connection starts numbering its TPDUs with a different initial sequence number (the low-order k bits of the clock)Require transport entities to be idle for T sec after a recovery to let all old TPDUs die offPrevent sequence numbers from being reused for a time T b
14、efore their potential use as initial sequence numbers The Three-way HandshakeThree protocol scenarios for establishing a connection using a three-way handshake (a) Normal operation(b) Old CONNECTION REQUEST appearing out of nowhere(c) Duplicate CONNECTION REQUEST and duplicate ACKCR: Connect Request
15、Connection ReleaseTwo Styles Asymmetric Release (violent)when one party hangs up, the connection is brokenAsymmetric release is abrupt and may result in data lossSymmetric Release (graceful)Treats connection as two separate unidirectional connectionsRequires each one to be released separatelyCR: Con
16、nect RequestThe Two-army ProblemConnection Release(a) Normal case of a three-way handshake. (b) final ACK lost.Releasing a connection meansThe transport entity removes the information about the connection from its table of currently open connections and signals the connections owner (the transport u
17、ser) somehow (Disconnect Request)Connection Release(c) Response lost (d) Response lost and subsequent DRs lostConnection Release: Half-open Connections Half-open connection if the initial DR and N retransmissions are all lost. The sender will give up and release the connection, while the other side
18、knows nothing at all about the attempts to disconnect Kill off half-open connections If no TPDUs have arrived for a certain number of seconds, the connection is then automatically disconnectedDummy TPDU: just to keep the other side from disconnecting (keepalive, heartbeat)Flow Control and BufferingB
19、uffer Size Problem(a) Chained fixed-size buffers. (b) Chained variable-sized buffers. (c) One large circular buffer per connection.Source Buffering & Destination BufferingThe optimum buffering between source buffering and destination bufferingBuffering at senderBuffering at receiverDecouple bufferin
20、g from acknowledgmentsVariable sized windows: Dynamic buffer managementThe sender and receiver need to dynamically adjust their buffer allocationsThe receiver piggybacks both acknowledgements and buffer allocations onto the reverse trafficFlow Control and BufferingFlow ControlTwo flow control factor
21、Buffer space available in the receiverexplicit window indicationThe capacity of the subnetsender monitor the networks carrying capacityMultiplexing(a) Upward multiplexing. (b) Downward multiplexing.6.4 The Internet Transport ProtocolsUDP(User Datagram Protocol)The Internet Transport ProtocolsTCP (Tr
22、ansmission Control Protocol)RFC793Connection-oriented protocolByte-stream UDP (User Datagram Protocol)RFC768Connectionless ProtocolTCP/IP Protocol StackApplicationTCP UDP Host-to-Network IPUDP (User Datagram Protocol)Does not do flow control, error control, or retransmission upon receipt of a bad se
23、gmentProvide an interface to the IP protocol with the added feature of demultiplexing multiple processes using the portsBroadcast & MulticastUser datagram boundary UDP HeaderChecksum Optional: Stored as 0 if not computed (a true computed 0 is stored as all 1s)UDP Checksum伪首部源端口目的端口长 度检验和数 据首 部UDP长度源
24、 IP 地址目的 IP 地址017IP 数据报字节44112122222字节发送在前数 据首 部UDP 用户数据报UDP Applications DNS (Domain Name System)DHCP (Dynamic Host Configuration Protocol)RIP (Routing Information Protocol)RTP (Real-time Transport Protocol)TFTP (Trivial File Transfer Protocol)RPC (Remote Procedure Call)NFS (Net File System)P2P (Pe
25、er-to-Peer, DHT, Kademlia)Remote Procedure CallSteps in making a remote procedure call. The stubs are shaded.The Real-Time Transport Protocol(a) The position of RTP in the protocol stack. (b) Packet nesting. RTP headerUnicast/Multicast UDP packetP: Padding, X: ExtensionCC: Counter of Contributing so
26、urce, M:MarkerPayload TypeEncoding algorithm Sequence number (丢失数据补估测值)A counter that is incremented on each RTP packet sentTimestamp(接收端:到达时间与播放时间分开)When the sample in the packet was madeSynchronization source identifier Which stream the packet belongs toTCP(Transmission Control Protocol)The TCP Se
27、rvice ModelSocketsocket address: IP address and Port (16-bit, TSAP)Each connection is identified by a pair of socketsWell-known portsReserved for standard servicesRFC1700inetd process (Internet daemon)TCP connectionFull-duplexEnd-to-End TCP does not support multicasting or broadcastingByte-stream, n
28、ot message stream (Why?)Message boundaries are not preserved end to end, just like UNIX fileTCP Well-known portsPortProtocolUse21FTPFile transfer23TelnetRemote login25SMTPE-mail80HTTPWorld Wide Web110POP-3Remote e-mail accessTCP Byte-stream(a) Four 512-byte segments sent as separate IP datagrams.(b)
29、 The 2048 bytes of data delivered to the application in a single READ CALLPUSH flagTo force data out, applications can use the PUSH flag, which tells TCP not to delay the transmissionUrgent data TCP Segment HeaderTCP Protocol (1)TCP EntityA port plus its hosts IP address forms a 48-bit unique end po
30、intThe source and destination end points together identify the connection (Local IP, Local port, Peer IP, Peer Port)32-bits sequenceCount byte, not segment (network speeds .)sequence numbers, acknowledgements numberTCP sender can accumulate data from several writes into one segment or can split data
31、 from one write over multiple segmentsThe retransmissions may include different byte ranges than the original transmissionTCP Protocol (2)TCP Segment20 or more bytes head, n bytes dataSegments without any data are legal and are commonly used for ACK and control messagesMSS (Maximum Segment Size)Limi
32、ted by IP datagram lengthLimited by MTU of each data link, so router could fragment a segmentVariable sized sliding windowReorder the segmentDisordered and duplicated segments received by the receiverThe TCP checksumThe pseudoheader included in the TCP checksumTCP ChecksumIt checksums the header, th
33、e data, and the conceptual pseudoheader Pseudoheader: helps detect misdelivered packets Checksum offloadTCP OptionsMSS optionAllow hosts to specify the maximum TCP payload it is willing to acceptDuring connection setup, each side can announce its maximum and see its partnersIf a host does not use th
34、is option, it defaults to a 536-byte payloadThe maximum segment size in the two directions need not be the sameWindow scale optionAllow the sender and receiver to negotiate a window scale factorSelective repeat instead of go back n protocolNACK: RFC 1106 introduced NAKs to allow the receiver to ask
35、for a specific segmentSelective Acknowledgment (SACK)TCP Connection EstablishmentClientExecutes a CONNECT primitive, specifying the IP address and port, sends a TCP segment with the SYN bit on and ACK bit off and waits for a responseServerWhen clients SYN segment arrives, checks to see if there is a
36、 process that has done a LISTEN on the port If not, it sends a reply with the RST bit on to reject the connectionIf some process is listening to the port, that process is given the incoming TCP segment, .TCP Connection Establishment(a) TCP connection establishment in the normal case.(b) Call collisi
37、on.Initial Sequence NumberInitial sequence number A clock-based scheme is used, with a clock tick every 4 sec When a host crashesIt may not reboot for the maximum packet lifetime to make sure that no packets from previous connections are still roaming around the Internet somewhere TCP Connection Rel
38、easeHost 1Host 2FIN=1, Seq=xAck= x+1Application request releasing connectionNotify applicationApplication request releasing connectionNotify applicationFIN=1, Seq= yAck= y+1Release the whole connectionUse timer to avoid the two-army problemIf a response to a FIN is not forthcoming within two maximum
39、 packet lifetimes, the sender of the FIN releases the connection TCP Connection Management ModelingStates used in the TCP connection management finite state machineTCP Connection Establishment (1)TCP Connection Establishment(2)TCP Connection Release (1)TCP Connection Release(2)TCP Connection Release
40、 (3)TCP Finite State MachineTCP Finite State MachineWindow management in TCPWindow management in TCPWhen the window is 0Sender may not normally send segmentsUrgent data may be sentSender may re-send a 1-byte segment to probe ACK & window to prevent deadlockNagles algorithmProblemOverhead: TCP head +
41、 IP head=20+20 bytesWhen used in TELNET connection, 1 data bytes carried with 40 bytes overhead (41+40+40+41)(DATA+ACK+WIN+ECHODATA)Improvement algorithmReceiver: Delay acknowledgement and window update, reduce the load placed by the receiverSender: Nagles algorithm Send one segment unless either of
42、 the following condition exist:Acknowledgement to last segment has been received Buffered data fills half the window or a maximum segmentTCP OptionTCP_NODELAY: Disable Nagles algorithm & using PUSH bitLinux TCP_CORK: Disable Nagles algorithm, wait 200ms to accumulate data for sending Silly Window Sy
43、ndromeClarks solutionReceiver should not send a window update until it can handle the MSS or its buffer is half empty, whichever is smallerOther TCP PoliciesReceiverBuffers received data, blocks a READ request from the application until it has a large chunk of data to provideAbout out-of-order segme
44、nts Network capacity and Receiver capacity(a) A fast network feeding a low capacity receiver(b) A slow network feeding a high-capacity receiverTCP Congestion ControlThe reason for packet timeoutNoise on a transmission linePacket discard at a congested routerTCP congestion control algorithmAssumption
45、: all timeouts are caused by congestion If an ICMP SOURCE QUENCH packet comes in and is passed to TCP, this event is treated the same way as a timeoutTwo flow factorReceiver capacity: receiver windowNetwork capacity: congestion windowOne Parameter (threshold)Initially 64 KBWhen a timeout occurs, the
46、 threshold is set to half of the current congestion window, and the congestion window is reset to one maximum segmentTCP Tahoe & TCP RenoSlow Start (Tahoe TCP)Slow startCongestion AvoidanceVarious Implementations of TCP Tahoe TCP (Van Jacobson, 1988)Reno TCPNew-Reno TCPVegas TCPSelective ACK TCPFast
47、 Recovery (Reno TCP)Reno TCP modifies retransmit procedure to include Fast Recovery (avoids the need to Slow-Start after a single packet loss)当接收端收到失序数据报时,会发回重复ACK,告知发送端收到失序的数据报并说明所期望的接收序号The sender enters fast recovery phase after receiving three duplicate ACKs, retransmits the lost packet and redu
48、ces its congestion window by one half (Fast retransmission)Upon receipt of an ACK for new data, the sender exits Fast Recovery phaseNew-Reno TCPNew-Reno TCP includes a small change to the Reno at the sender when a partial ACK is received during Fast Recovery phasePartial ACK: acknowledges some but n
49、ot all of the packets that were outstanding at the start of Fast Recovery (在快速恢复阶段到达的ACK只确认进入快速重传之前发送的一部分数据)In Reno: partial ACK take TCP out of Fast Recovery phase by deflating the size of congestion window.In New-Reno: Partial ACK do not take TCP out of Fast Recovery phasePartial ACK indicates the
50、 packet immediately following the acknowledged packet has been lost and should be retransmittedNew-Reno can recover multiple packets from a single window of data without a retransmission timeoutTCP Timer Management(a) Probability density of ACK arrival times in the data link layer. (b) Probability d
51、ensity of ACK arrival times for TCP.Retransmission Timer: Jacobson AlgorithmSolutionUse a dynamic algorithm that adjusts the timeout interval, based on continuous measurements of network performanceJacobsons AlgorithmM: How long the successful acknowledgement took: A smoothing factor, typically = 7/8. RTT: Estimate of the round-trip time RTT= RTT+(1-)MTimeout interval Timeout = RTT , Typically =2Enhanced Algorithm Problem: a constant value was inflexible because it failed to respond when
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2024购销合同模板
- 2024年字画装裱及展览服务协议
- 2025届高考生物一轮复习第1单元生命活动的调节第3讲通过激素的调节神经调节与体液调节的关系练习含解析新人教版必修3
- 2024-2025学年新教材高中政治第一单元探索世界与把握规律第二课第一框世界的物质性课后习题含解析部编版必修4
- 2024-2025学年高中数学第四讲用数学归纳法证明不等式二用数学归纳法证明不等式举例课时作业含解析新人教A版选修4-5
- 2024-2025年新教材高中生物第三章细胞的代谢第四节细胞呼吸为细胞生活提供能量3学案浙科版必修1
- 2024年工程材料供应与采购协议
- 2024年凉亭施工建设合同
- 网络应用测试服务合同
- 网球场连锁加盟合同
- 国开作业《公共部门人力资源管理》形考任务4:撰写课程学习总结(第1-9章权重25%)参考882
- 五星级酒店工程部标准化管理资料
- 晕厥护理查房(与“晕厥”相关共28张)课件
- 民族团结实践活动总结范文5篇
- 网店客服(第二版)整书电子教案完整版教学课件全套ppt教学教程最全课件最新
- 全国护士延续注册体检表-(正式)
- 小学校园污染防控管理制度
- 管理学-原理与方法(第七版)重点
- 危房封条格式
- (完整ppt)气候专题课件
- J-STD-020D[1].1中文版
评论
0/150
提交评论