[英]How can i get CRC from received data by TCP?
I need to send Ethernet packets from one device to another by Ethernet protocol.我需要通过以太网协议将以太网数据包从一台设备发送到另一台设备。 After some research i decide to use TCP\\IP protocol.
经过一番研究,我决定使用 TCP\\IP 协议。 I created TCP server and TCP client that communicating with each other.
我创建了相互通信的 TCP 服务器和 TCP 客户端。 I used TcpClient and TcpListener classes for that.
我为此使用了 TcpClient 和 TcpListener 类。 It works fine, but i have some questions:
它工作正常,但我有一些问题:
Svemir, you can check SO question here about raw communication using Sockets in C#. Svemir,您可以在此处查看有关使用 C# 中的套接字进行原始通信的SO 问题。
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
如果你使用 Sockets 的原始方法,那么你会遇到一些困难
you're going to have to handle the details of TCP if you implement your socket this way.
如果你以这种方式实现你的套接字,你将不得不处理 TCP 的细节。
From Microsoft documentation on SocketType.Raw来自微软关于 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).
使用 Raw,您可以使用 Internet 控制消息协议 (ProtocolType.Icmp) 和 Internet 组管理协议 (ProtocolType.Igmp) 等协议进行通信。 Your application must provide a complete IP header when sending.
您的应用程序在发送时必须提供完整的 IP 标头。 Received datagrams return with the IP header and options intact
接收到的数据报返回时带有完整的 IP 标头和选项
From Microsoft documentation on SocketType.Stream来自微软关于 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.
这种类型的 Socket 与单个对等方进行通信,并且在开始通信之前需要远程主机连接。 Stream uses the Transmission Control Protocol (ProtocolType.Tcp) and the AddressFamily.InterNetwork address family.
Stream 使用传输控制协议 (ProtocolType.Tcp) 和 AddressFamily.InterNetwork 地址族。
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.这基本上意味着一切都为您处理,您只能访问超级用户链接所指的信件内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.