Transcript lesson15
A look at IP-multicasting
We propose a programming
project to acquaint ourselves with
TCP/IP ‘multicast’ capabilities
Multicast IP addresses
32-bits
Address Range
0
Class A address
0.0.0.0 - 127.255.255.255
10
Class B address
128.0.0.0 - 191.255.255.255
110
Class C address
192.0.0.0 - 223.255.255.255
MULTICAST address
224.0.0.0 - 239.255.255.255
Reserved
240.0.0.0 - 247.255.255.255
1110
11110
The range of IPv4 Network-Layer Addresses is subdivided into “classes”
based on the high-order bits in these 32-bit addresses, with those which
begin with “1110” (the Class D addresses) being allocated to multicasting
Multicast Groups
• The remaining 28-bits of an IP multicast
address are used to identify the “group”
that a datagram should be delivered to
• There are some special multicast groups
whose addresses you should avoid using
– 224.0.0.1 (the all-hosts group)
– 224.0.0.2 (the all-routers group)
– 224.0.0.3 (address-purpose is unassigned)
– 224.0.0.x (for local administration purpose)
Our multicast group
• Multicast applications should not use any
multicast-addresses in the ‘special’ range
(i.e., 224.0.0.0 – 224.0.0.255) designated
for use by utilities devoted to maintenance
and administration of the local network
• So our example-programs define a ‘group’
whose IP-address lies outside this range,
namely: 224.3.3.6 (easily remembered?)
The ‘multicast’ concept
Host A
Host B
Host C
Host D
Host E
Local Area Network
With IP-broadcasting, a datagram whose destination-address is equal
to 255.255.255.255 will be received by every host on the local network
Host A
Host B
Host C
Host D
Host E
Local Area Network
With IP-multicasting, a datagram whose destination-address is equal
to 224.3.3.6 would be received only by those hosts on the local network
that have chosen to become ‘members’ of this specific multicast-group
Routers
Host A
Host B
Host C
Host D
Host E
Modern routers do not ‘forward’
broadcast datagrams, but they
can be configured to ‘forward’
any multicast datagrams
Router
X
Router
Y
Host I
Host J
Host K
Host L
Host M
Host F
Host N
Host G
Host O
Host H
(Older routers can use ‘tunneling’)
Host P
The socket API
• Programming languages that support the
‘sockets’ interface can allow you to write
client-and-server ‘multicast’ applications
server
client
client
client
client
But obviously the TCP ‘connection-based’ protocol is NOT used in multicasting!
A Python example
• We put up a very simple client-and-server
multicast application on our class website,
written in Python (for brevity)
– ‘multisend.py’ (the ‘server’ program)
– ‘multirecv.py’ (the ‘client’ program)
• The server just sends a ‘Hello’ message to
current group-members once each second
• The client can be run on multiple hosts
Project #2
• Write a multicast server-program (named
‘deadline.cpp’) that periodically sends out
reminder-messages about upcoming duedates for course-assignments or exams
• Write the multicast client-program (named
‘timeleft.cpp’) that a student who desires
to receive reminders can use to ‘join’ the
server’s multicast-group
The C++ versions
• Your programs are required to be written in
the C++ language, so we have put the
rewritten versions of our ‘multisend’ and
‘multirecv’ application-programs on the
class website as demonstration examples
Organization
‘multirecv.cpp’
socket()
‘multisend.cpp’
setsockopt( REUSEADDR )
socket()
bind()
setsockopt( ADDMEMBERSHIP )
sleep( 1 )
sendto()
recv()
puts()
‘Unique’ group-address
• For developing your own application, you
will be sharing our local USF networks as
the hardware ‘testbed’ for your C++ code
• You’ll be annoyed if everyone’s messages
arrive and get displayed on your screen!
• So we need a different IP-multicast group
address for each classmember
224.3.36.xxx
‘xxx’ equals 100 plus your number on
the Instructor’s class-list (you can find
it handwritten on your Midterm Exam)