青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

loop_in_codes

低調做技術__歡迎移步我的獨立博客 codemaro.com 微博 kevinlynx

TCP/IP Concepts 1


最近在草草地看<TCP/IP詳解>TCP那一部分,之所以草草地看是因為覺得早晚一天會回過頭去細看。手頭上
有工作要做,所以先草草地把之前隨便摘抄的TCP/IP相關概念貼出來:

繼續草草地貼:

--------------------------------------------------------------------------------------------------------------------------------------------------------
TCP segment:
Thus, we have simply “passed the buck” to TCP, which must take the stream from the application
and divide it into discrete messages for IP. These messages are called TCP segments.

On regular intervals, it forms segments to be transmitted using IP. The size of the segment is
controlled by two primary factors. The first issue is that there is an overall limit to the size
of a segment, chosen to prevent unnecessary fragmentation at the IP layer. This is governed by a
parameter called the maximum segment size (MSS), which is determined during connection establishment.
The second is that TCP is designed so that once a connection is set up, each of the devices tells the
other how much data it is ready to accept at any given time. If this is lower than the MSS value, a
smaller segment must be sent. This is part of the sliding window system described in the next topic.

Since TCP works with individual bytes of data rather than discrete messages, it must use an
identification scheme that works at the byte level to implement its data transmission and tracking
system. This is accomplished by assigning each byte TCP processes a sequence number.


Since applications send data to TCP as a stream of bytes and not prepackaged messages, each
application must use its own scheme to determine where one application data element ends and the
next begins.

--------------------------------------------------------------------------------------------------------------------------------------------------------

TCP MSS:
http://www.tcpipguide.com/free/t_TCPMaximumSegmentSizeMSSandRelationshiptoIPDatagra.htm

In addition to the dictates of the current window size, each TCP device also has associated
with it a ceiling on TCP size—a segment size that will never be exceeded regardless of how
 large the current window is. This is called the maximum segment size (MSS). When deciding
how much data to put into a segment, each device in the TCP connection will choose the amount
 based on the current window size, in conjunction with the various algorithms described in
the reliability section, but it will never be so large that the amount of data exceeds the
 MSS of the device to which it is sending.


Note: I need to point out that the name “maximum segment size” is in fact misleading. The
 value actually refers to the maximum amount of data that a segment can hold—it does not
include the TCP headers. So if the MSS is 100, the actual maximum segment size could be 120
(for a regular TCP header) or larger (if the segment includes TCP options).

This was computed by starting with the minimum MTU for IP networks of 576.

Devices can indicate that they wish to use a different MSS value from the default by including
a Maximum Segment Size option in the SYN message they use to establish a connection. Each
device in the connection may use a different MSS value.

--------------------------------------------------------------------------------------------------------------------------------------------------------

delayed ACK algorithm

http://tangentsoft.net/wskfaq/intermediate.html#delayed-ack

In a simpleminded implementation of TCP, every data packet that comes in is immediately acknowledged
 with an ACK packet. (ACKs help to provide the reliability TCP promises.)

In modern stacks, ACKs are delayed for a short time (up to 200ms, typically) for three reasons: a)
to avoid the silly window syndrome; b) to allow ACKs to piggyback on a reply frame if one is ready
to go when the stack decides to do the ACK; and c) to allow the stack to send one ACK for several
frames, if those frames arrive within the delay period.

The stack is only allowed to delay ACKs for up to 2 frames of data.


 

--------------------------------------------------------------------------------------------------------------------------------------------------------
Nagle algorithm:

Nagle's algorithm, named after John Nagle, is a means of improving the efficiency of TCP/IP networks by reducing the number of packets that need to be sent over the network.

Nagle's document, Congestion Control in IP/TCP Internetworks (RFC896) describes what he called the 'small packet problem', where an application repeatedly emits data in small chunks, frequently only 1 byte in size. Since TCP packets have a 40 byte header (20 bytes for TCP, 20 bytes for IPv4), this results in a 41 byte packet for 1 byte of useful information, a huge overhead. This situation often occurs in Telnet sessions, where most keypresses generate a single byte of data which is transmitted immediately. Worse, over slow links, many such packets can be in transit at the same time, potentially leading to congestion collapse.

Nagle's algorithm works by coalescing a number of small outgoing messages, and sending them all at once. Specifically, as long as there is a sent packet for which the sender has received no acknowledgment, the sender should keep buffering its output until it has a full packet's worth of output, so that output can be sent all at once.


[edit] Algorithm
if there is new data to send
  if the window size >= MSS and available data is >= MSS
    send complete MSS segment now
  else
    if there is unconfirmed data still in the pipe
      enqueue data in the buffer until an acknowledge is received
    else
      send data immediately
    end if
  end if
end if
where MSS = Maximum segment size

This algorithm interacts badly with TCP delayed acknowledgments, a feature introduced into TCP at roughly the same time in the early 1980s, but by a different group. With both algorithms enabled, applications which do two successive writes to a TCP connection, followed by a read, experience a constant delay of up to 500 milliseconds, the "ACK delay". For this reason, TCP implementations usually provide applications with an interface to disable the Nagle algorithm. This is typically called the TCP_NODELAY option. The first major application to run into this problem was the X Window System.

The tinygram problem and silly window syndrome are sometimes confused. The tinygram problem occurs when the window is almost empty. Silly window syndrome occurs when the window is almost full

===================================================================================================================================
3.17 - What is the Nagle algorithm?
The Nagle algorithm is an optimization to TCP that makes the stack wait until all data is acknowledged on the connection before it sends more data. The exception is that Nagle will not cause the stack to wait for an ACK if it has enough enqueued data that it can fill a network frame. (Without this exception, the Nagle algorithm would effectively disable TCP's sliding window algorithm.) For a full description of the Nagle algorithm, see RFC 896.

So, you ask, what's the purpose of the Nagle algorithm?

The ideal case in networking is that each program always sends a full frame of data with each call to send(). That maximizes the percentage of useful program data in a packet.

The basic TCP and IPv4 headers are 20 bytes each. The worst case protocol overhead percentage, therefore, is 40/41, or 98%. Since the maximum amount of data in an Ethernet frame is 1500 bytes, the best case protocol overhead percentage is 40/1500, less than 3%.

While the Nagle algorithm is causing the stack to wait for data to be ACKed by the remote peer, the local program can make more calls to send(). Because TCP is a stream protocol, it can coalesce the data in those send() calls into a single TCP packet, increasing the percentage of useful data.

Imagine a simple Telnet program: the bulk of a Telnet conversation consists of sending one character, and receiving an echo of that character back from the remote host. Without the Nagle algorithm, this results in TCP's worst case: one byte of user data wrapped in dozens of bytes of protocol overhead. With the Nagle algorithm enabled, the TCP stack won't send that one Telnet character out until the previous characters have all been acknowledged. By then, the user may well have typed another character or two, reducing the relative protocol overhead.

This simple optimization interacts with other features of the TCP protocol suite, too:

Most stacks implement the delayed ACK algorithm: this causes the remote stack to delay ACKs under certain circumstances, which allows the local stack a bit of time to "Nagle" some more bytes into a single packet.

The Nagle algorithm tends to improve the percentage of useful data in packets more on slow networks than on fast networks, because ACKs take longer to come back.

TCP allows an ACK packet to also contain data. If the local stack decides it needs to send out an ACK packet and the Nagle algorithm has caused data to build up in the output buffer, the enqueued data will go out along with the ACK packet.
The Nagle algorithm is on by default in Winsock, but it can be turned off on a per-socket basis with the TCP_NODELAY option of setsockopt(). This option should not be turned off except in a very few situations.

Beware of depending on the Nagle algorithm too heavily. send() is a kernel function, so every call to send() takes much more time than for a regular function call. Your application should coalesce its own data as much as is practical to minimize the number of calls to send().


--------------------------------------------------------------------------------------------------------------------------------------------------------

Sliding Window Acknowledgment System :
http://www.tcpipguide.com/free/t_TCPSlidingWindowAcknowledgmentSystemForDataTranspo.htm
--------------------------------------------------------------------------------------------
A basic technique for ensuring reliability in communications uses a rule that requires a
device to send back an acknowledgment each time it successfully receives a transmission.
If a transmission is not acknowledged after a period of time, it is retransmitted by its
sender. This system is called positive acknowledgment with retransmission (PAR). One
 drawback with this basic scheme is that the transmitter cannot send a second message
until the first has been acknowledged.
--------------------------------------------------------------------------------------------

http://www.ssfnet.org/Exchange/tcp/tcpTutorialNotes.html

The sliding window serves several purposes:
(1) it guarantees the reliable delivery of data
(2) it ensures that the data is delivered in order,
(3) it enforces flow control between the sender and the receiver.




------------------to be continued

posted on 2008-04-18 10:02 Kevin Lynx 閱讀(2372) 評論(1)  編輯 收藏 引用 所屬分類: game develop通用編程

評論

# re: TCP/IP Concepts 1[未登錄] 2008-04-18 10:05 cppexplore

果然夠草  回復  更多評論   

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            久久亚洲综合色一区二区三区| 久久久久在线| 亚洲人成亚洲人成在线观看图片| 国产精品久久一区主播| 国产亚洲欧美一区二区三区| 亚洲国产欧洲综合997久久| 日韩特黄影片| 久久成人免费电影| 亚洲丰满在线| 亚洲伊人观看| 欧美大秀在线观看| 国产精品在线看| 亚洲毛片播放| 久久在线91| 欧美久久久久| 亚洲第一在线| 欧美在线国产精品| 亚洲乱码国产乱码精品精98午夜| 午夜欧美大片免费观看| 欧美激情精品久久久久久变态| 怡红院精品视频在线观看极品| 亚洲男同1069视频| 亚洲精品视频在线观看网站| 国产美女一区| 亚洲理论在线观看| 狠狠v欧美v日韩v亚洲ⅴ| 欧美制服第一页| 欧美国产精品久久| 久久久www免费人成黑人精品| 亚洲永久精品大片| 亚洲黄网站在线观看| 午夜精品久久久久久久99热浪潮| 国产精品欧美一区二区三区奶水 | 欧美刺激午夜性久久久久久久| 亚洲综合国产精品| 亚洲素人一区二区| 欧美午夜精品久久久久久超碰| 日韩一区二区电影网| 欧美一区二区三区在| 精品999在线观看| 欧美sm视频| 蜜桃av久久久亚洲精品| 在线观看不卡| 欧美一区二区日韩一区二区| 亚洲婷婷综合色高清在线| 亚洲欧洲日韩综合二区| 欧美1区2区| 亚洲主播在线观看| 欧美高清成人| 亚洲国产成人午夜在线一区| 国内精品美女在线观看| 亚洲福利av| 1769国产精品| 久久久久久久综合| 免费观看在线综合色| 欧美黄污视频| 亚洲国产电影| 日韩午夜精品视频| 欧美精品在欧美一区二区少妇| 欧美激情亚洲| 国产精品久久波多野结衣| 久久不射网站| 国产日产欧产精品推荐色 | 国产欧美一区二区三区久久 | 欧美国产综合视频| 亚洲国产女人aaa毛片在线| 久久一区精品| 亚洲影视在线| 国产精品成人久久久久| 亚洲一区免费看| 欧美一区二区三区在线| 国产一区视频在线看| 久久激情视频| 亚洲一级在线| 女生裸体视频一区二区三区 | 中国亚洲黄色| 国产精品一区二区黑丝| 欧美诱惑福利视频| 亚洲在线一区二区| 国产精品一区二区在线观看| 欧美在线免费播放| 欧美国产综合一区二区| 亚洲视频免费观看| 国产欧美在线视频| 久久女同互慰一区二区三区| 最新精品在线| 欧美在线地址| 亚洲日韩成人| 午夜亚洲福利在线老司机| 你懂的亚洲视频| 亚洲视频图片小说| 国产真实久久| 欧美日韩国产丝袜另类| 美女精品视频一区| 在线亚洲成人| 欧美日韩视频一区二区三区| 亚洲二区精品| 欧美一区2区三区4区公司二百| 在线观看中文字幕亚洲| 国产精品xnxxcom| 另类av导航| 免费一级欧美在线大片| 中文一区二区| 在线观看视频一区| 国产精品九色蝌蚪自拍| 欧美阿v一级看视频| 午夜伦理片一区| 日韩网站在线看片你懂的| 日韩亚洲欧美成人一区| 国产一区二区三区网站| 欧美日韩中文字幕在线| 一区二区毛片| 亚洲一级特黄| 亚洲精品日本| 激情一区二区| 国产亚洲成人一区| 久久久蜜臀国产一区二区| 亚洲天堂成人在线观看| 亚洲国产人成综合网站| 中文成人激情娱乐网| 亚洲第一区在线| 国产视频一区三区| 国产精品黄视频| 欧美人与禽猛交乱配视频| 久久精品视频播放| 亚洲国产日韩欧美| 久久先锋影音| 久久久xxx| 久久精品日韩一区二区三区| 国产精品一区二区三区成人| 欧美日韩1区2区| 欧美激情视频在线免费观看 欧美视频免费一 | 亚洲精品123区| 黄色成人免费观看| 国产欧美精品一区二区三区介绍| 欧美日韩中文字幕在线| 欧美日韩综合视频| 欧美日韩国产精品专区 | 久久久久国产精品人| 欧美在线网址| 久久久久成人精品免费播放动漫| 欧美一区在线视频| 欧美一区二区三区在线看| 性欧美video另类hd性玩具| 亚洲免费在线观看视频| 久久亚洲影音av资源网| 狼人天天伊人久久| 亚洲视频在线观看三级| 亚洲私拍自拍| 欧美亚洲一区二区三区| 最新日韩在线视频| 国产喷白浆一区二区三区| 国产日韩综合| 亚洲国产精品女人久久久| 国产精品久久网| 国产啪精品视频| 尤物精品国产第一福利三区 | 国产一区av在线| 在线观看视频一区| 日韩午夜中文字幕| 亚洲欧美在线磁力| 日韩视频专区| 亚洲欧美美女| 蜜臀a∨国产成人精品| 亚洲国产欧美久久| 亚洲一级影院| 久久人人爽人人| 欧美日韩在线观看一区二区三区 | 日韩视频久久| 欧美一级片在线播放| 欧美大片在线观看一区二区| 久久精品在线| 亚洲国产精品成人一区二区 | 亚洲一区二区在线| 久久久蜜桃精品| 欧美性猛交xxxx乱大交蜜桃| 韩国精品久久久999| 在线视频你懂得一区| 久久久国产成人精品| 亚洲乱码久久| 久久久亚洲高清| 国产精品黄色| 亚洲区一区二| 久久亚洲私人国产精品va媚药| 亚洲人成网站色ww在线| 欧美在线视频一区二区| 欧美日韩性生活视频| 在线免费观看欧美| 欧美一区二区在线看| 日韩午夜中文字幕| 毛片基地黄久久久久久天堂| 国产精品中文字幕欧美| 一本色道久久综合亚洲精品高清| 亚洲激情在线播放| 久久精品首页| 亚洲性人人天天夜夜摸| 欧美精品午夜视频| 亚洲欧洲精品一区二区三区波多野1战4| 午夜精品久久久久久久久久久久久| 亚洲国产一区二区视频|