Computer Network
The following content is about the basic knowledge of computer network.
Breif introduction
Such as smartphone, tv, safe system, car and so on.All of this are called host or end system. The end system is linked by communication link(通信链路) and packet switch(分组交换机).
Different communication links such as 电缆、光纤、无线电频谱 can spread the data with different speed. The transmission rate are measured by bit/s or bps.These message packet(信息包) are called packet(分组).
The packet seems like truck, all of the truck trans the goods to the destination by highspeed road. The communication links like the road, the packet like the truck, and the packet switch like the fork in the road, and the end system like the building.
The end system connect the Internet by ISP(Internet Service Provider).
The end system, packet switch and the other part of Internet are following a series of protocol(协议). These protocols control the internet message’s receive and send. Such as TCP(Transmission Control protocol,传输控制协议) and IP(Internet protocol,网际协议) are the most important protocols in the internet.IP protocol defines the rules of sending and receiving message winin router and end system.The main protocol of Internet is called TCP/IP.
A socket interface(套接字接口) refers to a programming interface that allows communication between different computer systems over a network. For example, you want to write a letter for your friend, you can’t just write the letter and throw it out of the window and think he/she can receive it. You need to put the letter into the envelop and write the full name, address, and postcode of your friend. Close the envelop and post a stamp and throw it into the post office. So all of these are the socket interface of postface, you need to obey it so that you can send your letter.
What is protocol?
Let’s begin at the human protocol. If you want to say hi to the other, you need to first say ‘hi’ and wait for his response. If he gives your certain response, you can continue say what your want. But if he does’t want to response you, you can’t continue your work.
Now look at the picture, you tap the web’s url. You computer send a connection request message to the Web server and wait for the respond. The Web server receives that and return a connection response message. Then the computer sends a GET message, declaring what it wants to fetch from the Web server.
So the protocol defines the message’s format and order between two or more than two communication entity, and sending or receiving a message or something else.
The media
A bit from a series of connection link and router can arrive at the other end system. Each send-receive couple send the electromagnetic and pulse through a physical media. Such as 双绞铜线,同轴电缆,多模光纤缆. The physical media has two types: the guided media and the unguided media. For the first one, The waves go along with the solid media like 光缆,双绞铜线或同轴电缆.For the other, the waves spread through air or outter space. Such as WLAN or digital satellite channels.
双绞铜线
同轴电缆
光纤
陆地无线电信道
卫星无线电信道
The kernel of network
In various network application, the end system(also called host) exchanges messgae to each other. The messgae can implement a control function or contain the data. For sending a message to the destination host, the source end system cuts the long message into the little data brick. This operation called packet. Every packet can be transmited by connection link or packet switch between the source and destination. The time of transmiting is the length of bits(R) dividing the rate of connection link(R). So the time is (L/R).
packet exchange
store and forward transmission
The queuing delay and packet loss
The forwarding table and routing protocol
The router gets the packet from a connection link linked to it, but how does it know where to trans the packet to the destination?
The Internet of Internet
Lots of ISPs connect with each other, the low-level ISP connect to the high ISP. Peer to Peer(对等,两个运营商传输和接收尽量相同的bits,不让对方赚钱)
IXP(Internet Exchange Point) is a meeting point, the peer ISP does’nt pay the extra fees.
多宿(别吊死在一棵树上):low-level ISP seeks for higher ISP to connect to make sure its capacity of connection. It can avoid the trouble caused by one of the ISP, it can use the other ISP.
Time Delay
We have four types of time delay.
dtotal = dproc + dqueue + dtrans + dprop
Five protocols
我说张三你是帅哥,张三的身体是主机,耳朵是端口,我选择只传输给张三一个人,然后选择走哪条路(连接层就是链路层),如果他在泰国人就可以飞机过去,在国内就火车过去,电信号就通过电缆过去,最后物理层传输。
Application layer
There are two types of appliication architectures, one is client-server architecture, and the other is P2P.
Client-server architecture
A forever-opening host is called server. It serves lots of other client hosts’ request. When the server receives the request for a objection form a client, it sends the objection back as the response. When we are in the client-server architecture, the client can’t communicate with the other client. Just like the two webserver can’t communicate with each other. The sever has a solid, well-known ip, and is forever-opening. So client can always send packets to the ip to communicate with it. In this system, the famous application includes the Web, FTP, Telnet and E-mail. In general, a single sever host can’t content all of the requests. So data center which has lots of hosts is used to create strong virtual server.
Process Communication
In operating system, actually communicaition is a process instead of application. The processes in two different end system send message to communicate through computer network. The sending message process generates and sends the message to the net. The receiving process receives the message, and maybe send the message back to response.
The client and sever process
The web applications consist of couple of process. In Web application, a client webserver process exchanges the message with the Web server process. For each group of communication process, a process is called client, and the other is called server.
The process’s interface of computer network
Process Find Address
If we want wo send a letter to the destination, the destination needs to have an address. A host’s process sends packet to another host’s process. We need to define two label: ①The address of host;②The destination host’s receiving process’s identifier.
Four factors of transmission serve
Transmission Layer Protocol
TCP / UDP
TCP和UDP之间的区别与联系:就像打电话和写信,你打电话能知道他是谁,打给谁,挂断之后即时有反馈,而写信在你寄出去的一瞬间你不能确保信是否会寄到他那里,以及什么时候才能寄到,信的内容是否完整(丢包)。UDP就是用于可以容忍一点点丢包,比如实时竞技游戏,视频通话。
三次握手
A:是B吗?我要跟你通信,听得到我说话吗?
B:可以通信,你听得到我说话吗?
A:我也听得到。
其实二次握手就可以建立链接,三次握手是为了互相确认对方的序列号,四次挥手是因为服务端有未发送完的数据。所以需要服务端连续发两次。同时客户端最后的等待也是为了确保服务端收到ASK请求finaskfin~ask,如果过了等待时间则认为服务端已经关闭(没有关闭的话会有ASK)
四次挥手
C:我困了,先不聊了吧
S:还有几件事,说完我们就睡觉……
……(说完之后)
S:好了,说完了,我挂线了
C:好,你挂吧
S挂断电话
C说完之后就直接睡觉了,不知道电话挂没挂断,在几分钟后听到手机没有声音传来了,即使不用睁眼也知道S挂断了
http
http(HyperText Transfer Protocol)
HTTP(超文本传输协议)是互联网上用来传递信息的一种规则。可以把它想象成一种通讯方式,它定义了如何发送和接收网页内容,比如文本、图片和视频等。想象一下,当你在网上浏览器里输入一个网址或点击一个链接时,你的浏览器就通过HTTP向网站的服务器发送一个请求,就像是在说:“嘿,我想看这个网页。”服务器收到这个请求后,如果网页可用,它就用同样的HTTP规则回应,发送网页的内容回来。简单来说,HTTP像是你和网站之间的对话规则,确保双方都能理解对方发送的消息。这就是你能够浏览网页和观看在线视频的原因之一。若想高效识别用户,引入了cookies,cookies就像门禁卡,我新建了一个房子,刚开始来的给一张卡刷进来,后面来的时候就拿着这张卡,网页就可以识别到你这个人做了什么。
链路层
链路层协议的任何设备均成为节点,节点包括主机、路由器、交换机、和WIFI接入点。
数据链路层有三个重要的问题:封装成帧、差错检测、可靠传输。
封装成帧
封装成帧是指数据链路层给上层交付的协议数据单元添加帧头和帧尾使之称为帧。