-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtcp_abnormal_close.html
More file actions
151 lines (136 loc) · 5.08 KB
/
tcp_abnormal_close.html
File metadata and controls
151 lines (136 loc) · 5.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TCP Abnormal Connection Closure with CLOSE_WAIT Accumulation</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
background-color: #222;
color: #eee;
padding-top: 50px;
position: relative;
}
.container {
display: flex;
justify-content: space-between;
align-items: center;
width: 80%;
margin: 50px auto;
position: relative;
}
.box {
width: 160px;
height: 100px;
line-height: 100px;
font-size: 16px;
font-weight: bold;
border-radius: 10px;
border: 2px solid #ccc;
position: relative;
}
.established { background-color: #27ae60; }
.fin_wait_1 { background-color: #f39c12; }
.fin_wait_2 { background-color: #e67e22; }
.close_wait { background-color: #d35400; }
.packet {
position: absolute;
width: 130px;
height: 45px;
line-height: 45px;
font-size: 14px;
font-weight: bold;
border-radius: 5px;
background-color: #3498db;
color: #fff;
visibility: hidden;
}
.state {
font-size: 14px;
font-weight: bold;
margin-top: 5px;
color: #f1c40f;
}
.warning {
font-size: 18px;
font-weight: bold;
color: #e74c3c;
margin-top: 20px;
}
/* Watermark style */
.watermark {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 50px;
font-weight: bold;
color: rgba(255, 255, 255, 0.15); /* Light color for watermark */
pointer-events: none; /* Ensures it's not interactive */
z-index: 10;
user-select: none; /* Prevents text selection */
}
</style>
</head>
<body>
<!-- Watermark -->
<div class="watermark">wangbin579</div>
<h2>TCP Abnormal Connection Closure with CLOSE_WAIT Accumulation</h2>
<div class="container">
<div>
<div id="clientBox" class="box established">Client</div>
<div id="clientState" class="state">ESTABLISHED</div>
</div>
<div>
<div id="serverBox" class="box established">Server</div>
<div id="serverState" class="state">ESTABLISHED</div>
</div>
</div>
<div id="finPacket" class="packet">FIN -></div>
<div id="ackPacket" class="packet"><- ACK</div>
<div id="warning" class="warning" style="visibility: hidden;">
Warning: Server has too many CLOSE_WAIT connections! Resources may be exhausted!
</div>
<script>
function updateState(element, text) {
document.getElementById(element).innerText = text;
}
function startHandshake() {
let clientBox = document.getElementById("clientBox");
let serverBox = document.getElementById("serverBox");
let clientX = clientBox.getBoundingClientRect().x + 80;
let serverX = serverBox.getBoundingClientRect().x + 0;
let fin = document.getElementById("finPacket");
let ack = document.getElementById("ackPacket");
let warning = document.getElementById("warning");
// Step 1: Client sends FIN ¡ú Server
updateState("clientState", "FIN_WAIT_1");
clientBox.className = "box fin_wait_1";
gsap.set(fin, { visibility: "visible", x: clientX, y: -50 });
gsap.to(fin, { x: serverX, duration: 3, onComplete: function() {
gsap.set(fin, { visibility: "hidden" });
// Step 2: Server responds with ACK
updateState("serverState", "CLOSE_WAIT");
serverBox.className = "box close_wait";
gsap.set(ack, { visibility: "visible", x: serverX, y: -50 });
gsap.to(ack, { x: clientX, duration: 3, onComplete: function() {
gsap.set(ack, { visibility: "hidden" });
// Client moves to FIN_WAIT_2
updateState("clientState", "FIN_WAIT_2");
clientBox.className = "box fin_wait_2";
// Step 3: Server forgets to send FIN
// Simulate multiple CLOSE_WAIT connections
setTimeout(function() {
updateState("serverState", "CLOSE_WAIT (Accumulating...)");
warning.style.visibility = "visible";
}, 2000); // Delay to show warning
}});
}});
}
setTimeout(startHandshake, 1000);
</script>
</body>
</html>