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.

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

Blockquote

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 127.0.0.1 PORT 57389
device 2 IP 127.0.0.1 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