tcpip protocol

  Several concepts

1. stratified (we use four-layer model more fitting our actual network)

Layering is why, in fact, the company and position is the same, different jobs people do different things, and different positions of the people together, complete with the matter of data transmission.

Link layer  At this level, the interaction of the host with the host hardware mac only recognize numbers, did not know IP.

The network layer IP ICMP IGMP

Transport layer TCP UDP

Application Layer Telnet remote login, the FTP file transfer protocol (our ports and connectors that port is used to doing, to transfer files? You can use FTP. Transmission of text? You can use HTTP. The application layer is actually a specific program the interaction between the functional layer is defined.)

 2.   Interface Each interface on the Internet must have a unique IP address

Using TCP / IP protocol application usually two application programming interface ( the API ):

socket and the TLI (Transport Layer Interface: Transport Layer Interface ).

3. Package TCP passed IP data unit called TCP packets referred to as TCP segment or segments (TCP segment ). 

 IP passed to the network interface layer data units called IP datagrams (IP Datagram) . By comparing the Ethernet transmission Laid called a frame (Fr ame) stream .

 

 

 IP : Network Protocol

I. Basic Concepts

 

All TCP , UDP , ICMP and IGMP data to IP transport datagram format . IP to each machine is like a house number, the network layer of the network, you can understand it as the mail transport workers, its function is responsible for a packet transport from the house to another house.

 

Unreliable (Unreliable ) mean it can not guarantee the IP datagram can successfully reach their destinations. If some error occurs, such as a router runs out of buffer temporarily, the IP has a simple error processing algorithm: discard the packet and send ICMP message packet to the source terminal. Any required reliability must be provided by an upper layer (e.g., the TCP ).

 

Connectionless   IP data packets in the transmitted sequence may not be received. If a source to a same transmission data sink two consecutive packets (first A , then B ), each datagram is routed independently selected, may choose a different route, so B may be A first before reaching Arrivals.

. Multiple Access protocol:

 

A) ALOHA protocol: pure ALOHA protocol and slotted ALOHA protocol

 

b) Protocol carrier sense multiple access (CSMA): 1- stick type CSMA, comes in handy stick type CSMA, p- stick type CSMA,

 

  CSMA with Collision Detection (CSMA / CD)
  CSMA / CA (Collision Avoidance CSMA protocol): Send ⽅ to stimulate short RTS frame, CTS sent a short frame after receiving ⽅ received, the receiving ⽅ around the site to remain silent during transmission to avoid conflict

 

But there are also connection-oriented virtual circuit and connectionless packet.

II. Routing algorithm

There is also a corresponding adaptive algorithm on the network and a non-adaptive algorithm (static routes, reliability) (dynamic routing, network routing table according to the refresh state).

( The Dijkstra shortest path algorithm, distance vector algorithm DistanceVector, link state algorithm )

⽹ off internal routing protocol (IGP, also called domain routing protocol):

 

a) Routing Information Protocol (RIP): the amount of from ⽮ algorithm, Bellman-ford algorithm e.g.

 

b) Open Shortest Path First Protocol (OSBF): link-state algorithms such as Dijkstra's algorithm
 
III. Network Interface

 

IPv4 header format:

 

a) Version number: 4bit, IPv4 fill 4             B) of the header ⻓: 4bit, in units of 4 bytes, range 5-15, default value 5

 

c) Service types (the TOS): 8bit, 0           D) Total ⻓ degree: 16bit, in bytes, the total ⻓ described IP packet, including header and data, is largest 65535 bytes,

 

e) Identifier: 16bit, CD ⼀ Use in Identification Packet        f) mark: 3bit, bit 1 is undefined, the second bit is 0 DF represents the segment, bit 3 MF 1 represents the segment as well as

 

g) segment offset: 13bit, 8-byte unit, value 0-8191  H) ⽣ storage period (TTL): 8bit, in seconds

 

i) Protocol: 8bit, ADVANCED layer protocol indicates         j) packet header checksum: 16bit, each 16-bit addition, the carry is added to the result, and finally negated

 

IP addresses k) source IP address and destination time: each 32bit
 

Internet Protocol  IP  is  TCP / IP  one system, two major agreements. And  IP  support, there are three protocols used protocols:

ARP  ARP (Address Resolution Protocol)

Internet Control Message Protocol  ICMP (Internet Control Message Protocol)

Internet Group Management Protocol  IGMP (Internet Group Management Protocol)

 

 

 

 

TCP transport layer

 

Compared to the transport layer is the introduction of different layer of the network the largest port concept. Just send the network layer address and a destination address. But the host may send more than one program and with a receiving host for transmission of data, how to distinguish between multiple programs do? It introduces the concept of port.

 

There is also a function of the transport layer is defined substantially transmitting and receiving packet handling behavior . Speaking above the network layer is equivalent to the mail transport workers, it is only responsible thing to put a package from one place to another place, however, whether this package delivery, and after service of the recipient and what behavior. These can be defined in the transport layer. Note here that is, you can transport layer fabric regardless, only a simple basic package in the quad. You know, I'm talking UDP.

Using User Datagram Protocol (UDP): unreliable, ADVANCED propagation efficiency used in real time video data. Units called datagrams
Transmission Control Protocol (TCP): data transmission unit is called a data segment
                                       Data streaming, reliable, full duplex ⼯, flow control, congestion control

 

 

 

 

 

 

Packet sequence number, used to solve the scrambled packet network (Reordering) problem.

Acknowledgement Number is used to acknowledge receipt of ACK--, to solve the problem without packet loss.

Window also known as Advertised-Window, which is the famous sliding window (Sliding Window), for solving flow control.

TCP Flag, which is the type of package is mainly used to manipulate the TCP state machine.

I-connector-connector end of the source / destination time: Each 16bit

 

. Ii Serial No. / No acknowledgment: each 32bit

 

iii header ⻓ of:. 4bit, Unit 4 bytes

 

. Iv reservations: 6bit, zero

 

v URG:. 1bit, Urgent Pointer indicates effective

 

vi ACK:. 1bit, indicating the effective validation segment

 

vii PSH:. 1bit, tell the host data segment is about attention immediately submitted to the process to apply it

 

viii RST:. 1bit, reconnect

 

ix. SYN:1bit ,同步序列号,⽤于确认连接

 

x. FIN:1bit ,⽤于释放连接

 

xi. 窗⼝⼤⼩ :16bit,⽤于流量控制,指示确认后还可发送的字节数

 

xii. 检验和 /紧急指针 :各16bit

 

 

 

 二、流量控制与滑动窗口

 

三、TCP建立连接和关闭的三次握手

 

client和server应该理解为发送方(客户端)和接收方(服务器)

建⽴连接:三步握⼿
a) 主机 1 向主机 2 发送序号 seq = x的连接请求 TPDU
b) 主机 2 答应连接请求, ack = x, seq = y
c) 主机 1 发送序列号 seq = x 的数据,并确认 ack = y
TCP协议的状态机

 

 

三. 拥塞阻塞 明明网络已经堵塞了,还一个劲地发送大量包,甚至重发,那么这个时候,大家都没得玩了。于是,TCP引入了拥塞窗口(cwnd)的概念。

流量控制:根据接收⽅的缓存容量来动态调整发送⽅的窗⼝⼤⼩,避免⼀个快速的发送⽅淹没⼀个慢速的接收⽅
拥塞控制:根据⽹络的承载容量来动态调整发送⽅的窗⼝⼤⼩,避免同⼀时刻发送⽅有太多的未被确认接收的
 算法:
慢启动在刚刚连接网络的时候,最好先慢慢检测网络情况,再确定发送包的数量。这就是我们说的慢启动算法。
   发送方从1个包开始,收到ACK,下次就发送2个包,收到这两个包的ACK(请注意,这里有可能只有一个ACK),下次就发送4个包。

“每收到一个ACK,拥塞窗口就增加一个报文段”。

当然上图的情况太理想,实际的情况,坑cwnd为2的请求发出去两个报文包的时候,先返回了一个ACK,然后cwnd这个时候就为3,发送方就会继续发送请求包。。。

 

 

 

 拥塞避免算法 

慢启动使得cwnd是呈指数增长。一定不可能是无限增长的,这里就有个阀值,超过这个阀值,就进入拥塞避免算法。

先说拥塞避免算法,拥塞避免算法说的是拥塞窗口的增加不再是“每收到一个ACK,拥塞窗口就增加一个报文段”。 而是“每收到一个ACK,cwnd = cwnd + 1/cwnd”。

 

 

快速回复算法

快速恢复算法是为了不要有一个重传就那么大响应。能尽快恢复到网络流畅时候稳定的状态。

 

其他

DNS域名查询类型 :

 

a) 递归查询 :每⼀个被请求的服务器如果没有记录, 就会向其它服务器查询, 并沿着

 

查询路径返回

 

b) 迭代查询 :本地服务器如果没有记录, 就向⾼级服务器查询, 被请求的服务器如果

 

没有记录就返回⼀个可供查询的服务器地址

 

FTP⽂件传输协议 :

 

a) 主动模式 :client 向 server 命令通道 21 端⼝, server 向 client 数据通道 20 端⼝

 

b) 被动模式 :client 向 server 命令通道 21 端⼝, client 向 server 数据通道> 1023

电⼦邮件相关协议 :
a) 消息交换的协议:
   i. 发送 email:简单邮件传输协议( SMTP)
   ii. 接收 email:
  1. 邮局协议第 3 版( POP3)
  2. Internet 消息访问协议( IMAP)
b) 消息格式的协议:
   i. RFC 822:基本的 ASCII的⽂本邮件
   ii. 多⽤途 Internet 邮件扩展( MIME )

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/knightoffz/p/11957265.html