Understanding Multicast Networks: Efficient Data Transmission & Protocols Explained

Hello everyone, nice to see you again. I am your friend Full Stack Jun, here to talk about multicast networks.

Multicast Transmission:

Establishing a point-to-multipoint network connection between the sender and every receiver.

If a sender transmits the same data to multiple receivers simultaneously, only one copy of the same data packet needs to be sent. It enhances data transmission efficiency and reduces the likelihood of congestion in the backbone network.

The differences between unicast, multicast, and broadcast can be seen in the image below:

multicast network>

  • Unicast: Refers to a transmission method in computer networking where the destination address is a single target. It is the most widely used in current network applications, and most network protocols or services typically employ unicast transmission, for example, all protocols based on TCP.
  • Multicast: Also known as multiple-casting or group-casting. It refers to transmitting information to a group of destination addresses simultaneously. Its strategy is the most efficient because the message only needs to be transmitted once on each network link, and only at a branching point is the message replicated.
  • Broadcast: Refers to a transmission method in a computer network where the destination address is all devices in the network. However, “all devices” mentioned here is limited within a scope known as a “broadcast domain.”

Determining if Network Cards Support Multicast

Run ifconfig in Linux, if the network card information includes UP BROADCAST RUNNING MULTICAST, then it supports broadcast and multicast.

multicast network>

Reference: http://colobu.com/2014/10/21/udp-and-unicast-multicast-broadcast-anycast

Multicast IP Addresses

Multicast IP addresses are used to identify an IP multicast group.

IANA (Internet Assigned Numbers Authority) allocates Class D address space to IP multicast, ranging from 224.0.0.0 to 239.255.255.255.

  • 224.0.0.0 to 224.0.0.255 are reserved multicast addresses (permanent group addresses), address 224.0.0.0 is reserved not to be allocated, other addresses are for routing protocols.
  • 224.0.1.0 to 224.0.1.255 are public multicast addresses, which can be used on the Internet.
  • 224.0.2.0 to 238.255.255.255 are user-available multicast addresses (temporary group addresses), effective throughout the entire network.
  • 239.0.0.0 to 239.255.255.255 are locally managed multicast addresses, only effective within a specific local range. Reference:http://baike.baidu.com/view/492256.htm

Permanent Multicast Addresses:

  • 224.0.0.0 Base Address (Reserved)
  • 224.0.0.1 All Host Address (Includes All Router Addresses)
  • 224.0.0.2 All Multicast Routers’ Address
  • 224.0.0.3 Not Allocated
  • 224.0.0.4 DVMRP Routers
  • 224.0.0.5 All OSPF Routers
  • 224.0.0.6 OSPF DR/BDR
  • 224.0.0.7 ST Routers
  • 224.0.0.8 ST Hosts
  • 224.0.0.9 RIP-2 Routers
  • 224.0.0.10 EIGRP Routers
  • 224.0.0.11 Active Agents
  • 224.0.0.12 DHCP Servers/Relay Agents
  • 224.0.0.13 All PIM Routers
  • 224.0.0.14 RSVP Encapsulation
  • 224.0.0.15 All CBT Routers
  • 224.0.0.16 Assigned SBM
  • 224.0.0.17 All SBMs
  • 224.0.0.18 VRRP

When transmitting a unicast IP datagram over Ethernet, the destination MAC address is the receiver’s MAC address. However, when transmitting a multicast datagram, the target is no longer a specific receiver but an uncertain group of members, so a multicast MAC address is used.

Multicast MAC addresses correspond to multicast IP addresses. According to the Internet Assigned Numbers Authority (IANA), the high-order 24 bits of the multicast MAC address are 0x01005e, and the low-order 23 bits of the MAC address correspond to the low-order 23 bits of the multicast IP address. Since only 23 bits of the multicast IP address map to the MAC address, there will be 32 multicast IP addresses mapping to the same MAC address.

Group Membership Mechanism

To accurately send multicast data to group members, it is necessary to first determine which networks and which hosts are group members. Only by first determining the members’ locations can multicast be correctly forwarded. When a group member no longer needs to receive the multicast, sending to that member should stop. To determine that group members no longer need to receive multicast, explicit notifications from members when they exit are required. There are two methods to establish group membership: query and report.

Query involves a router sending a query message to the network to check if a host wants to join the group. If any host responds, the router can request upstream routers to forward multicast traffic to this subnet. If no host responds, it requests upstream routers to stop forwarding multicast traffic to it.

In the report method, a host can actively request to join a group without waiting for a query from the router and should send an exit message to the router when exiting to stop the forward of multicast traffic.

In a network, determining group membership requires a protocol known as IGMP (Internet Group Management Protocol). IGMP operates between routers and hosts because if a multicast sender and group member are on different networks, the router needs to provide forwarding for multicast data. The router must determine whether there are group members on its directly connected network and can use querying and reporting to discover them. IGMP facilitates this process.

Reference: http://www.china-ccie.com/ccie/lilun/Multicast/Multicast.html

Multicast Packet Time-to-Live

When sending a message to a multicast group, all subscribed receivers at that host and port will receive the message (within the time-to-live of the data packet, see below). A socket does not need to be a member of the multicast group to send messages to it.

Most multicast packets have a low TTL: All IP packets have a “time-to-live” (TTL), which specifies the maximum number of times a packet can transit the network before reaching its destination. Unlike DNS records, TTL specifies the maximum number of network hops a packet can take. Unicast packets are usually allowed to traverse 30 networks (for example, being routed or “hopped” over 29 routers). Typically, jumping across a network should not exceed 15 hops, so a limit of 30 is often used to terminate poorly routed packets. However, many applications set a very low TTL when sending multicast, often 0 (thus, the message does not leave the device itself).

Setting TTL to 1 means it can only be sent to machines on the local network, setting it to 2 means it can only pass through one router. Few applications intend to multicast to unknown devices across an entire campus network, let alone the entire network.

Many routers have a very high TTL threshold: Many network routers, especially WAN routers and Internet gateway routers, have a high TTL threshold, so they do not forward multicast packets with low TTL, like 15. This prevents multicast from leaking out of the local network.

Routers are generally configured either not to forward any multicast packets, forward only specific addresses, or to block multicast packets entirely.

Whenever a multicast router forwards a multicast data packet, the TTL value in the packet decreases by 1. If the TTL of a data packet decreases to 0, the router will discard the data packet. The TTL value determines the maximum number of multicast routers a multicast can travel through. For example, if the TTL is 0, the multicast can only be shared between multiple sockets on the local host and not reach the “network cable.” If the TTL is 1 (default value), the data packet will be “ruthlessly” discarded by the first router it encounters, prohibiting it from extending beyond the local network—meaning only multicast group members on the same network can receive the multicast data.

Reference from Java documentation: http://udn.yyuap.com/doc/jdk6-api-zh/java/net/MulticastSocket.html

Java Multicast Example

MulticastSocket is a (UDP) DatagramSocket with additional capabilities for joining “groups” with other multicast hosts on the Internet.

To join a multicast group, you can first create a MulticastSocket using the desired port, and then call the joinGroup(InetAddress groupAddr) method:

Example code taken from:

http://colobu.com/2014/10/21/udp-and-unicast-multicast-broadcast-anycast/#0-tsina-1-67000-397232819ff9a47a7b7e80a40613cfe1

Monitoring with Wireshark

You can monitor multicast requests with Wireshark using the following filter condition

javascriptcopy

(eth.dst[0]&1)

Publisher: Full Stack Developer Leader, please credit: https://javaforall.cn/167030.html Original Link: https://javaforall.cn