简体   繁体   English

在第2层组播

[英]Multicast over layer 2

Pardon my limited knowledge in networks. 请原谅我有限的网络知识。

I am trying to setup two small programs as client and server, which join to a particular multicast group. 我正在尝试设置两个小的程序作为客户端和服务器,它们加入了特定的多播组。 The servers sends some arbitrary data to the group and the client receives the data as it listens to the group. 服务器向该组发送一些任意数据,而客户端在侦听该组时会接收数据。

This of course is possible with UDP programs which I have already done. 我已经完成的UDP程序当然可以做到这一点。 However I need to work with MAC addresses instead of IP s. 但是,我需要使用MAC地址而不是IP And I have a few questions regarding this: 我对此有一些疑问:

  1. Is it possible to fix a range of MAC addresses for my multicast application ? 是否可以为我的多播应用程序固定一定范围的MAC地址? As I understand, the least significant bit of the first octet in the MAC address signifies if it is multicast or not. 据我了解,MAC地址中第一个八位位组的最低有效位表示它是否是组播的。 So the multicast MAC should look like 01:*:*:*:*:* . 因此,组播MAC应该看起来像01:*:*:*:*:* So I guess, there should be some way to use a wide range of MAC addresses (except for those reserved). 因此,我想应该有某种方法可以使用广泛的MAC地址(保留的除外)。

  2. Many places it is written as All multicast MAC addresses begin with: 0100.5e . All multicast MAC addresses begin with: 0100.5e Is it always true? 总是这样吗? AFAIK this prefix is fixed in the MAC address which leaves space for the rest of the IP address bits to be mapped here. AFAIK此前缀固定在MAC地址中,从而为其余IP地址位留出空间在此处进行映射。 But what if my application doesn't care about IP addresses and listens to multicast groups based on MAC addresses (if it is possible) ?. 但是,如果我的应用程序不关心IP地址,而是侦听基于MAC地址的多播组(如果可能)怎么办? Can't I keep the first octet as 01 and use a wide range for my multicast addressing ? 我不能将第一个八位位组保持为01并为我的多播寻址使用广泛的范围吗?

  3. How to send packets to a multicast group and listen to a multicast group only based on MAC addresses and irrespective of IP ? 如何仅基于MAC地址且不考虑IP,将数据包发送到多播组并侦听多播组? ie the multicast group addresses are defined based on MACs. 即,基于MAC来定义多播组地址。

I hope my questions made sense. 我希望我的问题有道理。

If you are not using IP (or UDP on top of that) then the default way of mapping IP addresses to mac addresses have probably no added value for you. 如果您不使用IP(或UDP),则将IP地址映射到mac地址的默认方式可能没有任何附加价值。 These mappings are specified for example in: 这些映射例如在以下示例中指定:

If you insist on using layer2 and multicasting it will probably be sufficient to send out frames with the LSB of the first octet set (the multicast bit, ref: http://en.wikipedia.org/wiki/File:MAC-48_Address.svg ). 如果您坚持使用layer2并进行多播,则可能足以发送具有第一个八位位组的LSB的帧(多播位,请参阅: http : //en.wikipedia.org/wiki/File : MAC-48_Address。 svg )。 And put your own mapping on top of that. 并在此之上放置您自己的映射。 But you should take into account that: 但是您应该考虑到以下几点:

  • you probably need to force your NIC to pass the data, often NIC's filter out frames they are interested in hardware. 您可能需要强制NIC传递数据,通常是NIC过滤掉他们对硬件感兴趣的帧。 And these filters are typically set when joining a group or eg when setting the ALLMULTI flag). 这些过滤器通常在加入组时设置,例如在设置ALLMULTI标志时设置)。
  • There is probably networking equipment in the middle and some pseudo-intelligent switches may refuse to forward data unless they have seen IGMP joins (ref igmp snooping). 中间可能有网络设备,并且某些伪智能交换机可能拒绝转发数据,除非他们看到IGMP加入(ref igmp snooping)。
  • And you code will obviously need to deal with raw layer 2 sockets to read out the data. 而且您的代码显然将需要处理原始的第2层套接字以读取数据。

Considering the ease of just using UDP this may be a lot of work. 考虑到仅使用UDP的简便性,这可能需要大量工作。

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

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