I need to send Ethernet packets from one device to another by Ethernet protocol. After some research i decide to use TCP\IP protocol. I created TCP server and TCP client that communicating with each other. I used TcpClient and TcpListener classes for that. It works fine, but i have some questions:
Svemir, you can check SO question here about raw communication using Sockets in C#.
Here is a good SuperUser explanation of the various layers. If you go with the raw method of the Sockets, then you are in for some hard times
you're going to have to handle the details of TCP if you implement your socket this way.
From Microsoft documentation on SocketType.Raw
Supports access to the underlying transport protocol. Using Raw, you can communicate using protocols like Internet Control Message Protocol (ProtocolType.Icmp) and Internet Group Management Protocol (ProtocolType.Igmp). Your application must provide a complete IP header when sending. Received datagrams return with the IP header and options intact
From Microsoft documentation on SocketType.Stream
Supports reliable, two-way, connection-based byte streams without the duplication of data and without preservation of boundaries. A Socket of this type communicates with a single peer and requires a remote host connection before communication can begin. Stream uses the Transmission Control Protocol (ProtocolType.Tcp) and the AddressFamily.InterNetwork address family.
Which basically means that everything is handled for you and that you can only have access to what the SuperUser link refers to as the letter contents.