[读书笔记]网络协议 —————— TCP/IP

原创 2006年06月08日 13:04:00

---------------------------------- IP ----------------------------------

IP protocol:

IP is the workhorse protocol of the TCP/IP protocol suite.  All TCP, UDP, ICMP and IGMP data gets transmitted as IP datagrams.  IP provideds an unreliable, connectionless datagram delivery service.

By unreliable we mean there are no guarantees that an IP datagram successfully gets to its destination.  IP provides a best effort service.  When something goes wrong, such as a router temporarily running out of buffers, IP has a simple error handling algorithm: throw away the datagram and try to send an ICMP message back to the source.  Any required reliability must be provided by the upper layers(e.g. TCP).

The term connectionless means that IP does not maintain any state information about grams.  This also means that IP datagrams can get delivered out of order.  If a source sends two consecutive datagrams(first A, then B) to the same destination, each is routed independently and can take different routes, with B arriving before A.


IP Routing

Host routing can be simple: the destination is either on a directly connected network, in which case the datagram is sent derectly to the destination, or a default router is chosen.

Hosts and routers have a routing table that is used for all routing decisions.  There are three types of routes in the table: host specific, network specific, and optional default routes.  There is a priority to the entries in a routing table.  A host route will be chosen over a network router, and a default route is used only when no other route exists to the destination. 

IP routing is done on a hop-by-hop basis.  The destination IP address never changes as the datagram proceeds through all the hops, but the encapsulation and destination link-layer address can change on each hop.  Most hosts and many routers use a default next-hop router for all nonlocal traffic. 

---------------------------------- TCP ----------------------------------

Even though TCP and UDP use the same network layer (IP), TCP provides a totally different service to the application layer than UDP does.  TCP provides a connection-oriented, reliable, byte stream service.

The term connection-oriented means the two applications using TCP (normally considered a client and a server) must establish a TCP connation with each other before they can exchange data.  The typical analogy is dialing a telephone number, waiting for the other party to answer the phone and say “hello,” and then saying who’s calling. 


TCP provides reliability by doing the following:

Ø         The application data is broken into what TCP considers the best sized chunks to send.  This is totally different from UDP, where each write by the application generates a UDP datagram of that size.  The unit of information passed by TCP to IP is called a segment.

Ø         When TCP sends a segment it maintains a timer, waiting for the other end to acknowledge reception of the segment.  If an acknowledgment isn’t received in time, the segment is retransmitted.

Ø         When TCP receives data from the other end of the connection, it sends an acknowledgment.  This acknowledgment is not sent immediately, but normally delayed a fraction of a second.

Ø         TCP maintains a checksum on its header and data.  This is an end-to-end checksum whose purpose is to detect any modification of the data in transit.  If a segment arrives with an invalid checksum, TCP discards it and doesn’t acknowledgment receiving it. (It expects the sender to time our and retransmit.)

Ø         Since TCP segments are transmitted as IP datagrams, and since IP datagrams can arrive out of order, TCP segments can arrive out of order.  A receiving TCP resequences the data if necessary, passing the received data in correct order to the application.

Ø         Since IP datagrams can get duplicated, a receiving TCP must discard duplicate data.

Ø         TCP also provides flow control.  Each end of a TCP connection has a finite amount of buffer space.  A receiving TCP only allows the other end to send as much data as the receiver has buffers for.  This prevents a fast host from taking all the buffers on a slower host.


A stream of 8-bit bytes is exchanged across the TCP connection between the two applications.  There are no record markers automatically inserted by TCP.  This is what we called a byte stream service.  If the application on one end writes 10 bytes, followed by a write of 20 bytes, followed by a write of 50 bytes, the application at the other end of the connection cannot tell what size the individual writes were.  The other end may read the 80 bytes in four reads of 20 bytes at a time.  One end puts a stream of bytes into TCP and the same, identical stream of bytes appears at the other end.

Also, TCP does not interpret the contents of the bytes at all.  TCP has no idea if the data bytes being exchanged are binary data, ASCII characters, EBCDIC characters, or whatever.  The interpretation of this byte stream is up to the applications on each end of the connection.


TCP provides a reliable, connection-oriented, byte stream, transport layer service.  TCP packetizes the user data into segments, sets a timeout any time it sends data, acknowledges data received by the other end, reorders out-of-order data, discards duplicate data, provides end-to-end flow control, and calculates and verifies a mandatory end-to-end checksum.

TCP is used by many of the popular applications, such as Telnet, Rlogin, FTP, and electronic mail (SMTP).



网络协议和网络编程例程 常用的网络编程---TCP/IP协议编程 1.几个重要概念: (1). 端口(Port)和套接口 端口正是我们要扫描的对象,具有“开”和“关”两种状态,利用它的开或关状...

tcp/ip详解卷1:协议 读书笔记 IP网络层

一、TCP、UDP、ICMP、IGMP数据都使用IP数据报格式传输,所以IP是TCP/IP协议族中最为核心的协议。   二、IP提供不可靠、无连接的数据报传输服务; 1)不可靠的意思是不能保证I...
  • wen0605
  • wen0605
  • 2013年06月07日 11:21
  • 811


以太网是一种局域网技术,以下是以太网的各种专业名字术语解析: 1、  各种网络缩写含义:10Base-5,第一个数字表示传输的速率,以Mpbs为单位,base表示基带,及最后一个数字表示传输距离,基...


IP:网际协议 IP是TCP/IP协议族中最为核心的协议,提供一种不可靠、无连接的数据报传送服务。所谓的不可靠指的是它不能保证IP数据报能成功地到达目的地。无连接是说IP并不维护任何关于后续数据...
  • ankwyq
  • ankwyq
  • 2012年05月07日 09:49
  • 638


基本概念: 计算机网络:物理链路将各个孤立的工作站或主机相连在一起组成数据链路,从而达到数据共享和通讯的目的。 按照媒介划分可以分为:有线网、光纤网、无线网 按照地域划分可以分成:广...


ICMP--Internet控制报文协议 ICMP被用来传递差错报文以及其他需要注意的信息,被认为是IP层的一个组成部分,通常被IP层或更高层协议使用,用来把差错报文返回给用回进程。其格式如下:...
  • ankwyq
  • ankwyq
  • 2012年05月14日 23:21
  • 774


ARP:地址解析协议 当一台主机把以太网数据帧发送到位于同一局域网上的另一台主机时,是根据 48 bit的以太网地址来确定目的接口的。设备驱动程序从不检查IP数据报中的目的I P地址。地址解析为...
  • ankwyq
  • ankwyq
  • 2012年05月07日 20:33
  • 499


第一章:概述 1.1 引言 1.2 分层 P1:TCP/IP通常被认为是一个四层协议系统 应用层 Telnet、FTP、email等 运输层 TCP和UDP 网络层 IP、ICMP、I...

TCP/IP详解卷1 读书笔记:HTTP协议

HTTP介绍   哑服务器,是指连接上服务器而不输入HTTP的8个命令,服务器不会响应任何信息。而一般的服务器,如FTP,连上之后会有一个欢迎信息。 HTTP服务器连上之后,不会有欢...
  • wwww4
  • wwww4
  • 2015年12月13日 22:34
  • 1069

TCP/IP详解卷1 读书笔记:第二十八章 SMTP和POP3协议

SMTP,发件,25号端口。POP3,收件,110号端口。   SMTP协议 --- 发件   先找别名,再根据别名查IP,然后发邮件。                ...
  • wwww4
  • wwww4
  • 2015年12月13日 21:15
  • 554
您举报文章:[读书笔记]网络协议 —————— TCP/IP