MulticastListener.java - A Simple Multicast Listener Program

This section provides a tutorial example on how to write a simple Java test program to join any given multicast group and listen to incoming messages.

In order to find out more information about the MS08-001 vulnerability and its relation with multicast communication, I wrote a very simple test program, MulticastListener.java, to join any given multicast group and listen for incoming messages:

/**
 * MulticastListener.java
 * Copyright (c) 2008 by Dr. Herong Yang, http://www.herongyang.com/
 */
import java.io.*;
import java.net.*;
public class MulticastListener {
   public static void main(String[] args) {
      if (args.length < 2) {
         System.out.println
            ("Usage: java MulticastListener 224.0.0.1 Herong");
         return;
      }
      String ip = args[0];
      String name = args[1];;
      int port = 6789;
      try {
         InetAddress group = InetAddress.getByName(ip);
         MulticastSocket s = new MulticastSocket(port);
         s.joinGroup(group);

         String msg = "Greeting from "+name;
         System.out.println("Sending out: "+msg);
         DatagramPacket data = new DatagramPacket(
            msg.getBytes(), msg.length(), group, port);
         s.send(data);
         
         byte[] buffer = new byte[10*1024];
         data = new DatagramPacket(buffer, buffer.length);
         while (true) {
            s.receive(data);
            System.out.println("Received: "+ 
               (new String(buffer, 0, data.getLength())));
         }
      } catch (IOException e) {
         System.out.println(e.toString());
      }
   }
}

I compiled and ran the program on my Windows XP system. Here is the output:

C:\herong>javac MulticastListener.java

C:\herong>java MulticastListener 224.0.0.1 Herong
Sending out: Greeting from Herong
Received: Greeting from Herong
Received: Greeting from Herong

2 interesting notes:

In the next test, I used multicast IP address that is not reserved for any special purposes, 224.0.0.3 I compiled and ran the program on my Windows XP system. Here is the output:

C:\herong>java MulticastListener 224.0.0.3 Herong
Sending out: Greeting from Herong
Received: Greeting from Herong

This test proves that my system with 2 IP interfaces, Wireless and Ethernet, connected to the same physical network, provided by my wireless hub, will receive 2 copies of messages multi casted to the All Hosts Multicast Group, 224.0.0.1.

I started another command window and run "java MulticastListener 224.0.0.3 Guest". On my first command window, I got the greeting message from Guest correctly:

C:\herong>java MulticastListener 224.0.0.3 Herong
Sending out: Greeting from Herong
Received: Greeting from Herong
Received: Greeting from Guest

Table of Contents

 About This Windows Security Book

 Windows 8: System Security Review

 Windows 8: System Security Protection

 Windows 8 System Recovery

 Windows 8 Defender for Real-Time Protection

 Windows 7: System Security Review

 Windows 7: System Security Protection

 Windows 7 System Recovery

 Windows 7 Forefront Client Security

 Norton Power Eraser - Anti-Virus Scan Tool

 McAfee Virus and Malware Protection Tools

 Spybot - Spyware Blocker, Detection and Removal

 Keeping Firefox Secure

 Keeping IE (Internet Explorer) Secure

 Malware (Adware, Spyware, Trojan, Worm, and Virus)

 HijackThis - Browser Hijacker Diagnosis Tool

 IE Add-on Program Listing and Removal

 "Conduit Search" - Malware Detection and Removal

 "Tube Dimmer", "Scorpion Saver" or "Adpeak" Malware

 Malware Manual Removal Experience

 Vundo (VirtuMonde/VirtuMundo) - vtsts.dll Removal

 Trojan and Malware "Puper" Description and Removal

 VSToolbar (VSAdd-in.dll) - Description and Removal

 PWS (Password Stealer) Trojan Infection Removal

MS08-001 Vulnerability on Windows Systems

 MS08-001 - Vulnerability in TCP/IP

 IP Multicast and IP Address Range

 "netsh" Commands for Interface IP

 224.0.0.1 - The All Hosts Multicast Group

MulticastListener.java - A Simple Multicast Listener Program

 All Hosts Multicast Group, 224.0.0.1, on Vista Systems

 MS08-001 Vulnerability Explanation by Microsoft

 Antivirus System PRO

 References

 Full Version in PDF/ePUB