Arduino mega with ENC28j60

Hello everyone, ihave some project to connect arduino mega to ethernet connection using ENC28j60. iwant to simulate connection from 2 device that i have simulated in PC software simulation(local host). ihave recorded connection with wireshark.

|1|0.000000|||TCP|56|57389 → 5001 [SYN] Seq=0 Win=65535 Len=0 MSS=65495 WS=256 SACK_PERM=1|
|2|0.000064|||TCP|56|5001 → 57389 [SYN, ACK] Seq=0 Ack=1 Win=65535 Len=0 MSS=65495 WS=256 SACK_PERM=1|
|3|0.000132|||TCP|44|57389 → 5001 [ACK] Seq=1 Ack=1 Win=2619648 Len=0|
|4|0.000562|||TCP|58|57389 → 5001 [PSH, ACK] Seq=1 Ack=1 Win=2619648 Len=14|
|5|0.000591|||TCP|44|5001 → 57389 [ACK] Seq=1 Ack=15 Win=2619648 Len=0|
|6|0.000606|||TCP|54|5001 → 57389 [PSH, ACK] Seq=1 Ack=15 Win=2619648 Len=10|
|7|0.000633|||TCP|44|57389 → 5001 [ACK] Seq=15 Ack=11 Win=2619648 Len=0|
|8|1.001665|||TCP|142|57389 → 5001 [PSH, ACK] Seq=15 Ack=11 Win=2619648 Len=98|
|9|1.001708|||TCP|44|5001 → 57389 [ACK] Seq=11 Ack=113 Win=2619648 Len=0|
|10|1.001817|||TCP|82|5001 → 57389 [PSH, ACK] Seq=11 Ack=113 Win=2619648 Len=38|
|11|1.001853|||TCP|44|57389 → 5001 [ACK] Seq=113 Ack=49 Win=2619648 Len=0|
|12|2.016982|||TCP|142|57389 → 5001 [PSH, ACK] Seq=113 Ack=49 Win=2619648 Len=98|
|13|2.017025|||TCP|44|5001 → 57389 [ACK] Seq=49 Ack=211 Win=2619392 Len=0|
|14|2.017093|||TCP|82|5001 → 57389 [PSH, ACK] Seq=49 Ack=211 Win=2619392 Len=38|
|15|2.017123|||TCP|44|57389 → 5001 [ACK] Seq=211 Ack=87 Win=2619648 Len=0|
|16|3.021796|||TCP|142|57389 → 5001 [PSH, ACK] Seq=211 Ack=87 Win=2619648 Len=98|
|17|3.021832|||TCP|44|5001 → 57389 [ACK] Seq=87 Ack=309 Win=2619392 Len=0|
|18|3.021887|||TCP|82|5001 → 57389 [PSH, ACK] Seq=87 Ack=309 Win=2619392 Len=38|
|19|3.021913|||TCP|44|57389 → 5001 [ACK] Seq=309 Ack=125 Win=2619648 Len=0|
|20|4.016834|||TCP|142|57389 → 5001 [PSH, ACK] Seq=309 Ack=125 Win=2619648 Len=98|
|21|4.016891|||TCP|44|5001 → 57389 [ACK] Seq=125 Ack=407 Win=2619392 Len=0|
|22|4.017043|||TCP|82|5001 → 57389 [PSH, ACK] Seq=125 Ack=407 Win=2619392 Len=38|
|23|4.017070|||TCP|44|57389 → 5001 [ACK] Seq=407 Ack=163 Win=2619392 Len=0|
|24|5.031885|||TCP|142|57389 → 5001 [PSH, ACK] Seq=407 Ack=163 Win=2619392 Len=98|
|25|5.031931|||TCP|44|5001 → 57389 [ACK] Seq=163 Ack=505 Win=2619136 Len=0|
|26|5.031998|||TCP|82|5001 → 57389 [PSH, ACK] Seq=163 Ack=505 Win=2619136 Len=38|
|27|5.032026|||TCP|44|57389 → 5001 [ACK] Seq=505 Ack=201 Win=2619392 Len=0|
|28|6.041787|||TCP|142|57389 → 5001 [PSH, ACK] Seq=505 Ack=201 Win=2619392 Len=98|
|29|6.041840|||TCP|44|5001 → 57389 [ACK] Seq=201 Ack=603 Win=2619136 Len=0|
|30|6.041921|||TCP|82|5001 → 57389 [PSH, ACK] Seq=201 Ack=603 Win=2619136 Len=38|
|31|6.041950|||TCP|44|57389 → 5001 [ACK] Seq=603 Ack=239 Win=2619392 Len=0|
|32|7.051549|||TCP|142|57389 → 5001 [PSH, ACK] Seq=603 Ack=239 Win=2619392 Len=98|
|33|7.051588|||TCP|44|5001 → 57389 [ACK] Seq=239 Ack=701 Win=2618880 Len=0|
|34|7.051647|||TCP|82|5001 → 57389 [PSH, ACK] Seq=239 Ack=701 Win=2618880 Len=38|
|35|7.051674|||TCP|44|57389 → 5001 [ACK] Seq=701 Ack=277 Win=2619392 Len=0|
|36|8.056679|||TCP|142|57389 → 5001 [PSH, ACK] Seq=701 Ack=277 Win=2619392 Len=98|
|37|8.056724|||TCP|44|5001 → 57389 [ACK] Seq=277 Ack=799 Win=2618880 Len=0|
|38|8.056885|||TCP|82|5001 → 57389 [PSH, ACK] Seq=277 Ack=799 Win=2618880 Len=38|
|39|8.056916|||TCP|44|57389 → 5001 [ACK] Seq=799 Ack=315 Win=2619392 Len=0|
|40|9.051179|||TCP|44|57389 → 5001 [FIN, ACK] Seq=799 Ack=315 Win=2619392 Len=0|
|41|9.051213|||TCP|44|5001 → 57389 [ACK] Seq=315 Ack=800 Win=2618880 Len=0|
|42|9.051232|||TCP|44|5001 → 57389 [FIN, ACK] Seq=315 Ack=800 Win=2618880 Len=0|
|43|9.051262|||TCP|44|57389 → 5001 [ACK] Seq=800 Ack=316 Win=2619392 Len=0|


iwant to make 2 arduino comunicating like in the communication above, please some advise or have the example for it. Thanks

i forgot that explain the connection
device 1 IP PORT 57389
device 2 IP PORT 5001
this is shared IP because recorded on localhost, but for real on 2 arduino mega the IP must different ithink

use EthernetENC library and see Arduino Ethernet library examples ChatServer and TelnetClient

hi Juraj,
ihave been search on the sample of ethercard library, but iam not found the syntax or command to do TCP hanshake like send or receive SYN PSH ACK FIN, iwant to simulate exactly communication like on the wireshark capture. Please your advise, Thanks

ethercard library doesn't implement standard Arduino networking API

Ok iwill dig in on EthernetENC library. are you have some example for tcp socket multiple packet?

you don't care about TCP packets on application level. you open a socket and write data.

how about tcp handshake?

what is TCP handshake?
the library has a TCP/IP stack which takes care of connection building, ACK, ...
but all this is in example mentioned in my first comment and in my Arduino SE answer