Upload
sana-khan
View
236
Download
0
Embed Size (px)
Citation preview
8/3/2019 Stevens Chap12 Cast
1/22
CSCI 5273
Computer Networks
Stevens, Chapter 12 & 13Broadcast & Multicast
with IGMP
Dirk Grunwald
Assoc. ProfessorDept. of Computer Science
University of Colorado, Boulder
8/3/2019 Stevens Chap12 Cast
2/22
Using Broadcast
u UDP broadcast involves sending to explicit broadcastaddresses
l Most POSIX implementations require you explic itly enablebroadcast
ret = setsockopt(sockfd, SOL_SOCKET,SO_BROADCAST, &on, sizeof(on));
u Only applicable to UDP!
8/3/2019 Stevens Chap12 Cast
3/22
Broadcast Addresses
u Limited Net Broadcast - 255.255.255.255
l Never forwarded by a router!
u Net-directed Broadcast - e.g., 128.138.255.255l 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
8/3/2019 Stevens Chap12 Cast
4/22
Multicast
u Class D addresses are mult icast addresses
l 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 routedl 224.0.0.1 - all hosts group
l 224.0.0.2 - all routers group
8/3/2019 Stevens Chap12 Cast
5/22
Well-defined multicast groups
u ntp.mcat.net is 224.0.1.1
l Network time protocol
8/3/2019 Stevens Chap12 Cast
6/22
////
// Set socket option to to joint// Set socket option to to joint mcastmcast
////
{{
struct ipstruct ip__mreq mreqmreq mreq;;
memcpymemcpy(&(&mreqmreq..imrimr__multiaddrmultiaddr,,
&from_&from_addraddr.sin_.sin_addraddr.s_.s_addraddr,,
sizeofsizeof((structstruct in_in_addraddr));));
mreqmreq..imrimr_interface.s__interface.s_addraddr == htonlhtonl(INADDR_ANY);(INADDR_ANY);
retret == setsockoptsetsockopt((sockfdsockfd, IPPROTO_IP, IP_ADD_MEMBERSHIP,, IPPROTO_IP, IP_ADD_MEMBERSHIP,
&&mreqmreq,, sizeofsizeof((mreqmreq));));
check_and_exit(check_and_exit(retret, ", "setsockoptsetsockopt");");
}}
Joining a Multicast Group prior to receive
Desired multicast
group
8/3/2019 Stevens Chap12 Cast
7/22
Using TTL to define multicast scope
u TTL field is used to limit propogation of mult icast packets
u In IPv4
l 0 - node local - doesnt leave machine
l 1 - link local - doesnt get routedl
8/3/2019 Stevens Chap12 Cast
8/22
////
////
// Set socket option to to joint// Set socket option to to joint mcastmcast
////
{{
u_charu_char ttlttl = 16;= 16;
retret == setsockoptsetsockopt((sockfdsockfd, IPPROTO_IP, IP_MULTICAST_TTL,, IPPROTO_IP, IP_MULTICAST_TTL,
&&ttlttl,, sizeofsizeof((ttlttl));));
check_and_exit(check_and_exit(retret, ", "setsockoptsetsockopt");");
}}
Setting a TTL scope
Desired TTL
field
8/3/2019 Stevens Chap12 Cast
9/22
Administrative Scoping
u 239.xxx.yyy.zzz is the administratively scope mult icast IPspace
l Addresses assigned locally to an organization, but not uniqueacross organizations
l 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.255u global -- 224.0.1.0 to 238.255.255.255
8/3/2019 Stevens Chap12 Cast
10/22
Converting Multicast to Ethernet
u Multicast addresses are targeted to a number of clients
l How does the ethernet card know which messages to receive?
u Could simple broadcast all packets
l Takes the same amount of network bandwidth as selectivemulticast, but..
l Disturbs all machines
u Can use ARP to advertise single MAC as resolving
multiple IP addressesl ..But multiple machines want to receive
8/3/2019 Stevens Chap12 Cast
11/22
u Ethernet cards can usually receive on mult iple MACaddresses
u Multicast router enters a virtual MAC address, clients
receive on that virtual MAC
1110 0000
00101 11100000 00000000 0001
Mapping a Multicast Address toEthernet Address
8/3/2019 Stevens Chap12 Cast
12/22
Digression - Virtual IP Addresses
u alias alias_address[/bitmask]
l Establishes an additional network address for this interface.
l Eample:ifconfig eth0 alias 128.138.241.79/26
u The following aliaslist command adds network addresses40 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 oftenimplemented using them.
8/3/2019 Stevens Chap12 Cast
13/22
IGMP - Internet Group ManagementProtocol
u Part of IP layer
u Lets hosts & routers know who belongs to what groups
IP Header
(20 bytes)
IGMP
Message (8 bytes)
8/3/2019 Stevens Chap12 Cast
14/22
IGMP Message Format
Version(1) Type(1-2) MBZ 16-bit checksum
32-bit group address (Class D IP address)
u Typel 1 is a query sent by multicast router
l 2 is a reponse sent by a host
u Group address is a class D IP address
l On query, its zero
l On response, its the group address being reported
8/3/2019 Stevens Chap12 Cast
15/22
IGMP Host Reports
Host Router
u Host sends a report when it joins a group
u Doesnt report when it leaves the group, but doesnt respond tonext query
IGMP report, TTL =1IGMP group addr = group address
dest IP addr = group address
src IP addr = hosts IP address
8/3/2019 Stevens Chap12 Cast
16/22
IGMP Router Query
Host Router
u Router sends query at regular intervals to see if anyone sti llbelongs to anygroups. Queries sent out each interface.
u Host responds by sending one responsefor each group to which it belongs IGMP query, TTL =1
IGMP group addr = 0.0.0.0
dest IP addr = 224.0.0.1
src IP addr = routers IP address
8/3/2019 Stevens Chap12 Cast
17/22
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 solicitation05:52:43.477432 192.168.1.6 > ALL-ROUTERS.MCAST.NET:
icmp: router solicitation
8/3/2019 Stevens Chap12 Cast
18/22
Multicast Routes
8/3/2019 Stevens Chap12 Cast
19/22
Sender Sends DatagramWith Specified TTL
Pruned
because no
one is
listening
8/3/2019 Stevens Chap12 Cast
20/22
Receiver Starts Joins group
8/3/2019 Stevens Chap12 Cast
21/22
Routers Form Destination Tree
8/3/2019 Stevens Chap12 Cast
22/22
Non-participants prune themselves