TCP communication failed - what happened to the server response?

I am creating a server with ENC28J60 and PIC18F4620 . The chip connects to the computer via Ethernet. I'm currently trying to configure a TCP connection, which I will use later to build an HTTP connection. I have never worked with TCP before.

I only implement TCP on the embedded device, not on the PC.

After sending the necessary ARP requests and responses, I open my browser, enter the IP address of the chip and press the enter key. In wirehark, I see TCP request 1 with the SYN flag. I believe that the SYN flag indicates a new initiation of a handshake, so good, right?

My answer of chip 1 has the SYN and ACK flag. From what I understood , this is the correct way to respond to a request marked SYN. The confirmation number sent by the chip is correct. Now the chip should receive a response with the ACK flag turned on in accordance with the same link.

However, the process seems to be starting: the PC sends the same packet 1 as its first packet, only the β€œidentity” has changed. I programmed my chip to stop responding when it continues to receive SYN requests on the same socket, so this is the end of the transfer, I read in the browser that the server could not be reached.

This connection is performed on four sockets simultaneously, all with the same result.

Since I just use my computer as a client (and nothing happened with my Ethernet port / driver), the problem should be something with the server and, therefore, with the second package.

What happened to the second package? Wireshark does not flag anything wrong, but the client does not send an ACK.


1: Here are the packages that the wires pick up:

Client: 3085 > 80 [SYN] Seq=0 Win=65535 Len=0 MSS=1460 WS=8 TSval=0 TSecr=0 SACK_PERM=1 0000 00 13 d4 c6 53 16 00 1a a0 03 c7 21 08 00 45 00 ....S... ...!..E. 0010 00 40 de 48 40 00 80 06 9a e1 c0 a8 00 01 c0 a8 .@.H @... ........ 0020 00 3c 0c 0d 00 50 88 ab 7e 18 00 00 00 00 b0 02 .<...P.. ~....... 0030 ff ff a1 4f 00 00 02 04 05 b4 01 03 03 03 01 01 ...O.... ........ 0040 08 0a 00 00 00 00 00 00 00 00 01 01 04 02 ........ ...... Server: 80 > 3085 [SYN, ACK] Seq=0 Ack=1 Win=65535 Len=0 MSS=1460 WS=8 0000 00 1a a0 03 c7 21 00 13 d4 c6 53 16 08 00 45 00 .....!.. ..S...E. 0010 00 30 88 10 40 00 7f 06 f2 29 c0 a8 00 3c c0 a8 .0..@... .)...<.. 0020 00 01 00 50 0c 0d 00 00 00 01 88 ab 7e 19 70 12 ...P.... ....~.p. 0030 ff ff ef 77 00 00 02 04 05 b4 01 03 03 03 ...w.... ...... Client: 3085 > 80 [SYN] Seq=0 Win=65535 Len=0 MSS=1460 WS=8 TSval=0 TSecr=0 SACK_PERM=1 0000 00 13 d4 c6 53 16 00 1a a0 03 c7 21 08 00 45 00 ....S... ...!..E. 0010 00 40 de 6f 40 00 80 06 9a ba c0 a8 00 01 c0 a8 .@.o @... ........ 0020 00 3c 0c 0d 00 50 88 ab 7e 18 00 00 00 00 b0 02 .<...P.. ~....... 0030 ff ff a1 4f 00 00 02 04 05 b4 01 03 03 03 01 01 ...O.... ........ 0040 08 0a 00 00 00 00 00 00 00 00 01 01 04 02 ........ ...... 

All this happens similarly to three other client source ports.

For comparison, I made a request to google.com and here is the TCP stream:

 Client: 49562 > 80 [SYN] Seq=0 Win=8192 Len=0 MSS=1460 WS=256 SACK_PERM=1 0000 00 1a a0 03 c7 21 08 9e 01 30 ee 69 08 00 45 00 .....!.. .0.i..E. 0010 00 34 32 3f 40 00 80 06 38 ab c0 a8 00 3c 4a 7d .42?@... 8....<J} 0020 84 78 c1 9a 00 50 74 b8 31 9c 00 00 00 00 80 02 .x...Pt. 1....... 0030 20 00 56 f7 00 00 02 04 05 b4 01 03 03 08 01 01 .V..... ........ 0040 04 02 .. Server: 80 > 49562 [SYN, ACK] Seq=0 Ack=1 Win=62920 Len=0 MSS=1430 SACK_PERM=1 WS=64 0000 08 9e 01 30 ee 69 00 1a a0 03 c7 21 08 00 45 00 ...0.i.. ...!..E. 0010 00 34 9e e3 00 00 2e 06 5e 07 4a 7d 84 78 c0 a8 .4...... ^.J}.x.. 0020 00 3c 00 50 c1 9a f4 5e 12 bc 74 b8 31 9d 80 12 .<.P...^ ..t.1... 0030 f5 c8 7a 22 00 00 02 04 05 96 01 01 04 02 01 03 ..z".... ........ 0040 03 06 .. Client: 49562 > 80 [ACK] Seq=1 Ack=1 Win=65536 Len=0 0000 00 1a a0 03 c7 21 08 9e 01 30 ee 69 08 00 45 00 .....!.. .0.i..E. 0010 00 28 32 49 40 00 80 06 38 ad c0 a8 00 3c 4a 7d .( 2I@... 8....<J} 0020 84 78 c1 9a 00 50 74 b8 31 9d f4 5e 12 bd 50 10 .x...Pt. 1..^..P. 0030 01 00 af 9e 00 00 00 00 00 00 00 00 ........ .... 
+6
source share
1 answer

I used text2pcap to load your capture in wirehark.

If you enable TCP checksum verification and absolute sequence numbers, you will see a bad TCP checksum in your SYN-ACK packet of chips.

In addition, the chip starting with absolute sequence number 0 is very weak.

+5
source

Source: https://habr.com/ru/post/944184/


All Articles