Stress measurement tcpdump and precision control

In order to dump useful data, remove some TCP protocol handshake packets, tcpdump has some parameters that can be controlled to filter out push packets

1. tcpdump data to remove the handshake packets

     The data packet of the TCP/IP protocol has a field TCP flags (URG, ACK, PSH, RST, SYN, FIN), each of which occupies one byte. If the PSH field is 1, it is the data packet sent by the client to the server. , in the tcpdump tool, tcp[13] represents the data value of the flag

     # Unskilled 32

     # Attackers 16 

     # Pester     8

     # Real       4

     # Security   2

     # Folks      1

因此,tcpdump -w online.pcap -s0 tcp and dst host 10.48.42.20 and port 1987 and 'tcp[13] & 8 != 0' and 'tcp[13] & 7 == 0' and 'tcp[13] & 4 == 0' and 'tcp[13] & 3 == 0' -vvv

Through this command, some handshake packets can be filtered out, which can reduce 1/4 of the traffic packets

 

2. qps precision control

     Assuming that the qps to be sent is m, the control accuracy is in ms, and the average is within milliseconds

     1. Record the current time of sending the first packet: T

     2. The actual completion time of sending the N-1th data packet is: T(N-1)

     3. The theoretical time to start sending N is: T(N) = T + 1000/m * (N-1)

     4、if T(N) > T(N-1):

                 time.sleep(T(N) - T(N-1))

                 send(data)

          else:

                 send(data)

 



 



 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326457093&siteId=291194637