Vous êtes sur la page 1sur 22

CSCI 5273 Computer Networks Stevens, Chapter 12 & 13 Broadcast & Multicast with IGMP

Dirk Grunwald Assoc. Professor Dept. of Computer Science University of Colorado, Boulder

Using Broadcast
u UDP
l

broadcast involves sending to explicit broadcast addresses


Most POSIX implementations require you explicitly enable broadcast ret = setsockopt(sockfd, SOL_SOCKET, SO_BROADCAST, &on, sizeof(on));

u Only

applicable to UDP!

Broadcast Addresses
u Limited
l

Net Broadcast - 255.255.255.255

Never forwarded by a router!

u Net-directed
l

Broadcast - e.g., 128.138.255.255

A router must forward a net-directed broadcast, but must have an option to disable this.

u Subnet-directed

Broadcast - e.g., 128.138.202.255

Multicast
u Class
l

D addresses are multicast addresses

224.0.0.0 through 239.255.255.255

uA

specific multicast address defines a network group

u Two

special network groups l 224.0.0.xxx is never routed l 224.0.0.1 - all hosts group l 224.0.0.2 - all routers group

Well-defined multicast groups


u ntp.mcat.net is 224.0.1.1
l

Network time protocol

Joining a Multicast Group prior to receive


// // Set socket option to to joint mcast // { struct ip_mreq mreq; ip_ mreq; memcpy(&mreq.imr_multiaddr, memcpy(&mreq.imr_multiaddr, &from_addr.sin_addr.s_addr, &from_addr.sin_addr.s_addr, sizeof(struct in_addr)); sizeof( in_addr));

Desired multicast group

mreq.imr_interface.s_addr = htonl(INADDR_ANY); mreq.imr_interface.s_addr htonl(INADDR_ANY); ret = setsockopt(sockfd, IPPROTO_IP, IP_ADD_MEMBERSHIP, setsockopt(sockfd, &mreq, sizeof(mreq)); &mreq, sizeof(mreq)); check_and_exit(ret, "setsockopt"); check_and_exit(ret, "setsockopt"); }

Using TTL to define multicast scope


u TTL

field is used to limit propogation of multicast packets u In IPv4


l l l l

0 - node local - doesnt leave machine 1 - link local - doesnt get routed <32 - site local - .But whats a site? <255 - global - The world

Setting a TTL scope


// // // Set socket option to to joint mcast // { u_char ttl = 16; ret = setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, setsockopt(sockfd, &ttl, sizeof(ttl)); &ttl, sizeof(ttl)); check_and_exit(ret, "setsockopt"); check_and_exit(ret, "setsockopt"); }

Desired TTL field

Administrative Scoping
u 239.xxx.yyy.zzz

space
l

is the administratively scope multicast IP

Addresses assigned locally to an organization, but not unique across organizations Border routers must not forward

u link-local

-- 224.0.0.0 to 224.0.0.255 u site-local -- 239.255.0.0 to 239.255.255.255 u organization-local - 239.192.0.0 to 239.195.255.255 u global -- 224.0.1.0 to 238.255.255.255

Converting Multicast to Ethernet


u Multicast
l

addresses are targeted to a number of clients

How does the ethernet card know which messages to receive? Takes the same amount of network bandwidth as selective multicast, but.. Disturbs all machines

u Could simple broadcast all packets


l

u Can
l

use ARP to advertise single MAC as resolving multiple IP addresses


..But multiple machines want to receive

Mapping a Multicast Address to Ethernet Address


u Ethernet

cards can usually receive on multiple MAC addresses u Multicast router enters a virtual MAC address, clients receive on that virtual MAC
1110 0000

0000 0001 0000 0000 0101 1110 0

Digression - Virtual IP Addresses


u alias
l l

alias_address[/bitmask]

Establishes an additional network address for this interface. Eample: ifconfig eth0 alias 128.138.241.79/26

u The following aliaslist

command adds network addresses 40 through 50, inclusive, to subnets 18.240.32, 18.240.64, and 18.240.96
ifconfig aliaslist 18.240.32,64,96.40-50

u Doesnt

require multiple MAC addresses, but often implemented using them.

IGMP - Internet Group Management Protocol


u Part of IP layer u Lets

hosts & routers know who belongs to what groups

IP Header (20 bytes)

IGMP Message (8 bytes)

IGMP Message Format


Version(1) Type(1-2) MBZ 16-bit checksum

32-bit group address (Class D IP address)

u Type
l l

1 is a query sent by multicast router 2 is a reponse sent by a host

u Group
l l

address is a class D IP address

On query, its zero On response, its the group address being reported

IGMP Host Reports


u u

Host sends a report when it joins a group Doesnt report when it leaves the group, but doesnt respond to next query
IGMP report, TTL =1 IGMP group addr = group address dest IP addr = group address src IP addr = hosts IP address

Host

Router

IGMP Router Query


u u

Router sends query at regular intervals to see if anyone still belongs to any groups. Queries sent out each interface. Host responds by sending one response IGMP query, TTL =1 for each group to which it belongs
IGMP group addr = 0.0.0.0 dest IP addr = 224.0.0.1 src IP addr = routers IP address

Host

Router

Sample Query on Windows Bootup


05:52:32.517937 arp who-has 192.168.1.6 tell 192.168.1.6 05:52:32.518010 linux > 192.168.1.6: icmp: echo request 05:52:33.378928 192.168.1.6 > ALL-ROUTERS.MCAST.NET: icmp: router solicitation 05:52:37.511385 arp who-has 192.168.1.6 tell linux 05:52:37.511664 arp reply 192.168.1.6 is-at 0:a0:cc:3b:95:4b 05:52:38.453193 192.168.1.6 > ALL-ROUTERS.MCAST.NET: icmp: router solicitation 05:52:43.477432 192.168.1.6 > ALL-ROUTERS.MCAST.NET: icmp: router solicitation

Multicast Routes

Sender Sends Datagram With Specified TTL


Pruned because no one is listening

Receiver Starts Joins group

Routers Form Destination Tree

Non-participants prune themselves

Vous aimerez peut-être aussi