Lecture 24: Multicasting Objectives:: Multicast Group
Lecture 24: Multicasting Objectives:: Multicast Group
Lecture 24: Multicasting Objectives:: Multicast Group
Objectives:
Learn what Multicasting is about
Learn about the IP Addresses used for Multicasting
Learn about the Internet Group Management Protocol (IGMP) used for
multicasting
Learn how C# supports multicasting
1.
What is Multicasting?
Broadcasting is an excellent way to send information to all devices on
a subnet. However, it has one serious drawback:
The broadcast packets are restricted to the local subnet.
Multicasting was designed to address this drawback.
Multicasting allows application programs to send a single packet to a
select subset of devices called a multicast group.
Each multicast group is identified by a single special IP address
discussed below.
A packet sent with the particular IP address as the destination address
will be received by each member of the group.
Multicast group is a dynamic group. That is, members can join and
leave the group at any time. Also members of a multicast group can
span across network boundaries.
Examples of application areas that can take advantage of multicasting
include videoconferencing, e-learning, stock quotes, news, etc.
2.
Multicast IP Addresses
IP multicasting uses a particular range of IP addresses to designate
different multicast groups.
The class D IP addresses in the range: 224.0.0.0 through
239.255.255.255 are used to represent multicast groups.
4.
System;
System.Net;
System.Net.Sockets;
System.Text;
while (true) {
data = new byte[1024];
int recv = sock.ReceiveFrom(data, ref remoteEP);
message = Encoding.ASCII.GetString(data, 0, recv);
Console.WriteLine("received: {0} from: {1}", message,
remoteEP.ToString());
}
}
}
System;
System.Net;
System.Net.Sockets;
System.Text;
String message;
while (true) {
Console.Write("Enter message to Multicast: ");
message = Console.ReadLine();
if (message=="")
break;
byte[] data = Encoding.ASCII.GetBytes(message);
sock.SendTo(data, endPoint);
}
sock.Close();
}
}
System;
System.Net;
System.Net.Sockets;
System.Text;
System;
System.Net;
System.Net.Sockets;
System.Text;
class UdpClientMulticastReceiver {
public static void Main()
{
using
using
using
using
System;
System.Net;
System.Net.Sockets;
System.Text;
class UdpClientMulticastSender {
public static void Main()
{
UdpClient sock = new UdpClient(9090);
IPEndPoint remoteEP = new
IPEndPoint(IPAddress.Parse("224.100.0.1"), 9090);
byte[] data;
string message;
while (true) {
Console.Write("Enter Message to Multicast: ");
message = Console.ReadLine();
if (message == "")
break;
data = Encoding.ASCII.GetBytes(message);
sock.Send(data, data.Length, remoteEP);
}
sock.Close();
}