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

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>
            亚洲视频观看| 亚洲少妇自拍| 免费看黄裸体一级大秀欧美| 加勒比av一区二区| 欧美国产日韩免费| 欧美刺激午夜性久久久久久久| 亚洲精品视频中文字幕| 亚洲精品国产拍免费91在线| 欧美视频一二三区| 久久国产精品久久久久久| 久久久夜夜夜| 夜夜爽av福利精品导航| 在线中文字幕不卡| 精品1区2区3区4区| 亚洲三级性片| 国产日韩亚洲欧美| 亚洲国产精品电影| 国产精品免费一区二区三区观看| 久久免费视频网站| 欧美精品色综合| 久久久99国产精品免费| 欧美a级片一区| 先锋a资源在线看亚洲| 久久露脸国产精品| 亚洲综合第一| 免费看黄裸体一级大秀欧美| 欧美亚洲系列| 欧美激情精品久久久| 久久精品国产免费看久久精品| 欧美成人精品在线| 久久激情五月丁香伊人| 欧美日韩精品| 乱码第一页成人| 国产精品色网| 亚洲精品国产品国语在线app| 国产自产女人91一区在线观看| 最近看过的日韩成人| 黄色精品免费| 午夜精品电影| 亚洲自拍都市欧美小说| 欧美高清不卡| 欧美高清hd18日本| 国产一区二区三区丝袜| 在线亚洲一区观看| 99国产麻豆精品| 玖玖国产精品视频| 久久一区欧美| 国产一区二区你懂的| 亚洲综合大片69999| 亚洲视频在线免费观看| 欧美大片免费观看在线观看网站推荐| 久久久欧美精品| 国产午夜久久久久| 午夜欧美精品久久久久久久| 亚洲影院免费| 国产精品电影在线观看| 日韩亚洲欧美成人| 亚洲色在线视频| 欧美日韩三级电影在线| 日韩视频免费观看| 制服丝袜亚洲播放| 国产精品成人免费精品自在线观看| 亚洲国产mv| 亚洲精品视频在线播放| 欧美高清在线观看| 亚洲精品国产系列| 一区二区日韩欧美| 欧美性猛交xxxx乱大交退制版| 99国产精品久久久久久久久久| 一卡二卡3卡四卡高清精品视频| 欧美高清在线视频| 亚洲作爱视频| 午夜精品网站| 国产一区二区三区四区老人| 久久精品国产精品亚洲精品| 免费高清在线一区| 亚洲国产精品一区| 欧美精品一区二区三区久久久竹菊| 亚洲精品在线三区| 亚洲永久字幕| 黄色成人av网站| 欧美va天堂va视频va在线| 亚洲精品在线观| 久久av最新网址| 亚洲国产成人精品久久久国产成人一区 | 欧美日韩激情小视频| 亚洲精品国产精品国自产观看浪潮| 老牛影视一区二区三区| 国产精品99久久久久久久vr| 亚洲伊人久久综合| 国产一区二区三区在线观看免费视频| 久久久精品久久久久| 亚洲日本va午夜在线影院| 亚洲欧美国产77777| 韩日精品视频一区| 欧美日韩国产在线| 久久久精品国产免大香伊| 亚洲靠逼com| 久久视频精品在线| 99精品久久久| 国产一区二区三区最好精华液| 欧美xxx成人| 欧美一级大片在线免费观看| 亚洲国产高潮在线观看| 久久狠狠婷婷| 一区二区日本视频| 伊伊综合在线| 国产精品一区二区三区久久久| 免费成人黄色片| 亚洲欧美日韩综合aⅴ视频| 欧美激情一区二区三区不卡| 亚洲欧美日韩中文在线制服| 亚洲激情视频网站| 国产一区二区三区观看 | 亚洲午夜久久久| 亚洲电影自拍| 久久尤物电影视频在线观看| 亚洲免费人成在线视频观看| 亚洲国产精品久久久久婷婷老年| 国产精品最新自拍| 欧美日韩美女一区二区| 欧美gay视频激情| 久久精品国产欧美亚洲人人爽| 亚洲天堂av图片| 日韩午夜激情电影| 亚洲欧洲精品一区二区三区波多野1战4| 久久狠狠亚洲综合| 亚洲中午字幕| 亚洲视频每日更新| 99这里有精品| 日韩一级欧洲| 日韩五码在线| 91久久精品www人人做人人爽| 黄色亚洲在线| 精品成人一区二区| 狠狠久久亚洲欧美| 尤物yw午夜国产精品视频| 国产午夜精品久久久久久久| 国产精自产拍久久久久久| 国产精品久久久久久av下载红粉| 欧美精品色综合| 欧美日韩精品一区二区天天拍小说| 欧美电影在线免费观看网站 | 欧美成人亚洲成人日韩成人| 久久综合伊人| 欧美777四色影视在线| 免费国产一区二区| 欧美激情精品久久久久久大尺度 | 久久精品人人做人人爽| 久久精品成人欧美大片古装| 欧美在线一级视频| 久热爱精品视频线路一| 欧美成人精品一区二区三区| 欧美大秀在线观看| 亚洲欧洲免费视频| 一本色道久久综合亚洲精品按摩| 中文精品视频| 欧美在线黄色| 欧美freesex8一10精品| 欧美人妖另类| 国产精品永久入口久久久| 国产亚洲欧美另类一区二区三区| 伊人色综合久久天天| 亚洲精品国久久99热| 亚洲午夜一二三区视频| 欧美一区二区久久久| 免费观看一区| 99精品热6080yy久久| 西瓜成人精品人成网站| 巨乳诱惑日韩免费av| 欧美调教vk| 好吊视频一区二区三区四区| 亚洲人久久久| 欧美亚洲综合久久| 欧美激情区在线播放| 亚洲天堂免费观看| 久久亚洲春色中文字幕| 欧美日韩精品三区| 激情综合色丁香一区二区| 99精品99| 女人香蕉久久**毛片精品| 一区二区三区欧美| 狂野欧美激情性xxxx欧美| 国产精品久久久久久久久免费樱桃 | 国产精品久久久久久久app| 娇妻被交换粗又大又硬视频欧美| 中日韩高清电影网| 久热精品在线| 亚洲永久网站| 欧美精品一区二区三区四区 | 欧美二区乱c少妇| 国产在线日韩| 亚洲欧美日韩一区二区在线| 亚洲第一区中文99精品| 欧美在线一二三区| 国产精品久久97| 99av国产精品欲麻豆| 欧美freesex8一10精品| 小黄鸭视频精品导航| 欧美视频在线观看一区|