【发布时间】:2015-05-13 07:42:58
【问题描述】:
我尝试了如下所示的程序:-
class Program
{
static IPEndPoint Mypoint = new IPEndPoint(IPAddress.Parse("10.169.20.30"), 8050);
static IPEndPoint UrPoint = new IPEndPoint(IPAddress.Parse("10.169.20.15"), 8051);
static UdpClient TxClient;
static void Main(string[] args)
{
int i = 0;
byte[] data= new byte[1472];
TxClient = new UdpClient(Mypoint);
while (i < 500)
{
data[i]++;
try
{
TxClient.Send(data, data.Length, UrPoint);
}
catch { }
Console.WriteLine("Sent frame " + ++i + " times\n");
}
Console.ReadKey();
}
}
在此我向 IP 地址为 10.169.20.15 的系统发送一系列帧。我没有为此系统提供任何 MAC ID。 但是当我通过wireshark查看帧的传输时,我发现目标MAC Id会自动更新为该系统的MAC Id。
谁能告诉我这是怎么回事。是系统自动找出IP地址对应的MAC id,还是有其他原因。
我之所以问这个是因为,我现在需要以 UDP 协议与微控制器通信。由于我无法在 C# 中更新目标 MAC 地址,因此仅提供 IP 地址就足够了。 MAC Id 会自动解析吗?
希望问题很清楚,感谢您的帮助!!!
编辑:- 我尝试在命令提示符下使用 arp -s ipaddress mac address 然后运行我的程序,但是发送的帧仍然没有传输到给定的 mac 地址。
谁能告诉我如何解决这个问题。 感谢您的帮助
【问题讨论】: