360 likes | 530 Views
Network Programming. Chapter 9: Multicast Sockets. Agenda. Unicasts, Broadcasts, Multicasts Application Models with Multicasting Architecture of Multicast Sockets Using Multicast Sockets with .NET Creating a Chat Application Creating a Picture Show Application. Introduction.
E N D
Network Programming Chapter 9: Multicast Sockets
Agenda • Unicasts, Broadcasts, Multicasts • Application Models with Multicasting • Architecture of Multicast Sockets • Using Multicast Sockets with .NET • Creating a Chat Application • Creating a Picture Show Application
Introduction • Multicasts can be used for group communications over the Internet, where every node participating in the multicast must join the group set up for the purpose • In multicasts, a sender sends a message to a GROUP of receivers (group distribution) • Broadcasts may be achieved via UDP • Multicasts may be achieved via UDP
Unicasts, Broadcasts and Multicasts • Introduction • IP Protocol supports • Unicast • Broadcast • Multicast • Unicast addresses • Broadcast addresses • Multicast addresses
Unicasts, Broadcasts and Multicasts • Introduction • Unicast addresses • Network packets sent to a single destination • Server maintains a separate connection for each client • TCP can only send unicast messages • UDP can send unicast messages (no reliability checks) • Broadcast addresses • Multicast addresses
Unicasts, Broadcasts and Multicasts • Introduction • Unicast addresses • Broadcast addresses • Broadcast datagrams are sent to all nodes in a subnetwork • Broadcasts always use UDP • Low overheads • No guarantee that message has been received • Broadcasts don’t cross subnets • Multicast addresses
Unicasts, Broadcasts and Multicasts • Introduction • Unicast addresses • Broadcast addresses • Multicast addresses • Multicast datagrams are sent to every node that belongs to a group (regardless of subnet) • Every host (node) that wants to receive multicast messages must register with the Internet Group Management Protocol (IGMP) • Class D addresses (224.0.0.0 to 239.255.255.255) are used for multicast gateways
Agenda • Unicasts, Broadcasts, Multicasts • Application Models with Multicasting • Architecture of Multicast Sockets • Using Multicast Sockets with .NET • Creating a Chat Application • Creating a Picture Show Application
Application Models with Multicasting Chat server/client Chat server/client • Many-to-Many Applications • Allows every system in a group to send data to every other system in the group • A multicast can be used • E.g. a peer-to-peer chat system (everyone in the group can see what everyone else is saying) • One-to-Many Applications Chat server/client Chat server/client Chat server/client
Application Models with Multicasting • Many-to-Many Applications • One-to-Many Applications • One system may send a message to a group of systems • This can be useful for video, audio or other large files/data types Sender Receiver Receiver Receiver Receiver Receiver
Agenda • Unicasts, Broadcasts, Multicasts • Application Models with Multicasting • Architecture of Multicast Sockets • Using Multicast Sockets with .NET • Creating a Chat Application • Creating a Picture Show Application
Architecture of Multicast Sockets • Introduction • Multicast messages send using UDP and class D addresses • Can also use IGMP to send multicast messages • IGMP • Multicast Address Allocation • Routing • Scoping • Routing Protocols • Scalability • Reliability • Security
IGMP • Part of IP module and allows clients to leave a group as well as join a group • IGMP = Internet Group Management Protocol • IGMP messages are encapsulated in IP datagrams with the IP protocol number 2. • Versions of IGMP • IGMP version 2 (IGMPv2): client can explicitly leave the group (and almost immediately) • IGMP version 3 (IGMPv3): RFC 3376 – http://www.ietf.org/rfc/rfc3376.txt ) Allows specific joins and leaves with the source address(es). Possible now to run Source-Specific Multicast (SSM) protocol.
Multicast Address Allocation • Class D address range • 224.0.0.0 to 239.255.255.255 • Special purpose range: 244.0.0.0 to 244.0.0.255 (cannot be used and routers will not pass these messages on) • RFC 3171 defines the use of specific ranges of IP multicast addresses and their purposes • Ways in which addresses can be allocated: • Static • Dynamic • Scope-relative
Multicast Address Allocation • Static Multicast Addresses • Usually are globally assigned by the IANA • Usually for messages that are of global interest • Used for protocols that need well-known addresses • IANA-assigned addresses may be hard-coded into applications and devices • Two blocks of static multicast addresses are used: • Local Network Control Block • Internetwork Control Block • Dynamic Multicast Addresses • Scope-Relative Multicast Addresses
Multicast Address Allocation • Static Multicast Addresses • Dynamic Multicast Addresses • Often better suited to circumstances than static address • Request-on-demand addresses have a “life-time” • Similar concept to DHCP • Multicast Address Dynamic Client Allocation Protocol (MADCAP) • MADCAP: the client sends a unicast or multicast message out to a MADCAP server to request a multicast address. The server answers with a lease-based address • Scope-Relative Multicast Addresses
Multicast Address Allocation • Static Multicast Addresses • Dynamic Multicast Addresses • Scope-Relative Multicast Addresses • Multicast addresses that are only used within a local group or organisation • Address range 239.0.0.0 to 239.255.255.255 is reserved for administrative scope-relative addresses. (These addresses can be reused with other local groups because the routers filter this address range out and prevent the message from leaving the local network)
Architecture of Multicast Sockets • Introduction • Multicast messages send using UDP and class D addresses • Can also use IGMP to send multicast messages • IGMP • Multicast Address Allocation • Routing • Scoping • Routing Protocols • Scalability • Reliability • Security
Routing • Multicast backbone (MBone) • Routers don’t necessarily implement multicasting (manufacturing issue) • Multicasting over the Internet • Multicast messages forwarded using unicast connections • MBone tools are available • MBone used for audio and video multicasts, technical talks, seminars, NASA space shuttle missions, etc • http://www.multicasttech.com/status
Scoping • Done via Class D addresses (issued by IANA) • TTL = 1 • Message does not leave the network • Each router that receives the group report decrements the TTL by 1
Routing Protocols • Distance Vector Multicast Routing Protocol (DVMRP): uses a reverse path-flooding algorithm, where the router sends a copy of the network packet out to all paths, except the one from which the packet originated. If no node in a router’s network is a member of the multicast group, the router sends a prune message back to the sending router so that it knows it does not need to receive packets for that multicast group. DVMRP periodically refloods attached networks to reach new nodes that may be added to the multicast group. DVMRP does not scale very well. • Multicast Open Shortest Path First (MOSPF) • Protocol-Independent Multicast (PIM)
Routing Protocols • Distance Vector Multicast Routing Protocol (DVMRP) • Multicast Open Shortest Path First (MOSPF): This protocol is an extension of the Open Shortest Path First (OSPF) Protocol. With MOSPF, all routers must be aware of all available links to networks hosting members of multicast groups. MOSPF calculates routes when multicast traffic is received. This protocol can be used only in networks where OSPF is used as a unicast routing protocol, because MOSPF routes are exchanged between routers using OSPF. MOSPF does not scale well if many multicast groups are used or if groups change often. • Protocol-Independent Multicast (PIM)
Routing Protocols • Distance Vector Multicast Routing Protocol (DVMRP) • Multicast Open Shortest Path First (MOSPF) • Protocol-Independent Multicast (PIM): This protocol uses two different algorithms for sending messages to group members. When the members are widely distributed across different networks, PIM-SM (Sparse Mode) is employed; when a group uses only a few networks, PIM-DM (Dense Mode) is used. PIM-DM uses a reverse path-flooding algorithm similar to DVMRP, except that any unicast routing protocol can be used. PIM-SM defines a registration point for proper routing of packets.
Architecture of Multicast Sockets • Introduction • Multicast messages send using UDP and class D addresses • Can also use IGMP to send multicast messages • IGMP • Multicast Address Allocation • Routing • Scoping • Routing Protocols • Scalability • Reliability • Security
Scalability • It is an advantage of multicasting • Multicasting is the most efficient and scalable way to send messages to multiple clients • Broadcasting has the disadvantage that messages cannot cross networks and that clients who are not interested pick up the broadcast as well.
Reliability • IP multicasting does not offer any compatible transport-level protocol that is both reliable and implements a flow mechanism • UDP offers no guarantees • Sometimes need a highly reliable mechanism for transporting packets (e.g. multicasting an application to several workstations simultaneously) • If guaranteed delivery is needed, then must use custom handshaking using a reliable protocol • Add packet numbers • Add a checksum • If the receiver detects a corrupted message, it sends a NACK message to the sender
Security • Multicasting security • Internet multicasting vs Intranet multicasting • Firewall prevents “leaks” into Internet • Clients need to register with group • Internet Engineering Task Force (IETF) working group working on Multicast Security (MSEC) proposal • Multicast Group Key management • http://www.ietf.org/internet-drafts/draft-ietf-msec-gkmarch-08.txt
Agenda • Unicasts, Broadcasts, Multicasts • Application Models with Multicasting • Architecture of Multicast Sockets • Using Multicast Sockets with .NET • Creating a Chat Application • Creating a Picture Show Application
Using Multicast Sockets with .NET • Multicast Sender Applications • No special tasks • Use the UdpClient class • Use a multicast address • IPEndPoint object, remoteEP, will point to the group address and the port number that will be used by the group • Multicast address must be known to clients joining the group • Can use a MADCAP server to get addresses dynamically • Use a stream socket that the client connects to, to tell the client about the multicast address • Multicast Receiver Applications
Using Multicast Sockets with .NET • Multicast Sender Applications • Multicast Receiver Applications • Using the UdpClient Class • Need to program UdpClient Class • Clients must join the multicast group • Need to be able to drop a group member • Using the Socket Class • May use the Socket class instead of UdpClient class • A UDP socket is created (AddMembership and MulticastTimeToLive are programmable options) • IGMP protocol is implemented
Agenda • Unicasts, Broadcasts, Multicasts • Application Models with Multicasting • Architecture of Multicast Sockets • Using Multicast Sockets with .NET • Creating a Chat Application • Creating a Picture Show Application
Creating a Chat Application • Setting Up the User Interface • Creating the Configuration File • Joining the Multicast Group • Receiving Multicast Messages • Sending Multicast Messages • Starting the Chat Application
Agenda • Unicasts, Broadcasts, Multicasts • Application Models with Multicasting • Architecture of Multicast Sockets • Using Multicast Sockets with .NET • Creating a Chat Application • Creating a Picture Show Application
Creating a Picture Show Application • Creating a Picture Protocol • Building the Picture Show Server • Creating the Picture Show Client • Starting the Picture Show