0
点赞
收藏
分享

微信扫一扫

TCP与实验

yellowone 2022-01-12 阅读 42

TCP与实验

三次握手

第一次握手:建立连接时,客户端发送syn包(seq=j)到服务器,并进入SYN_SENT状态,等待服务器确认;SYN:同步序列编号(Synchronize Sequence Numbers)。

第二次握手:服务器收到syn包,必须确认客户端的SYN(ack=j+1),同时自己也发送一个SYN包(seq=k),即SYN+ACK包,此时服务器进入SYN_RECV状态。

第三次握手:客户端收到服务器的SYN+ACK包,向服务器发送确认包ACK(ack=k+1),此包发送完毕,客户端和服务器进入ESTABLISHED(TCP连接成功)状态,完成三次握手。

四次断开

(即连续终止协议)

由于TCP连接是全双工的,因此每个方向都必须单独进行关闭。这原则是当一方完成它的数据发送任务后就能发送一个FIN来终止这个方向的连接。收到一个 FIN只意味着这一方向上没有数据流动,一个TCP连接在收到一个FIN后仍能发送数据。首先进行关闭的一方将执行主动关闭,而另一方执行被动关闭。

(1) TCP客户端发送一个FIN,用来关闭Client到Server的数据传送,Client进入FIN_WAIT_1状态。

(2) 服务器收到这个FIN,它发回一个ACK,确认序号为收到的序号加1,Server进入CLOSE_WAIT状态。

(3) 服务器关闭客户端的连接,发送一个FIN给客户端,Server进入LAST_ACK状态。

(4) 客户端发回ACK报文确认,并将确认序号设置为收到序号加1,Server进入CLOSED状态,完成四次挥手。

实验要求

在这里插入图片描述
1.R6为ISP,接口IP地址为公有地址;该设备只能配IP地址,之后不能在对其进行任何配置。
2.R1-R5为局域网,私有IP地址192.168.1.0/24请合理分配。
3.所有的路由器上均有换回,代表用户接口。
4.R3下的两台PC通过DHCP自动获取IP地址。
5.选路最佳,路由表尽量小,避免环路。
6.R1-R5均可访问R6的环回。
7.R6 telnet R5的公有IP地址时,实际登录到R1上。
8.R4与R5正常通过1000兆链路,故障时,通过100兆链路。

拓扑图

在这里插入图片描述

子网划分

192.168.1.0/27 (主网段)
192.168.1.32/27 (R1环回)
192.168.1.64/27 (R1环回)
192.168.1.96/27 (R2环回)
192.168.1.128/27(R2环回)
192.168.1.160/27(R4环回)
192.168.1.192/27(R4环回)
192.168.1.224/27(用于R3dhcp使用)

192.168.1.0/27作为主网段,子网段需要7个网段,子网划分为:
192.168.1.0/30
192.168.1.4/30
192.168.1.8/30
192.168.1.12/30
192.168.1.16/30

实验配置

1.先配置所有IP地址:

【R1】:
[R1]int g 0/0/0
[R1-GigabitEthernet0/0/0]ip address 192.168.1.1 30
[R1-GigabitEthernet0/0/0]int g0/0/1
[R1-GigabitEthernet0/0/1]ip address 192.168.1.5 30
[R1]int LoopBack 0
[R1-LoopBack0]ip address 192.168.1.33 27
[R1]int LoopBack 1
[R1-LoopBack1]ip address 192.168.1.65 27

【R2】:
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip address 192.168.1.9 30
[R2-GigabitEthernet0/0/0]int g0/0/01
[R2-GigabitEthernet0/0/1]ip address 192.168.1.2 30
[R2]int LoopBack 0
[R2-LoopBack0]ip address 192.168.1.97 27
[R2]int LoopBack 1
[R2-LoopBack1]ip address 192.168.1.129 27

【R3】:
[R3]int g0/0/0
[R3-GigabitEthernet0/0/0]ip address 192.168.1.6 30
[R3-GigabitEthernet0/0/0]int g0/0/1
[R3-GigabitEthernet0/0/1]ip address 192.168.1.13 30
[R3]int g0/0/2
[R3-GigabitEthernet0/0/2]ip address 192.168.1.225 27
R3的dhcp配置:
[R3]ip pool 1
[R3-ip-pool-1]network 192.168.1.224 mask 27
[R3-ip-pool-1]gateway-list 192.168.1.225
[R3-ip-pool-1]dns-list 8.8.8.8 8.8.4.4
[R3-ip-pool-1]int g0/0/2
[R3-GigabitEthernet0/0/2]dhcp select global
PC1和PC2:

【R4】:
[R4]int g0/0/1
[R4-GigabitEthernet0/0/1]ip address 192.168.1.10 30
[R4-GigabitEthernet0/0/1]int g0/0/2
[R4-GigabitEthernet0/0/2]ip address 192.168.1.14 30
[R4-GigabitEthernet0/0/2]int g0/0/0
[R4-GigabitEthernet0/0/0]ip address 192.168.1.21 30
[R4]int e4/0/0
[R4-Ethernet4/0/0]ip address 192.168.1.17 30
[R4]int LoopBack 0
[R4-LoopBack0]ip address 192.168.1.161 27
[R4-LoopBack0]int lo 1
[R4-LoopBack1]ip address 192.168.1.193 27

【R5】:
[R5]int g0/0/0
[R5-GigabitEthernet0/0/0]ip address 192.168.1.22 30
[R5-GigabitEthernet0/0/0]int g0/0/1
[R5-GigabitEthernet0/0/1]ip address 56.1.1.1 24
[R5]int e4/0/0
[R5-Ethernet4/0/0]ip address 192.168.1.18 30
[R5]int LoopBack 0
[R5-LoopBack0]ip address 5.5.5.5 24

【R6】:
[R6]int g0/0/0
[R6-GigabitEthernet0/0/0]ip address 56.1.1.2 24
[R6-GigabitEthernet0/0/0]int lo 0
[R6-LoopBack0]ip address 6.6.6.6 24

2.配置静态路由和缺省:

【R1】:
[R1]ip route-static 0.0.0.0 0.0.0.0 192.168.1.2
[R1]ip route-static 0.0.0.0 0.0.0.0 192.168.1.6
[R1]ip route-static 192.168.1.96 27 192.168.1.2
[R1]ip route-static 192.168.1.128 27 192.168.1.2
[R1]ip route-static 192.168.1.160 27 192.168.1.2
[R1]ip route-static 192.168.1.8 30 192.168.1.2
[R1]ip route-static 192.168.1.12 30 192.168.1.6
[R1]ip route-static 192.168.1.192 27 192.168.1.6
[R1]ip route-static 192.168.1.224 27 192.168.1.6
[R1]ip route-static 192.168.1.32 27 NULL 0
[R1]ip route-static 192.168.1.64 27 NULL 0

【R2】:
[R2]ip route-static 0.0.0.0 0.0.0.0 192.168.1.10
[R2]ip route-static 192.168.1.32 27 192.168.1.1
[R2]ip route-static 192.168.1.64 27 192.168.1.1
[R2]ip route-static 192.168.1.4 30 192.168.1.1
[R2]ip route-static 192.168.1.224 27 192.168.1.1
[R2]ip route-static 192.168.1.224 27 192.168.1.10
[R2]ip route-static 192.168.1.96 27 NULL 0
[R2]ip route-static 192.168.1.128 27 NULL 0

【R3】:
[R3]ip route-static 0.0.0.0 0.0.0.0 192.168.1.14
[R3]ip route-static 192.168.1.32 27 192.168.1.5
[R3]ip route-static 192.168.1.64 27 192.168.1.5
[R3]ip route-static 192.168.1.0 30 192.168.1.5
[R3]ip route-static 192.168.1.96 27 192.168.1.5
[R3]ip route-static 192.168.1.128 27 192.168.1.14

【R4】:
[R4]ip route-static 0.0.0.0 0.0.0.0 192.168.1.22
[R4]ip route-static 0.0.0.0 0.0.0.0 192.168.1.18 preference 61
[R4]ip route-static 192.168.1.96 27 192.168.1.9
[R4]ip route-static 192.168.1.128 27 192.168.1.9
[R4]ip route-static 192.168.1.0 30 192.168.1.9
[R4]ip route-static 192.168.1.32 27 192.168.1.9
[R4]ip route-static 192.168.1.64 27 192.168.1.13
[R4]ip route-static 192.168.1.4 30 192.168.1.13
[R4]ip route-static 192.168.1.224 27 192.168.1.13
[R4]ip route-static 192.168.1.160 27 NULL 0
[R4]ip route-static 192.168.1.192 27 NULL 0
[R4]ip route-static 192.168.1.24 30 NULL 0
[R4]ip route-static 192.168.1.28 30 NULL 0

【R5】:
[R5]ip route-static 0.0.0.0 0.0.0.0 56.1.1.2
[R5]ip route-static 192.168.1.0 24 192.168.1.21
[R5]ip route-static 192.168.1.0 24 192.168.1.17 preference 61
R1开启telnet:
[R1]aaa
[R1-aaa]local-user root privilege level 15 password cipher root
Info: Add a new user.
[R1-aaa]local-user root service-type telnet
[R1-aaa]q
[R1]user-interface vty 0 4
[R1-ui-vty0-4]authentication-mode aaa

3.R5NAT以及端口映射:

NAT:
[R5]acl 2000
[R5-acl-basic-2000]rule permit source 192.168.1.0 0.0.0.255
[R5-acl-basic-2000]int g0/0/1
[R5-GigabitEthernet0/0/1]nat outbound 2000

端口映射:
[R5]int g0/0/1
[R5-GigabitEthernet0/0/1]nat server protocol tcp global current-interface 23(协议号) ins
ide 192.168.1.33 23(端口号)
Warning:The port 23 is well-known port. If you continue it may cause function fa
ilure.
Are you sure to continue?[Y/N]:y

回到上方

举报

相关推荐

0 条评论