background
client connection server receives data parsing data into storage
server (port: 8090) = > client
demand
the server that wants to run the client application but cannot connect to it is wondering if it is possible to tcpdump the data from server port 8090 on the client side and then tcpreplay the dump data locally so that the client can run
. production environment
server (8090) = = > client (parsing storage)
local environment
Mock server (8090) & & tcp replay dump file = = > client (parsing storage)
Experimental verification
tcpdump data
A local Server port 8090 sends data to the client every 1 second: the current timestamp
also has a Client connection port 8090 to receive the data sent by the server and print it
-sharp dump8090 10
~ sudo tcpdump -i lo0 -nn -s0 -v src port 8090 -c 10 -w test.pcap
-sharp
~ tcpdump -r test.pcap
11:13:24.772928 IP localhost.8090 > localhost.50969: Flags [P.], seq 3586243504:3586243518, ack 1284618522, win 6379, options [nop,nop,TS val 741399489 ecr 741398485], length 14
11:13:25.775746 IP localhost.8090 > localhost.50969: Flags [P.], seq 14:28, ack 1, win 6379, options [nop,nop,TS val 741400491 ecr 741399489], length 14
...
Replay dump file
now that you have dump data, how can you send the data captured in the previous step to the client
- start a Mock Server and do nothing but listen to port 8090
INFO: server listening on localhost:8090 (xSocket 2.8.15)
- start the client to connect to port Mock Server (8090
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
Shadowsoc 1097 zhugw 5u IPv4 0xe7dccacf94a472b5 0t0 TCP *: 8090 (LISTEN)
java 34607 zhugw 40u IPv6 0xe7dccacfb3a69df5 0t0 TCP localhost:8090 (LISTEN)
java 34607 zhugw 49u IPv6 0xe7dccacfb3a6a975 0t0 TCP localhost:8090- > localhost:52286 (ESTABLISHED)
java 34610 zhugw 45u IPv6 0xe7dccacfb3a6c635 0t0 TCP localhost:52286- > localhost:8090 (ESTABLISHED) -
dump file of the previous step of replay
sudo tcpreplay-ilo0 test.pcap
Warning: Unable to process unsupported DLT type: BSD loopback (0x0)Actual: 10 packets (700 bytes) sent in 4.01 seconds
Rated: 174.5 Bps, 0.001 Mbps, 2.49 pps
Statistics for network device: lo0Successful packets: 10 Failed packets: 0 Truncated packets: 0 Retried packets (ENOBUFS): 0 Retried packets (EAGAIN): 0
but what is the reason that the client does not receive the data?