计算机网络chapter6传输层课件_第1页
计算机网络chapter6传输层课件_第2页
计算机网络chapter6传输层课件_第3页
计算机网络chapter6传输层课件_第4页
计算机网络chapter6传输层课件_第5页
已阅读5页,还剩100页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、The Transport Layer传输层Chapter 62022/7/251The Transport LayerThe task of the transport layer:To provide efficient, reliable, cost-effective data transport from source machine to the destination machine传输层的任务:为源端到目的端提供可靠、价格合理的数据传输26.1 The Transport ServiceServices Provided to the Upper LayersTransport

2、 Service PrimitivesBerkeley SocketsAn Example of Socket Programming: An Internet File Server36.1.1 Services Provided to the Upper LayersThe network, transport, and application layers.4Services Provided to the Upper Layers(2)最终目标为用户(应用进程)提供有效、可靠、价格合理的服务网络层、传输层和应用层传输服务类型:面向连接, 三个阶段:建立连接、数据传输和释放连接无连接OS

3、I模型划分为2大部分:1-4层:传输服务提供者(Transport service provider)5-7层:传输服务用户(Transport service user)56.1.2 Transport Service PrimitivesThe primitives for a simple transport service.传输服务与网络服务的区别网络服务不太可靠,而面向连接的传输服务则是可靠的服务对象不同网络层的数据交换比传输层复杂的多一个简单传输服务的原语: 6Transport Service Primitives (2)The nesting of TPDUs, packets

4、, and frames.传输协议数据TPDUTPDU,分组和帧的嵌套:7Transport Service Primitives (3)A state diagram for a simple connection management scheme. Transitions labeled in italics are caused by packet arrivals. The solid lines show the clients state sequence. The dashed lines show the servers state sequence. Disconnecti

5、on AsymmetricSymmetric86.1.3 Berkeley SocketsThe socket primitives for TCP. (注意这些系统调用所使用的参数)96.1.4 Socket Programming Example:Internet File ServerClient code using sockets.6-6-110Socket Programming Example:Internet File Server (2)Server code using sockets.116.2 Elements of Transport ProtocolsAddress

6、ingConnection EstablishmentConnection ReleaseFlow Control and BufferingMultiplexingCrash Recovery12Transport Protocol(a) Environment of the data link layer.(b) Environment of the transport layer.13Transport Protocol与数据链路层的差异两者都要解决:差错控制、分组顺序、流量控制等问题路由、目的地址连接建立过程子网的存储能力(数据缓冲、流量控制)数量上的差别146.2.1 Address

7、ingTSAPs, NSAPs and transport connections.Ports:end pointsTSAP:Transport Service Access PointNSAP:15Addressing(2)Name Server(Directory Server):用于查找TSAP地址地址空间层次型地址地址=如: +86,571,7952114平面型地址通过二级映射(如 DNS服务器)来定位机器166.2.2 Connection EstablishmentHow a user process in host 1 establishes a connection with

8、a time-of-day server in host 2.17Connection Establishment (2)一个复杂的过程:延迟的重复分组的干扰解决方法:废弃使用过的传输地址给每个连接分配一个连接标识符缺陷:每个传输实体长时间保存历史信息。如果系统崩溃,将造成信息丢失改进技术,删除在子网中“徘徊”的过时分组:将分组的生命周期限制在一个已知的最大值内:受限制的子网设计在每个分组内设计一个站段计数器为每个分组加上时间标记18Connection Establishment (3)(a) TPDUs may not enter the forbidden region.(b) The

9、resynchronization problem.基本思想:确保在同一时刻永远不会出现两个相同编号的TPDU19Connection Establishment (4)Three protocol scenarios for establishing a connection using a three-way handshake. CR denotes CONNECTION REQUEST. (a) Normal operation, (b) Old CONNECTION REQUEST appearing out of nowhere. (c) Duplicate CONNECTION

10、REQUEST and duplicate ACK.206.2.3 Connection ReleaseAbrupt disconnection with loss of data.终止连接的两种方法:非对称释放-可能导致丢失数据-see fig 6-12对称释放 适用于固定数量的数据发送,且知道何时完毕21Connection Release (2)The two-army problem:无论三次、四次的握手都不能圆满地解决问题22Connection Release (3)实际应用,三次握手-see fig 6-14并非绝对无误,但却令人满意三次握手的不足:第一个DR和所有N次的重发,最

11、终造成半连通的连接 协议失败消除半连通的办法:在一段时间内没有受到任何TPDU,便自动释放连接23Connection Release (4)Four protocol scenarios for releasing a connection. (a) Normal case of a three-way handshake. (b) final ACK lost.6-14, a, b24Connection Release (5)(c) Response lost. (d) Response lost and subsequent DRs lost.256.2.4 Flow Control

12、and Buffering*考虑连接在使用过程中的管理问题通过滑动窗口和其它机制数据缓冲的方法: -see fig 6-15固定大小可变大小循环缓冲区另一个可能的瓶颈:子网的运载容量26Flow Control and Buffering(2)(a) Chained fixed-size buffers. (b) Chained variable-sized buffers. (c) One large circular buffer per connection.27Flow Control and Buffering (3)Dynamic buffer allocation. The ar

13、rows show the direction of transmission. An ellipsis () indicates a lost TPDU.286.2.5 Multiplexing * (a) Upward multiplexing:考虑连接的费用问题 (b) Downward multiplexing:考虑连接的技术(带宽、可靠性)问题,以提高连接的带宽296.2.6 Crash Recovery *从网络和路由器中恢复如果网络层提供数据报服务,传输实体留有丢失的TPDU的副本如果网络层提供面向连接的服务,重建新的虚电路,重发丢失的TPDU从主机或服务器崩溃中恢复,存在着复杂

14、的问题-see fig 6-18结论:从第N层崩溃中恢复只能由第N+1层来完成,并且只能由第N+1层留有足够状态信息的情况下才能完成30Crash Recovery(2)Different combinations of client and server strategy.A:Acknowledgement, W: writing to the output process, C: crashing316.3 A Simple Transport Protocol *The Example Service PrimitivesThe Example Transport EntityThe E

15、xample as a Finite State Machine326.3.1 The Example Service Primitives5条原语Connum = LISTEN(local)Connum = CONNECT(local,remote)Status = SEND(connum,buffer,bytes)Status = RECEIVE(connum,buffer,bytes)Status = DISCONNECT(connum)336.3.2 The Example Transport EntityThe network layer packets used in our ex

16、ample.选用面向连接的网络服务与网络层的接口:to_net 和 from_net网络层分组类型-see fig 6-19网络层通过 enable_transport_layer 和 disable_transport_layer控制传输层对其调用34The Example Transport Entity (2)Each connection is in one of seven states:IDLE Connection not established yet.WAITING CONNECT has been executed, CALL REQUEST sent.QUEUED A C

17、ALL REQUEST has arrived; no LISTEN yet.ESTABLISHED The connection has been established.SENDING The user is waiting for permission to send a packet.RECEIVING A RECEIVE has been done.DISCONNECTING a DISCONNECT has been done locally.Main data structure: conn35The Example Transport Entity (3)36The Examp

18、le Transport Entity (4)37The Example Transport Entity (5)38The Example Transport Entity (6)39信用报文 (Credit Message)40The Example Transport Entity (8)41The Example Transport Entity (9)42The Example Transport Entity (10)436.3.3 The Example as a Finite State Machine(*)The example protocol as a finite st

19、ate machine. Each entry has an optional predicate, an optional action, and the new state. The tilde indicates that no major action is taken. An overbar above a predicate indicate the negation of the predicate. Blank entries correspond to impossible or invalid events.44The Example as a Finite State M

20、achine (2)The example protocol in graphical form. Transitions that leave the connection state unchanged have been omitted for simplicity.456.4 The Internet Transport Protocols: UDPIntroduction to UDPRemote Procedure CallThe Real-Time Transport Protocol466.4.1 Introduction to UDPThe UDP header.无连接的传输

21、协议UDP(User Data Protocol)发送封装的原始IP数据报发送时无需建立连接UDP数据段包括:8字节头+数据部分头格式-see fig 6-23476.4.2 Remote Procedure CallSteps in making a remote procedure call. The stubs are shaded. 486.4.3The Real-Time Transport ProtocolReal-time multimedia applications:Internet radioInternet telephony Music-on-demandVideoco

22、nferencingVideo-on-demandBasic function of RTP: Multiplex several real-time data streams onto a single stream of UDP packetsNo flow control, no error control, no acknowledgement and no retransmissionsTimestamping: to make multi-streams play back sychronously49The Real-Time Transport Protocol(2)(a) T

23、he position of RTP in the protocol stack. (b) Packet nesting.50The Real-Time Transport Protocol (3)The RTP header.51The Real-Time Transport Protocol (4)RTCP (Realtime Transport Control Protocol)Handle feedback, synchronization526.5 The Internet Transport Protocols: TCPIntroduction to TCPThe TCP Serv

24、ice ModelThe TCP ProtocolThe TCP Segment HeaderTCP Connection EstablishmentTCP Connection ReleaseTCP Connection Management ModelingTCP Transmission PolicyTCP Congestion ControlTCP Timer ManagementWireless TCP and UDPTransactional TCP536.5.1 Introduction to TCPTCPTransmission Control ProtocolProvide

25、a reliable end-to-end byte stream over an unreliable internetworkConnection-oriented Defined in RFC 793, 1122,1323Segment 64KB546.5.2 The TCP Service Model套接字(socket)地址:IP地址+端口(port, 16bits)Well-known port(通用端口)Port number 1024FTP: 21, Telnet: 23, SMTP: 25 TCP连接: 全双工、点到点、不支持广播、字节流TCP数据的缓存发送和立即发送(带PU

26、SH标志)紧急数据带URGENT标志55The TCP Service Model(2)Some assigned ports.记住常用的端口号!PortProtocolUse21FTPFile transfer23TelnetRemote login25SMTPE-mail69TFTPTrivial File Transfer Protocol79FingerLookup info about a user80HTTPWorld Wide Web110POP-3Remote e-mail access119NNTPUSENET news56The TCP Service Model (3)(

27、a) Four 512-byte segments sent as separate IP datagrams.(b) The 2048 bytes of data delivered to the application in a single READ CALL.576.5.4 The TCP Segment Header数据交换形式:数据段(segment)包含:20字节头+大小限制:Segment max size (65515 字节 and MTU)65535-20(IP Header)-20(TCP Header) = 65495 payloadTCP基本协议:滑动窗口协议尽管协议

28、简单、但要解决许多问题58The TCP Segment HeaderTCP Header.59The TCP Segment Header (2)Source port / Destination portSequence number Acknowledgment number The next byte expected, not the last byte correctly receivedHeader lengthHow many 32-bit wordsURG =1: Urgent pointer is in useACK =1: Acknowledgment number is

29、 validPSH =1: deliver the data to the application layer upon arrivalRST =1: to reset a connectionSYN =1: to establish a connectionSYN=1, ACK=0: CONNECTION REQUESTSYN=1, ACK=1: CONNECTION ACCEPTEDFIN =1: to release a connection60The TCP Segment Header (3)ChecksumInclude: Header, Data and Pseudoheader

30、The pseudoheader included in the TCP checksum.61The TCP Segment Header (4)OptionMaximum TCP payload willing to acceptDefault 536 bytes TCP segment:536+20=556Selective repeat transmission (instead of go back n protocol) Option: Windows scaleWindow sizeTells how many bytes (octets) may be sent626.5.5

31、TCP Connection Establishment(a) TCP connection establishment in the normal case.(b) Call collision.6-3163TCP Connection Establishment(2)建立连接:采用三次握手的方法服务器:执行LISTEN和ACCEPT原语客户端:执行CONNECT原语(SYN=1, ACK=0)两主机同时想在相同的套接字间建立连接,造成碰撞646.5.6 TCP Connection ReleaseThink of connections as a pair of simplex conne

32、ctionsEach simplex connection is released independently of its siblingWhen the FIN is acknowledged, that direction is shut down for new dataTo avoid two-army problem, timers are used 656.5.7 TCP Connection Management ModelingThe states used in the TCP connection management finite state machine.66TCP

33、 Connection Management Modeling (2)Event/actionEvent: A user-initiated system call( CONNECTION, LISTEN, SEND, CLOSE)A segment arrival(SYN, FIN, ACK, or RST)A case: a timeout of twice the maximum packet lifetimeAction:The sending of a control segment (SYN,FIN or RST)Nothing (-)67TCP Connection Manage

34、ment Modeling (3)TCP connection management finite state machine. The heavy solid line is the normal path for a client. The heavy dashed line is the normal path for a server. The light lines are unusual events. Each transition is labeled by the event causing it and the action resulting from it, separ

35、ated by a slash.(event/action)68TCP Connection Management Modeling (4)Event/Action (Comments)Event : a user initiated system call (CONNECT, LISTEN, SEND, or CLOSE)A segment arrival (SYN,FIN, ACK, or RST)A timeout of twice the maximum packet lifetimeAction: The sending of a control segment (SYN,FIN,

36、or RST) Nothing (indicated by “-”)69TCP Connection Management Modeling (5)分析:沿客户端的路径(粗实线)客户端应用发出CONNECT请求,本地TCP实体创建一个连接记录, 然后发送SYN数据段到服务器端 CONNECT/SYN (第一次握手) ,并标记为SYN SENT状态当SYN+ACK (SYN=1,ACK=1)数据段到达后, TCP实体发出最后一个ACK数据段SYN+ACK/ACK (第三次握手), 状态进入ESTABLISHED. 现在可开始数据发送和接收了.完成数据收发任务后, 客户端执行CLOSE原语, 使当

37、地TCP实体发送出FIN数据段CLOSE/FIN,并等待相应的ACK数据段(主动关闭),进入FIN WAIT1状态ACK到达后ACK/-,转移到FIN WAIT2状态, 连接在一个方向上断开了.另一方面也需要断开连接时,会发出FIN数据段,并得ACK确认FIN/ACK. 现在双方均已断开连接.TCP需要等待一个最大的分组生命期,确保该连接的所有分组全部消失(TIMED WAIT), 防止出现确认丢失, 此时已没有任何Event/Action了-/-当定时器超时后,进入CLOSED状态,TCP删除该连接记录, 回到起始70TCP Connection Management Modeling (6

38、)分析:沿服务端的路径(粗虚线)服务器执行LISTEN原语,并等待连接请求到来LISTEN/-. 状态:LISTEN一个SYN数据段到达后,将被确认 SYN/SYN+ACK(第二次握手),并且服务器进入SYN REVD状态当服务器发出的SYN也被确认ACK/-后,三次握手便完成了, 服务器进入ESTABLISHED状态, 现在可开始数据发送和接收了.客户端完成数据发送任务后,执行CLOSE原语, 发送一个FIN数据段到达服务器端. (被动关闭).服务器给出响应FIN/ACK后, 便进入CLOSE WAIT状态.服务器也执行CLOSE原语, 向客户端发出一个FIN CLOSE/FIN,进入LAS

39、T ACK状态收到客户端的确认后ACK/-,服务期便释放该连接, 进入CLSOED状态,删除连接记录716.5.8 TCP Transmission PolicyWindow management in TCP.通常,当滑动窗口win=0时,停止发送但有例外:Urgent data数据传输的最坏情况:Telnet每个输入字符需要162字节带宽并发送4个数据段72TCP Transmission Policy (2)Nagles algorithm:When data come into the sender one byte at a time, just send the first byt

40、e and buffer all the rest until the outstanding byte is acknowledgeTry to solve the problem caused by the sender delivering data to a byte at a time 73TCP Transmission Policy (3)Silly window syndrome(傻瓜窗口症状).74TCP Transmission Policy (4)Clark Solution (for silly window syndrome)Forced to wait until

41、it has a decent amount of space available and advertise that to senderTo solve the problem of the receiving application sucking the data up from TCP a byte at a time 756.5.9 TCP Congestion Control(a) A fast network feeding a low capacity receiver.(b) A slow network feeding a high-capacity receiver.7

42、6TCP Congestion Control (2)两个潜在的问题:网络的容量接收方的容量发送方需要保持的两个窗口:接收方承认的窗口拥塞窗口(Congestion Window)取上面两个基本点窗口的最小值作为可发送字节数拥塞窗口大小的获取:采用慢速启动(slow start)算法77TCP Congestion Control (3)An example of the Internet congestion algorithm.(congestion window size start from 1024bytes)786.5.10 TCP Timer Management重发定时器(Re

43、transmission Timer)超时间隔如何确定?数据链路层vs TCP中确认到达时间的概率超时时间间隔太短(T1)或太长(T2)都有问题79TCP Timer Management(2)(a) Probability density of ACK arrival times in the data link layer. (b) Probability density of ACK arrival times for TCP.80TCP Timer Management(3)解决办法:通过对网络性能的不断测定,采用一种不断调整超时时间间隔的动态算法(Jacobson,1988)原理:R

44、TT = RTT+(1-)M D = D + (1- )|RTT-M|超时值 = RTT + 4*D其中:M响应(ACK)时间, smoothing factor RTTRetransmission Timer简单建议:已重发的数据段无需修正其RTT,而是在失败后将超时时间加倍,直到传输成功。-(Karm算法)81TCP Timer Management(4)持续定时器(Persistence Timer)防止出现死锁“保活”定时器(Keepalive Timer)超时后检测对方是否仍然存在TIMED WAIT定时器设定为分组最长生命周期的两倍确保释放连接创建时申请的所有资源826.5.11

45、Wireless TCP and UDP原有的TCP实现都基于有线网,在无线网上可能性能极差主要问题:拥塞控制算法有线网:分组丢失时,放慢发送速度无线网:分组丢失时,尽快重发分组83Wireless TCP and UDP(2)解决办法:采用“间接TCP”将一个TCP连接分为两个连接-see fig 6-39优点:两个连接均为同质缺点:不符合TCP的定义对无线网上的UDP同样需要制定一套确保尽量可靠的解决方案84Wireless TCP and UDP(3)Splitting a TCP connection into two connections.856.5.12 Transactiona

46、l TCP(a) RPC using normal TCP.(b) RPC using T/TCP.86Transactional TCP(2)Clients first packet contains:SYN bitRequest FIN“I want to establish a connection, here is the data and I am done.”Server:Get the requestLook up or compute to form a replyFIN“I acknowledge your FIN, here is the answer, and I am

47、done”876.6 Performance Issues *Performance Problems in Computer NetworksNetwork Performance MeasurementSystem Design for Better PerformanceFast TPDU ProcessingProtocols for Gigabit Networks88Performance Issues(2)性能问题的复杂性性能下降却不知道为什么了解性能更像一门艺术,而不是一门科学涉及:网路层、传输层等术语“段”(segment) 传输层“分组”(packet) - 网络层“报文”

48、(message) - 应用层“帧”(frame) 数据链路层896.6.1 Performance Problems in Computer Networks拥塞资源组织不合理过载, 广播风暴(broadcast storm)UDP遭受广播风暴解决方法:主机不对广播方式的UDP错报做出响应适当地设置超时时限电源故障 RARP请求千兆级网络上使用原有协议-see fig 6-41带宽延迟乘积(bandwidth-delay product)结论:若想得到好的性能,接收窗口大小必须大于等于带宽延迟乘积。因为接收方不会马上作出响应90Performance Problems in Computer

49、 NetworksThe state of transmitting one megabit from San Diego to Boston(a) At t = 0, (b) After 500 sec, (c) After 20 msec, (d) after 40 msec.916.6.2 Network Performance MeasurementThe basic loop for improving network performance.Measure relevant network parameters, performance.Try to understand what is going on.Change one parameter.92Network Performance Measurement(2)改善性能的基本步骤(循环):测定相关的网络参数和性能尽

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论