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

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>
            欧美在线欧美在线| 9色porny自拍视频一区二区| 久久国产精品亚洲77777| 亚洲国产欧美一区二区三区久久 | 久久激情一区| 国产尤物精品| 中日韩高清电影网| 午夜欧美理论片| 亚洲第一区在线| 亚洲精品国产精品国自产观看浪潮 | 99精品久久久| 欧美片网站免费| 午夜一区二区三视频在线观看| 欧美精品三级在线观看| 久久av二区| 亚洲一区免费| 国产精品乱码一区二三区小蝌蚪| 亚洲影院高清在线| 久久黄色级2电影| 一本到高清视频免费精品| 一区二区三区欧美激情| 国产欧美日韩综合一区在线播放| 久久精品男女| 欧美理论片在线观看| 性久久久久久久久久久久| 性欧美暴力猛交69hd| 中文国产一区| 欧美高清在线精品一区| 香蕉久久夜色精品| 欧美精品国产精品日韩精品| 久久中文在线| 亚洲电影免费在线观看| 欧美日韩综合视频网址| 在线观看欧美亚洲| 亚洲人成网站777色婷婷| 国产精品日韩一区二区| 亚洲毛片在线免费观看| 91久久精品美女高潮| 亚洲视频在线观看视频| 一区二区日韩精品| 欧美日韩精品一区二区| 亚洲美女色禁图| 日韩视频欧美视频| 欧美国产日本| 亚洲人久久久| 亚洲图片欧美一区| 国产精品mv在线观看| 99伊人成综合| 国产精品久久久久秋霞鲁丝| 亚洲激情在线观看| 在线视频精品一区| 欧美视频一区二区三区在线观看 | 欧美高清视频一区二区三区在线观看 | 欧美在线亚洲在线| 亚洲高清在线观看一区| 久久9热精品视频| 欧美成va人片在线观看| 亚洲激情在线视频| 欧美日韩高清区| 午夜精品在线| 日韩视频国产视频| 免费观看一区| 性色av一区二区三区红粉影视| 国产午夜精品理论片a级探花 | 欧美精品久久99| 久久综合五月天婷婷伊人| 欧美电影免费观看高清| 欧美四级在线观看| 国产一区二区三区四区五区美女 | 久久久91精品国产| 亚洲在线一区| 久久九九国产| 欧美不卡一卡二卡免费版| 久久免费视频网站| 久久精品中文| 久久精品视频导航| 久久久国际精品| 久久久久国产精品www| 亚洲男女自偷自拍| 午夜精品www| 亚洲综合日韩中文字幕v在线| 国产精品狠色婷| 欧美精品激情blacked18| 久久在线免费| 免费国产自线拍一欧美视频| 久久精品30| 欧美在线亚洲综合一区| 久久福利电影| 欧美一级淫片播放口| 校园激情久久| 久久久久久久网| 久久亚洲欧美| 免费欧美网站| 国产精品蜜臀在线观看| 最新高清无码专区| 亚洲欧洲一二三| 亚洲自拍16p| 久久久久久尹人网香蕉| 久久人91精品久久久久久不卡| 欧美高清成人| 欧美性猛交视频| 亚洲丰满在线| 新狼窝色av性久久久久久| 亚洲第一精品夜夜躁人人躁| 一本久道久久综合婷婷鲸鱼| 久久gogo国模啪啪人体图| 久久久久久久久久看片| 精品99一区二区三区| 欧美日韩一区二区免费在线观看| 日韩视频在线免费观看| 亚洲国产日韩一区| 欧美有码在线观看视频| 国产精品扒开腿做爽爽爽视频| 亚洲国产成人一区| 久久久久九九九九| 亚洲欧美日韩中文视频| 国产精品igao视频网网址不卡日韩| 亚洲在线观看免费视频| 鲁大师成人一区二区三区| 国产精品美女一区二区在线观看| 日韩亚洲一区二区| 久热精品在线| 久久综合成人精品亚洲另类欧美| 国产午夜精品理论片a级探花 | 亚洲人成免费| 久久精品国产一区二区三区| 欧美日韩中文字幕综合视频| 99精品福利视频| 91久久在线视频| 嫩草影视亚洲| 99香蕉国产精品偷在线观看| 亚洲欧洲另类国产综合| 欧美日韩美女在线观看| 亚洲视频在线观看视频| 在线亚洲观看| 一色屋精品视频在线看| 久热精品视频在线观看| 欧美成人在线免费视频| 日韩午夜在线视频| 亚洲午夜激情免费视频| 韩国免费一区| 亚洲精品一级| 国产中文一区| 日韩网站在线| 在线国产精品一区| 亚洲国产另类 国产精品国产免费| 欧美日韩一区二区免费在线观看 | 欧美激情五月| 久久国产精品电影| 欧美激情在线有限公司| 午夜精品久久久久久久久久久久久| 午夜精品理论片| 日韩午夜电影| 久久久噜噜噜久噜久久| 欧美在线看片a免费观看| 99精品99久久久久久宅男| 久久精品99无色码中文字幕| 亚洲美女区一区| 国内精品伊人久久久久av一坑| 蜜臀va亚洲va欧美va天堂| 精品电影在线观看| 免费国产一区二区| 亚洲国产精品悠悠久久琪琪| 国产精品夜色7777狼人| 欧美精品偷拍| 欧美成人亚洲| 久热精品视频在线免费观看| 午夜精品久久久久| 中文亚洲字幕| 一区二区三区久久精品| 最新亚洲视频| 欧美黄色成人网| 久久影院午夜片一区| 久久久久久一区| 久久全球大尺度高清视频| 久久久久久电影| 久久精品国产一区二区电影 | 国产精品v欧美精品v日韩| 欧美国产三级| 欧美精品少妇一区二区三区| 欧美国产一区二区| 欧美国产高清| 欧美精品国产一区| 欧美日韩在线观看一区二区三区| 欧美激情va永久在线播放| 牛牛精品成人免费视频| 欧美大片第1页| 欧美日韩高清一区| 国产精品不卡在线| 国产精品看片你懂得| 国产欧美在线看| 影音先锋中文字幕一区| 91久久精品美女| 9l视频自拍蝌蚪9l视频成人| 一区二区三区久久网| 亚洲欧美久久久久一区二区三区| 亚洲综合成人在线| 欧美一区二视频| 久久免费国产精品| 亚洲国产精品t66y|