本文是阅读《Understanding the TCP/IP protocol suite》 的读书笔记，文章来自Nassos Katsaounis在serverdensity上发布的博客。
- TCP/IP: Transmission Control Protocol/Internet Protocol
- Developed in the mid 1970’s and widely adopted in the early 1980’s, it has been the standard of computer networking for over 35 years.
- TCP/IP plays a particularly important role in two specific layers:
- In the Transport Layer, where correct delivery of data is ensured
- In the Network Layer, where the correct recipient is located
- This layer provides applications the ability to access the services of the other layers
- Defines the protocols that applications use to exchange data.
- This layer adds it’s own header and sends down to the Transport layer.
- Some of the popular protocols of this layer are :HTTP, FTP, SMTP, Telnet, NFS, RIP, etc.
- It is mainly responsible for providing the application layer with session and datagram communication services. 下层为上层提供服务
- This layer adds it’s own headers and sends down to the Network layer.
- ensure that all the split pieces arrive correctly at the other end.
- It is concerned with end-to-end transportation of data and setups up a logical connection between the hosts.数据端到端传输，建立主机间逻辑连接。
- There are two protocols available in this layer:TCP and UDP
- establishing reliable data exchange between applications.
- This ensures that data is not lost or misinterpreted along the way: TCP confirms that the message sent is the message actually received.
- open a channel of communication between the two computers.
- breaks the data into small units of information (“segments” or “packets”) as required, confirms correct delivery and reassembles them at the destination.
- The segments sent by the above layers are received here.
- send this segment of data to a destination host which could be anywhere ( in the same network or may be external network).
- It provides logical addressing, path determination for the segments to be sent and forwarding .
- This layer also adds it’s own headers and convert and send the received segments in form of packets.网络层以包的形式传递报文段
- Some of the popular protocols of this layer are :Internet Protocol (IP), ICMP, etc.
- send the data to the correct recipient.
- determines how data will find its intended destination through interconnected networks.
- dictates the roadmap that data will have to follow.
- ensures that all packets include the information necessary for each node to be able to forward them to the next.
- This layer defines the protocols and hardware required to connect a host to a physical network and to deliver data across it.
For delivery within a given physical network, packets are sent from the above layer to this layer.
The destination can be another host in the network, itself, or a router for further forwarding.
So the Network layer has a view of the entire Network whereas the Network Access layer is limited to the physical layer boundary that is often defined by a layer 3 device such as a router.
TCP is activated with every network request/response.For example:
- In an HTTP request,
- TCP takes over as soon as the browser knows where the request should be routed, i.e. after DNS resolution has been completed.
- Based on the socket provided (combination of IP address and server port), the request will reach the target computer and application through the network.
- The necessary communication channel will open up.
- data will be broken down to appropriately sized packets.
- Then, they will be sent over to the server.
- While the server handles the request and prepares the response accordingly, TCP makes sure that this particular connection channel remains open until the response reaches the source of the request successfully.
While moving data around, TCP/IP protocols annotate segments with extra information (headers) in order to be able to perform all the above tasks successfully. Headers include:
- information regarding the segment sequence number,
- a number (checksum) to allow confirmation of data validity
- information about sender and recipient.
This added information allows data to be segmented and transmitted as efficiently as possible, making sure it is correctly restructured at the destination, without worrying about structure during transportation. But it also plays an important role in the Three-Way Handshake.
- Unlike User Datagram Protocol (UDP), reliability is a top priority for TCP/IP. UDP serves as an alternative to TCP for different types of communication services where there is no time or need for confirmation that the correct message was successfully received by the intended party. An example of a case like that is a voice call over IP.
- But in most cases, such confirmation is absolutely necessary.
- To ensure reliability in communications, TCP establishes a verified connection between the client and the server computer before actual data is transmitted. This is done through the Three-Way Handshake using three segments (hence the “three-way”).
- C. SYN(seq:100) to S.
- SYN : Synchronization
- requests that the server synchronizes with the sequence numbers that the client will use.(seq:100)
- new sequence numbers are generated with every new transaction
- Client state changes to SYN-SENT
- S. ACK-SYN(ack:101,seq:200) to C.
- acknowledges (ACK) the request by confirming the Sequence Numbers sent by the client.(ack:101)
- requests synchronization (SYN) of the client’s Sequence Numbers with its(server) own.(seq:200)
- Server state changes to SYN-RECEVED
- C. ACK(ack:201,seq:101) to S.
- acknowledges (ACK) the Sequence Numbers sent by the server. (ack:201)
- Client state changes to EATABLISHED
- Server state changes to EATABLISHED
- Transmission is ready to begin.
Click here to read more about the Three-Way Handshake.
- TCP/IP comes with utilities that assist admins diagnose and understand problems in network performance.
- The most well-known of these utilities is probably Ping, that allows you to test whether your computer can open a communication channel with a certain host to exchange data, and how fast.
- In a way, Traceroute takes the Ping utility a few steps further.
- Data transmitted through networks almost always goes through intermediate nodes before reaching its destination.
Traceroute is especially designed to identify all the routers or other network devices (“hops”) between the source and the destination and measure the rate at which data is exchanged with each router. So the purpose of Traceroute is twofold:
- To determine the path to a destination, complete with intermediate stops
- To identify possible delay points in this path
Using specific switches, the Traceroute command can be configured with regard to maximum hops最大跃点数, timeouts for each reply, hostname resolution and other options.
- To read more about how to use Traceroute click here (for Windows) or here(for Linux).
to be continued….