简体   繁体   English

从多播组中收到的DatagramPacket确定发送者

[英]Determine the sender from a received DatagramPacket in a Multicast group

I am trying to implement a Multicast group in Java whose members can both send and receive DatagramPackets by using MulticastSockets . 我正在尝试在Java中实现一个Multicast组,该组的成员可以使用MulticastSockets来发送和接收DatagramPackets The sender relies on acknowledgements from the receiving members in order to ensure, say, that all members have received the transmitted file. 发件人依赖于来自接收成员的确认,以确保(例如)确保所有成员都已接收到传输的文件。

My question is whether it is possible for a receiving member to determine the sender of the packet, as all members send and receive packets through the Multicast address they have joined. 我的问题是,接收成员是否有可能确定数据包的发送者,因为所有成员都通过他们已加入的多播地址发送和接收数据包。

This should be possible by assigning each member an ID which will be included (as a sort of preamble) in the first packet of a transmission, but I was wondering whether there is a better solution. 应该为每个成员分配一个ID,该ID将包含在传输的第一个数据包中(作为一种前导码),但我想知道是否有更好的解决方案。

Is any information which could be used to determine the sender stored in the DatagramPacket sent? 是否可以发送任何信息来确定存储在DatagramPacket的发件人?

Source addresses are always unicast . 源地址始终是unicast In other words, transmission of data always begins from a single source. 换句话说,数据的传输总是从single来源开始。 Hence, no matter which node we consider in a network, the packet it gets will have a source MAC address and a destination MAC address (which will be multicast). 因此,无论我们在网络中考虑哪个节点,它得到的数据包都会有一个源MAC地址和一个目的MAC地址 (将是多播的)。 Using the source MAC address you should be easily able to tell the sender of the packet. 使用源MAC地址,您应该可以轻松地将数据包告知发送方。 I believe you have improperly modeled your problem. 我相信您对问题的建模不当。 Provide us with your UML diagrams/code so that we can analyse it better. 向我们提供您的UML图表/代码,以便我们对其进行更好的分析。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM