TCP三次握手/四次挥手
- 三次握手内容不多,涉及到5种有限状态机(Finite State Machine),小写的seq,ack字段代表TCP首部报文中的序列号和确认号,大写的SYN,ACK是6个flags中的字段,ack确认号表示期待对方下次发过来的seq序列号,window size机制表示不再采取一来一去的收发形式,而是当收到size个数据包时再作回复
- 四次挥手很少用到,重点讨论FIN-WAIT1和FIN-WAIT2之间的半关闭状态,涉及到5种新的有限状态机(还有一种特殊状态closing,例如当server收到client的FIN包时,直接回复一个FIN包,跳过了close-wait的状态),其中time-wait状态的时间是[2MSL][1](maximum segment length),意为TCP报文段最大生存时间的2倍,由于数据包的先发后至特性,因此client会在这段时间等待server端完成全部的数据传输,再进入closed状态。四次挥手中server/client都可以是主动发起方。在server回复第一次ACK包 到 第二次回复FIN包的过程中,如果server始终没有回复FIN包,那么称client在半关闭状态下进入孤儿连接,由内核来接管,内核中定义了表示孤儿连接最大连接数和生存时间的参数
TCP/UDP区别
TCP | UDP |
---|
Connection-oriented | Connectionless | sequence | none | FTP File-Sharing E-mail | Voice Streaming Video Streaming |
IP地址分类
- A类:
0 0000000 - 0 1111111.X.Y.Z : 0-127.X.Y.Z 网络ID位是最高8位,主机ID是24位低位 网络数:126=2^7(可变的网络ID位数)-2 每个网络中的主机数:2^24-2=16777214 默认子网掩码:255.0.0.0 私网地址:10.0.0.0 范例:114.114.114.114,8.8.8.8,1.1.1.1,58.87.87.99,119.29.29.29
127.0.0.1为回环地址,因此127.0.0.0网段被保留;其特殊性在于,只要是和loopback网卡在同一网段的ip地址,都能ping通,并且loopback网卡上新加的ip地址并不会生成路由记录,回环网卡因物理上比较稳定,在生产环境中时有用到
- B类:
10 000000 - 10 111111.X.Y.Z:128-191.X.Y.Z 网络ID位是最高16位,主机ID是16位低位 网络数:2^14=16384 每个网络中的主机数:2^16-2=65534 默认子网掩码:255.255.0.0 私网地址:172.16.0.0-172.31.0.0 范例:180.76.76.76,172.16.0.1 - C类:
110 0 0000 - 110 1 1111.X.Y.Z: 192-223.X.Y.Z 网络ID位是最高24位,主机ID是8位低位 网络数:2^21=2097152 每个网络中的主机数:2^8-2=254 默认子网掩码:255.255.255.0 私网地址:192.168.0.0-192.168.255.0 范例: 223.6.6.6 - D类:组(多)播,1110 0000 - 1110 1111.X.Y.Z: 224-239.X.Y.Z
- E类:保留未使用,240-255
IP配置方法
ifconfig IFACE IFADDR/MASK
ifconfig IFACE up/down
ifconfig IFACE:<Label> IP/MASK
ip address [add][del][change] IFADDR/MASK dev IFACE [label IFACE:NUM][scope {host,link,global}] [master] [type]
nmcli connection reload
nmcli connection [up][down] IFACE
nmcli connection [add][modify][del] con-name xxx ifname xxx ipv4.method {auto,manual}\
> ipv4.{addresses,gateway} type {ethernet,bond,bridge,team}
nmcli实现bonding
[root@linuxprobe ~]
Connection 'mybond' (8f0d9cce-ed6a-4d0e-a9a2-cba48490d1d2) successfully added.
[root@linuxprobe ~]
Connection 'bond-slave-ens37' (c4f82c63-145d-4ec9-8432-f5ecbb7f3b3a) successfully added.
[root@linuxprobe ~]
Connection 'bond-slave-ens38' (c5a3f017-3a99-428a-8b9d-4a00af4152da) successfully added.
[root@linuxprobe ~]
[root@linuxprobe ~]
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/6)
[root@linuxprobe ~]
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/7)
[root@linuxprobe ~]
Connection successfully activated (master waiting for slaves) (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/8)
[root@linuxprobe /]
NAME UUID TYPE DEVICE
ens33 49da06d1-7851-3b3c-8025-39ac395471fc ethernet ens33
mybond 8f0d9cce-ed6a-4d0e-a9a2-cba48490d1d2 bond bond0
bond-slave-ens37 c4f82c63-145d-4ec9-8432-f5ecbb7f3b3a ethernet ens37
bond-slave-ens38 c5a3f017-3a99-428a-8b9d-4a00af4152da ethernet ens38
Wired connection 1 4e5d315c-274b-32eb-88a3-ca5cd71c07ce ethernet --
Wired connection 2 da549472-f269-3db4-af9b-47e66e7a1810 ethernet --
3: ens37: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc fq_codel master bond0 state UP group default qlen 1000
link/ether 00:0c:29:13:dd:40 brd ff:ff:ff:ff:ff:ff
altname enp2s5
4: ens38: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc fq_codel master bond0 state UNKNOWN group default qlen 1000
link/ether 00:0c:29:13:dd:40 brd ff:ff:ff:ff:ff:ff permaddr 00:0c:29:13:dd:4a
altname enp2s6
5: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 00:0c:29:13:dd:40 brd ff:ff:ff:ff:ff:ff
inet 192.168.142.134/24 brd 192.168.142.255 scope global dynamic noprefixroute bond0
valid_lft 1024sec preferred_lft 1024sec
inet6 fe80::9647:c69d:cc99:d556/64 scope link noprefixroute
valid_lft forever preferred_lft forever
[root@linuxprobe /]
Ethernet Channel Bonding Driver: v5.11.11-300.fc34.x86_64
Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: ens37
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Peer Notification Delay (ms): 0
Slave Interface: ens37
MII Status: up
Speed: 10 Mbps
Duplex: half
Link Failure Count: 0
Permanent HW addr: 00:0c:29:13:dd:40
Slave queue ID: 0
Slave Interface: ens38
MII Status: up
Speed: 10 Mbps
Duplex: half
Link Failure Count: 0
Permanent HW addr: 00:0c:29:13:dd:4a
Slave queue ID: 0
|