【转载】[基础知识]【网络编程】TCP/IP

转自http://mc.dfrobot.com.cn/forum.php?mod=viewthread&tid=27043

iooops 

胖友们楼主我又来发帖了……(最近无时不刻感受到身上穷得叮当响而且还感觉什么都不会当然这是不相干的内容哎)

今天晚上楼主刚学了一下TCP/IP协议。特来分享。

TCP/IP一般有4 Layers.

1. Application Layer

包括有HTTP(Hypertext Transfer Protocol), FTP(File Transfer Protocol), SMTP(Simple Mail Transfer Protocol), SNMP(Simple Network Management Protocol)等协议传输数据到Transport Layer。

2. Transport Layer

通常就是TCP和UDP了。
TCP可靠,会完整地传输数据,不会损失一分一毫。就是把数据分割成一个个小包,每次确保送到,发现没送到就重送。
UDP不可靠,有可能会丢包。

3. Network Layer

最常见的就是IP(Internet Protocol)了,负责在网络上传输数据的一层。

4. Data Link Layer

会涉及到device drivers in the OS and the network interface card attached to the system。
貌似和OS相关。楼主懵逼躺枪。



但楼主大概明白,从我们在浏览器里输入某个IP地址,到我们得到网页的内容,之间发生了什么。


就是这个样子的:




箭头正着来一遍。

再反着来一遍。







再来科普一下Socket是啥 = =。

所谓Socket,就是串口(Port)+对应的IP地址。
Client的(Port+IP) + Server的(Port+IP)组成一个four tuple, 就成了一个connection。

原文如下:

On a particular machine, a port number coupled with the IP address of the machine is known as a socket. A combination of IP and port on both client and server is known as four tuple. This four tuple uniquely identifies a connection. In this section we will discuss how port numbers are chosen.



嗯楼主大概梳理了一下。嗯感觉清晰多了。
(虽然貌似很多技术细节还是一脸懵逼。 = =。)





扩展阅读:
http://www.thegeekstuff.com/2011/11/tcp-ip-fundamentals
http://www.csd.uoc.gr/~hy556/material/tutorials/cs556-3rd-tutorial.pdf
https://www.saylor.org/site/wp-content/uploads/2012/02/Computer-Networking-Principles-Bonaventure-1-30-31-OTC1.pdf

原文地址:https://www.cnblogs.com/vectors07/p/7976488.html