Ad Hoc Networks TOPIC SIX-TCP and MANET TCP
- ARQ and Flow Control Protocols
- Transport Layer
- 一、TCP(Transmission Control Protocol)
- 二、UDP(User Datagram protocol)
- MANET TCP-Feedback(TCP-F)
- MANET TCP Buffering & Sequencing
- Summary
- 其他资料
正文:
ARQ and Flow Control Protocols
PDU(Packet Data Units)
– DATA:(来自应用层的)请求数据/确认信息
– PCI(protocol control information): header, checksum (CRC)
ARQ(Automatic Repeat Request)(4种)
• Stop-and-wait (Idle-Request)
• Continuous- Request
• Go-back-N
• Selective-retransmit (selective-acknowledgement)
Flow Control(2种)
Reliable Transport
- 全部数据
- 好数据
- 好的顺序
1. Idle Request
Tx:Transmitter
Rx:Receiver
ACK:Acknowledgement
-
流程:
Tx发送一个PDU(因为只发送一个所以没有顺序问题)到Rx,同时启动Timer,Rx收到后检查CRC,如果good:Rx返回ACK到Tx作为之前数据的确认。Timer过时后仍未收到回复,重新发送。 -
问题:
- Rx如何识别重复数据?—>PDU附带一位序列号SN(sequence numbers)(new/re)
- Tx如何识别old ACK:Tx的Timer很短,没收到ACK就过时了,因此Tx重新发送,Tx将迟到的ACK当作对此次重发的回应。—>ACK附带一位序列号(new/re)
SN modulus 2:0,1,0,1,…
SN modulus 6:0,1,2,3,4,5,0,1,2,3,…
2. Continuous Request
增加信道利用率(Channel utilization)
以前(Idle Request)
现在
- pipelining
- Capacity of “pipe”: data-rate * RTT(Round Trip Time,PDU+ACK来回的时间)
- 问题
TX produces data faster than Rx can process it?—>使用发送窗口与接收窗口
Re-transmission strategies
– go-back-N
– selective re-transmission
1. Go-back-N
一旦没收到或收到坏PDU,停止返回ACK,直到重新接收
Rx省去了buffer,但是造成传输浪费(重新发送lost/corrupt后的所有数据)
要求modulus>window
只要在window内,收到什么都是可接受的?(无论顺序?)
如果modulus = window,发生ACK lost后,Tx等待第一个ACK3(此时window不移动),直到timer过时,重发3;Rx将Tx重发的3当作了第二个3(Rx正好在等待3)
modulus>window,Rx等待(window:4,1,2),但收到了重传的3,意识到是重传数据,返回ACK,Tx的window前进
2. Pure Selective Re-transmission
即使PDU lost,Rx仍然发送后续ACK并等待重传。TX在ACK中看到“洞”,在timer过时后尝试修复洞。RX在交付数据之前等待丢失的PDU(洞后的数据暂存在Rx的缓存中)
减少Tx重发的代价–>增加了ACK的次数
3. Selective Re-transmission Variation
一旦没收到或收到坏PDU(此例为2),停止返回ACK,洞后的数据暂存在Rx的缓存中并“累加”,当2、3、4、5的timer陆续过时后Tx重发,Rx收到2后返回ACK5,表示已收到5及以前的数据,Tx收到ACK后停止重发
要求m>2W-1:
假设序号最大为7即0,1,2,3,4,5,6,7,发送窗口大小为5,当发送窗口发送0,1,2,3,4后,假设接收窗口全部收到,则接收窗口向前移动到5次,接受窗口期望接收5,6,7,0,1;若发送窗口并没接收到任何ACK,所以发送窗口重发0,1,2,3,4此时接收窗口会以为重发的0,1是新的分组。
- 问题
严重延迟PDU:
解决办法:给PDU设置TTL
Full Duplex Service
Flow control
Stop / Go
- Rx controls Tx PDU rate
- RNR: Receiver Not Ready(Tx收到后停止发送,直到收到RR)
- RR: Receiver Ready
- HWM:
– “high” threshold send RNR - LWM:
– “low” threshold send RR
• HWM: set low for safety(给RNR足够的时间到达Tx),因为如果RNR loss: RX overrun
Sliding Window
- Rx发送ACK改变Tx的window size
– reduce window to 1: stop-and-wait
– other window sizes allow selective re-transmit - ACK from Rx contains:
– SN for data to be acknowledged (A)
– window size for Tx to use (W)
Transport Layer
Router工作在网络层,Bridge工作在链路层
传输层提供end-to-end应用服务,host作为Tx和Rx可以读取传输层报表
数据传输经过很多物理层,传输层提供虚拟的端到端链接
传输层负责end-to-end flow control
在网络层报表表头才有源和目标的信息,以此才能正确发送数据
TCP/IP Implementation Hierarchy
IP Header
Socket
IP Address + Port Number
Port Number
在传输层报表头中,表明应用层使用了何种协议,以发送给正确的应用
一、TCP(Transmission Control Protocol)
• Connection Oriented Protocol
• Provides reliable End-to-End transmission of transport level
• Segments delivered in order by using sequence numbers
• Retransmission to resend corrupted or lost packets
• Flow Control
• Congestion Control
• Byte-stream service
• Error Detection
TCP Segment Format
virtual path:不关心网络层等,只关心终端系统(end system)
源端口,目标端口:所有传输层协议都有
SN:第一个随便选,后面的按顺序来。每个byte一个SN,选择第一个byte的SN作为当前段的SN
Acknowledgment Number:预料中的下一个段的SN
flag | meaning | 拉拉 |
---|---|---|
URG | check urgent ptr field | 1代表header中的urgent pointer有意义 |
ACK | check ack num field | 1代表接收方应该注意它 |
PSH | push | 1代表必须发送,无论大小 |
RST | reset | 1中止连接并重置 |
SYN | synchronise seq num | 1代表当前段为初始段,构建连接 |
FIN | no more data | 1代表当前段为最后段,结束连接 |
Window:Flow control
Checksum:CRC
Urgent Pointer:指向段中的紧急部分,要求先执行
Features of TCP
• Byte-stream transmission service using full-duplex buffered communication
• Connection-Oriented using 3-way hand-shake to sequence S/N in both directions
• A sliding window mechanism for both reliability through positive acknowledgement retransmission and flow control to prevent receive buffer overrun and to offset transitory network congestion.
• Congestion control
• Flags
Byte-Stream Oriented
发送端缓冲:已读入未发送,已发送未确认,空闲
接收端缓冲:已读入未提取,空闲
三个control
• Flow Control: Algorithms to prevent that the sender overruns the capacity of the receiver
• Congestion Control: Algorithms to prevent that the sender overloads the network
• Error Control: Algorithms to recover or conceal the effects from packet losses
三次握手,四次那个
-
A建立到B的连接
B在回复ACK的同时,建立B到A的连接
-
A结束发送,B过一会结束
-
Tx有big window
检查header,然后CRC,如果good,返回ACK
问题1:如果段lost
Rx出现洞,继续接收并返回ACK,将接下来的所有ACK( duplicate acknowledgements)的SN设为洞的SN,尝试修复洞
如果同时lost两个?
问题2:800段比700段先到达(B视角)
问题3:700段lost(A视角 )
Tx发出段,同时启动timer,在timer过时前收到ACK,段将从window中移除。没有收到ACK前,将一直保存在缓存中
700段timer过时后,Tx重传
Summary
TCP Header
TCP Numbering
TCP Positive Acks
• The number of segments that can be in-transit at any point in time is governed by a sliding window flow control mechanism. The “width” of the window is set by the effective window parameter
• Each transmitted segment carries the sequence number of the first byte of data held within that segment.
• Assuming the segments are received in order, the destination returns an acknowledgement to the originator containing an acknowledgement number set to the sequence number of the last contiguous byte received plus one
• If segments are received out of sequence, the acknowledgement number returned will remain at the same value for subsequent acknowledgements until the complete sequence is received. This gives rise to duplicate acknowledgements
Sliding Window
应用于Tx
- Byte-Stream Oriented
- SN for each byte
implement in software
三个指针
如何设置window size:
effective window size = min(congestion window, advertised window)
advertised window:Flow control,反映Rx的剩余缓存空间,可能导致SWS。来源于Rx将自己的缓存信息写入TCP Header的window field。
congestion window:Congestion Control,反映了网络状况。传统TCP中,发送者没有收到ACK,TCP operator会认为网络繁忙(Congestion)
Congestion Control
三个phase
- SS(Slow Start):从1 开始,每轮指数增加,直到到达预设阈值
- AI(Addictive Increase):线性增一,直到出现data lost(Congestion )
- MD(Multiplicative Decrease):Time out(SS)或 3ACK(AI)触发
- TCP Tahoe:发生Time out(No ACK),重设window size为1,新阈值设为CwndMAX(Congestion 发生时的window size)的一半,进入SS。
- TCP RENO:当timer过时前连续收到三个同样的ACK(RX出现洞),也认为是Congestion ,通过MD进入AI,重设阈值为CwndMAX/ 2,重设Cwnd到阈值。
与TCP Tahoe相比,TCP RENO-Fast Retransmit/Fast Recovery
发生data lost/ACK lost时的timer
期望设置timer接近真实RRT(Round-Trip Time)
监视每次的RRT以修正SRTT。
RTO(Retransmission Time-Out)
比SRTT长一点
另外:
Karn’s algorithm
removes ambiguities – ignore retransmitted segments
问题一:RTO过小
ACK在timer过时后重传到达前抵达Tx,导致RTO过小
问题二:RTO过大
ACK在timer过时后重传到达后,重传的ACK抵达Tx后才到达Tx,导致RTO过大
Silly Window Syndrome(SWS)
data byte过小,传输的大多是强制的Header byte。由于Rx建议过小的空闲缓存,或Tx传输过慢。
什么时候发送者可以发小段:
- 可以形成最大段(IP header中规定了data上线,64Kbytes)
- 所有已发送未确认段最终被确认(ACK’d),可以传小段
- Rx有至少一半的空闲缓存
接收者方面:
- 更新将打开窗口至少50%的最大缓冲区大小,或足以容纳一个最大大小的段。
Summary of TCP Operation
• Employs sliding window to improve performance.
• Sets up connection before any data exchange.
• Clears down connection after finishing communication.
• Segment header contains source port, destination port, sequence number, ACK number = next sequence number expected to be received, space for actual data and flags.
• Most important flags are SYN, ACK and FIN (SYN used in connection set-up and FIN terminates opened connection
二、UDP(User Datagram protocol)
传输时才建立连接
非可靠
注重速度
header
有线网络异常通常由拥堵(congestion)导致
无限网络由移动(mobility)导致
自组织网络是高阻塞网络
TCP没有辨认阻塞和路由失败
MANET TCP-Feedback(TCP-F)
Snooze state :to avoid the timeout coming from route reconstruction delay
RFN&RRN
- upstream node (pivoting node) 发现连接中断,发送RFN(Route Failure Notification) back to SRC
- 当SRC收到RFN message,进入SNOOZE state and
- stops transmitting data
- freezes all its timers related to TCP such as retransmission timer
- pivoting node 发送 RRN(Route Re-establishment Notification) 给SRC,通知它成功的路线重新配置。 因此,恢复传输并恢复所有timer和状态变量值(Cwnd size,ssthreshold,RTT estimate)
目标
- 识别link failure:RFN(Route Failure Notification)/ RRN(Route Re-establishment Notification)
- what to do:freeze and stop
问题
- 重新建立连接后,timer和之前的参数可能不适用于新的连接。
- RFN lost/RRN lost
MANET TCP Buffering & Sequencing
TCP-F升级版:
• Explicit Notifications: It is used to differentiate between network congestion and route failure.
• Reliable Transmission of Control Messages
• Buffering.
• Extension of Timeout Values.
• Selective Fast Retransmission.
1. Reliable Transmission of Control Messages
ERDN&ERRN
- ERDN (Explicit Route Disconnection Notification):传输层。由pivoting node生成,发送到TCP sender,后者进入Snooze State
- ERRN (Explicit Route Reconstruction Notification):重新建立连接后由pivoting node生成,发送到TCP sender,后者离开Snooze State,回到ESTABLISHED State,恢复timer,重新开始传输
ERDN loss
IN啥时候重传ERDN?
哪一个IN重传?
ERDN_RET_TIMER记录的是什么
ERRN loss
- 手段1-Source Probe:在接收到ERDN后,SRC周期性地发送探针消息,以检查pivoting node是否成功地获得了到DEST的新的部分路由。
- 手段2-ERRN重传:IN的ERRN_RET_TIMER过期后(没有收到对于ERRN的确认),IN将重传ERRN。
2. Buffering
IN什么情况下记录buffer
什么情况下清除Buffer
连接重新建立后,TCP Receiver返回最后收到的数据段的ACK,pivoting node将ACK和自己缓存中的第一条数据段与ERRN一起发送给TCP sender
3. Selective Fast Retransmission
TCP sender根据接收方的反馈恢复传输。INs从其缓冲区恢复传输。
【1,2成功,3丢失(N3不在连接之中)】
4. Extension of Timeout Values
在RRC完成后,缓冲段在传输中(in-transit)。 超时值必须在SRC和路径上的节点上扩展到pivoting node,以考虑路由更改引起的延迟。扩展时间允许传输段在没有超时的情况下到达目的地。 一般修改后的超时值加倍,但这也取决于其他因素。
Summary
• Address reliable transmission of control messages for route failure notification.
• Overcome the need for fast retransmission after a route failure.
• Extend timeout value to prevent unwanted retransmissions.
• Enhanced flow control via buffering and buffer status reporting schemes.
• Enhance TCP throughput