Reputation: 1
I have a complete program that communicates via UDP protocol. Program runs on a PC with ip 192.168.1.9. When I send specific data, this program responds.
code for sending:
var client = new UdpClient();
IPEndPoint destination = new IPEndPoint(IPAddress.Parse("192.168.1.9"), 1531);
IPAddress localIp = IPAddress.Parse("192.168.1.3");
IPEndPoint source = new IPEndPoint(localIp, 1530);
client.Client.Bind(source);
client.Connect(destination);
byte[] send_buffer = { 170, 170, 0, 0, 1, 1, 86 };
client.Send(send_buffer, send_buffer.Length);
Wireshark captures: Screen
But my application does not detect anything:
UdpClient listener = new UdpClient(1530);
IPAddress ip = IPAddress.Parse("192.168.1.3");
IPEndPoint groupEP = new IPEndPoint(IPAddress.Any, 1530);
byte[] receive_byte_array;
while (!done)
{
Console.WriteLine("Waiting for broadcast");
receive_byte_array = listener.Receive(ref groupEP);
}
I need to capture communications from 192.168.9 to 192.168.1.3 on port 1530.
Upvotes: 0
Views: 742
Reputation: 596287
Your sender is binding to local IP 192.168.1.3
on port 1530 as its source, and then sending data to remote IP 192.168.1.9
on port 1531 as the destination.
Your receiver is binding to local IP 0.0.0.0
on port 1530 for receiving data, and then filtering out any inbound data that was NOT sent from remote port 1530 (which it is).
The data is not being sent to the port that the receiver is reading on.
To fix that, you need to either:
change your receiver to bind to port 1531
instead of port 1530
:
UdpClient listener = new UdpClient(1531);
change your sender to send the data to port 1530
instead of port 1531
:
IPEndPoint destination = new IPEndPoint(IPAddress.Parse("192.168.1.9"), 1530);
Upvotes: 1