gpt4 book ai didi

c# - 如何解释 wireshark 消息并使用 C# 发送它们

转载 作者:太空宇宙 更新时间:2023-11-03 15:31:59 26 4
gpt4 key购买 nike

我有一台巴可投影仪,我想自己远程控制。

巴可有自己的 tool这样做,但完全用 java 编写。

当我使用 wireshark 捕捉到发送到 HDMI 源的数据时,我得到以下信息:

0000   00 0d 0a 01 2a bc d8 d3 85 95 91 57 08 00 45 00  ....*......W..E.
0010 00 31 51 72 40 00 80 06 00 00 0a 00 00 0d 0a 00 .1Qr@...........
0020 00 3e ef e1 04 01 c2 67 14 b8 9e da c6 b2 50 18 .>.....g......P.
0030 01 00 14 6e 00 00 3a 49 48 44 4d 20 31 20 0d ...n..:IHDM 1 .


0000 00 0d 0a 01 2a bc d8 d3 85 95 91 57 08 00 45 00 ....*......W..E.
0010 00 28 51 73 40 00 80 06 00 00 0a 00 00 0d 0a 00 .(Qs@...........
0020 00 3e ef e1 04 01 c2 67 14 c1 9e da c6 c4 50 10 .>.....g......P.
0030 01 00 14 65 00 00 ...e..

然后切换回 DVI,我得到:

0000   00 0d 0a 01 2a bc d8 d3 85 95 91 57 08 00 45 00  ....*......W..E.
0010 00 31 53 1e 40 00 80 06 00 00 0a 00 00 0d 0a 00 .1S.@...........
0020 00 3e ef e1 04 01 c2 67 14 c1 9e da c6 c4 50 18 .>.....g......P.
0030 01 00 14 6e 00 00 3a 49 44 56 49 20 31 20 0d ...n..:IDVI 1 .


0000 00 0d 0a 01 2a bc d8 d3 85 95 91 57 08 00 45 00 ....*......W..E.
0010 00 28 53 20 40 00 80 06 00 00 0a 00 00 0d 0a 00 .(S @...........
0020 00 3e ef e1 04 01 c2 67 14 ca 9e da c6 d6 50 10 .>.....g......P.
0030 00 ff 14 65 00 00 ...e..

我在 C# 中尝试了一些东西,但收效甚微:

IPAddress beamerIP = new IPAddress(IpToBin("!!Beamer IP!!"));
IPEndPoint ip = new IPEndPoint(beamerIP, 1025);
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

socket.Connect(ip);
Console.WriteLine("Socket connected to " + socket.RemoteEndPoint.ToString());

byte[] msg = Encoding.ASCII.GetBytes(":IDVI 1 .");
byte[] dvi = new byte[] { 0x3a, 0x49, 0x44, 0x56, 0x49, 0x20, 0x31, 0x20, 0x0d };
byte[] hdmi = new byte[] { 0x3a, 0x49, 0x48, 0x44, 0x4d, 0x20, 0x31, 0x20, 0x0d };

int bytesSent = socket.Send(dvi);
Console.WriteLine("Sent {0} bytes.", bytesSent);

socket.Shutdown(SocketShutdown.Both);
socket.Close();

我也试过像这个 thread 中那样用 PCAP.NET 发送,但收效甚微。

我是做错了什么还是有其他方法可以解决这个问题?

最佳答案

原来我快到了。这是对我有用的代码:

// Data buffer for incoming data.
byte[] bytes = new byte[1024];
// Establish the remote endpoint for the socket.
IPAddress beamerIP = new IPAddress(IpToBin("!!Beamer IP!!"));
IPEndPoint ip = new IPEndPoint(beamerIP, 1025);
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
socket.Connect(ip);
// Send the data through the socket.
int bytesSent = socket.Send(message); //message => DVI = Encoding.ASCII.GetBytes(":IDVI 1 \r") || HDMI = Encoding.ASCII.GetBytes(":IHDM 1 \r")
// Receive the response from the remote device.
int bytesRec = socket.Receive(bytes);
// Release the socket.
socket.Shutdown(SocketShutdown.Both);
socket.Close();

关于c# - 如何解释 wireshark 消息并使用 C# 发送它们,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33496706/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com