[读书笔记]网络协议 —————— 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.

Summary

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、http、udp等网络协议 区别

tcp和udp协议是传输协议,ip是网络层协议、http是应用层协议 TCP三次握手四次拜拜 三次握手:又叫建立连接协议 (1)客户 端发送一个带SYN标志的TCP报文到服务器。这是三次握手过程...
  • yang3516793
  • yang3516793
  • 2016年07月27日 10:08
  • 1546

网络协议基础TCP/IP-http协议

一、网络协议 二、TCP(Transmission Control Protocol,传输控制协议) TCP头格式TCP协议中的三次握手和四次挥手TCP报文抓取工具 三、HTTP(H...
  • lijunchao1
  • lijunchao1
  • 2017年07月26日 20:16
  • 672

TCP/IP、Http等各层协议汇总表

TPC/IP协议是传输层协议,主要解决数据如何在网络中传输,而HTTP是应用层协议,主要解决如何包装数据。关于TCP/IP和HTTP协议的关系,网络有一段比较容易理解的介绍:“我们在传输数据时,可以只...
  • Scythe666
  • Scythe666
  • 2015年09月03日 14:58
  • 1228

TCP/IP网络协议的相关面试题

面试中常问到的TCP/IP相关知识点的通俗理解,此处就自己的理解列出四个供大家参考,谢谢!...
  • baigoocn
  • baigoocn
  • 2014年11月23日 20:41
  • 5928

《TCP/IP详解》读书笔记

1 TCP/IP概述 1.1 TCP/IP协议 通常所说的TCP/IP协议指的其实是“TCP/IP协议族”,是指包括TCP、IP等网络协议在内的众多网络协议的集合。TCP/IP协议也可以认为是对OSI...
  • a34140974
  • a34140974
  • 2016年12月21日 19:58
  • 823

10分钟理解TCP/IP各个协议以及协议之间的关系

理解TCP/IP各个协议以及协议之间的关系
  • Linux_ever
  • Linux_ever
  • 2016年04月12日 20:18
  • 27642

【TCP/IP系列1】TCP/IP经典书籍

《TCP/IP协议详解》三卷,第一卷特别经典,适合反复地看,对于几个基础的协议一定要非常清晰,比如IP、TCP、UDP、ICMP,一定记住每个协议所有字段细节,ping,traceroute 的工作原...
  • zongzhiyuan
  • zongzhiyuan
  • 2016年12月08日 12:54
  • 1537

《网络协议》TCP 协议

TCP 和 UDP 都使用相同的网络层 IP,但是与 UDP 不同的是,TCP 是面向连接的、可靠的字节流协议。因此,在传输数据之前通信双方必须建立一个 TCP 连接。TCP 通过检验和、序列号、确认...
  • chenhanzhun
  • chenhanzhun
  • 2014年11月29日 10:42
  • 2532

TCP/IP协议总结

TCP/IP中有两个重要的协议,传输层的TCP协议和互连网络层的IP协议,因此就拿这两个协议做代表,来命名整个协议族了,在说TCP/IP协议时,是指整个协议族。 TCP/IP协议族按照层次由上到下,层...
  • E_ROAD_BY_U
  • E_ROAD_BY_U
  • 2016年12月30日 10:15
  • 297

网络七层协议、TCP/IP、UDP、HTTP、Socket 个人理解

OSI是一个开放性的通信系统互连参考模型,他是一个定义得非常好的协议规范。OSI模型有7层结构,每层都可以有几个子层。 应用层 示例:TELNET,HTTP,FTP,NFS,SMTP等。 ...
  • ch1406285246
  • ch1406285246
  • 2017年02月17日 09:44
  • 1722
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:[读书笔记]网络协议 —————— TCP/IP
举报原因:
原因补充:

(最多只允许输入30个字)