broadcast and multicast

Post on 03-Jan-2016

43 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

Broadcast and Multicast. Unicast. Host 1. Host 2. Broadcast. Packet received by every host on network (including the sender!). Multicast. Packet received by a selected subset of hosts in the network. Root. Leaf. Leaf. Broadcast. Advantages Reducing Network Traffic - PowerPoint PPT Presentation

TRANSCRIPT

Broadcast and Multicast

Unicast

Host 2Host 1

BroadcastPacket received by every host on network (including the sender!)

MulticastPacket received by a selected subset of hosts in the network

Root

Leaf Leaf

Broadcast

• Advantages

– Reducing Network Traffic• Network Time Protocol (NTP), Route Broadcasts

– Resource Discovery• ARP, BOOTP

Broadcast…

• Disadvantage

– Everybody receives a packet, whether they want it or not.

• Receving a packet Interrupting your work and processing the packet.

Types of broadcast addresses

• IP Address can be broken down as

{netid, subnetid, hostid}

E.g. 130.245.224.19

130.245 Netid

224 subnet id

19 host id

Types of broadcast addresses…

• Subnet-directed broadcast

{netid, subnetid, *}E.g. 130.245.224.255

• Broadcasts to local subnet.

• Routers do not forward these types of broadcast.

Types of broadcast addresses…

• All-Subnet broadcast

{netid, *, *}E.g. 130.245.255.255

• Broadcasts to all subnets under netid

• Almost never used. May not be allowed for administrative reasons.

Types of broadcast addresses…

• Network directed broadcast

{netid, *}

• For networks without sub-netting

• Doesn’t exist anymore

Types of broadcast addresses…

• Limited broadcast address

{*, *, *}E.g. 255.255.255.255

• Older form of Subnet-directed broadcast

• Broadcasts to local subnet

• Never forwarded across routers.

How broadcast works

Sender

UDP

IPv4

Data Link

Receiver

UDP

IPv4

Data Link

UDP

IPv4

Data Link

X

Dest IP = 130.245.224.255Dest Port = 9999

Dest Ethernet addr ff:ff:ff:ff:ff:ff

Port 9999

Example Echo from Multiple Servers

int sockfd, on=1, len;

char recvline[MAXLILNE];

struct sockaddr_in reply_addr, bcastaddr;

sockfd = Socket(…);

/* Enable broadcast on socket */

Setsockopt(sockfd, SOL_SOCKET,SO_BROADCAST, &on, sizeof(on));

/* Set a receive timeout on socket */

tv.tv_sec = 5;

tv.tv_usec = 0;

Setsockopt( sockfd, SOL_SOCKET, SO_RCVTIMEO, (void *)&tv, sizeof(tv));

Initialize bcastaddr with IP = 130.245.224.255 and

Port = 9999

/* Broadcast a Hello */Sendto(sockfd, “Hello”, strlen(“Hello”), 0, (struct sockaddr

*)&bcastaddr, sizeof(bcastaddr));

/* Receive Echos from servers*/for(;;) {

len = sizeof(reply_addr);n = recvfrom (sockfd, recvline, MAXLINE, 0, &reply_addr, &len);if( n < 0) {

if (errno == EAGAIN) {printf(“Waited for 5 seconds - exiting\n”);

} else {perror(“ERROR”);

}exit(0);

}recvline[n] = 0;printf(“%s\n”, recvline);

}

Multicast

Multicast addresses

• Class D address : – 224.0.0.0 to 239.255.255.255

• Low order 28 bits identify a multicast group id.

• Link Local addresses :– 224.0.0.0 to 224.0.0.255– Reserved for network maintenance messages– Never forwarded by routers

• All-hosts group - 224.0.0.1

• All-routers group - 224.0.0.2

Multicast to Ethernet mapping

e

28-bit group ID

01 00 5e

Low order 23 bits

32 IP multicast groups map to one Ethernet level multicast group

How multicast works

Sender

UDP

IPv4

Data Link

Receiver

UDP

IPv4

Data Link

UDP

IPv4

Data Link

Dest IP = 224.0.1.1Dest Port = 9999

Dest Ethernet addr 01:00:5e:00:01:01

Port 9999

Join224.0.1.1

Receive01:00:5e:00:01:01

Managing multicast membership

• Five Socket options– IP_ADD_MEMBERSHIP

• Join a multicast group

– IP_DROP_MEMBERSHIP• Leave a multicast group

– IP_MULTICAST_IF• Specify a default interface for outgoing multicast

– IP_MULTICAST_TTL• Specify TTL for outgoing multicast

– IP_MULTICAST_LOOP• Enable or disable loopback of outgoing multicast

WAN Multicast

R1

R2

R3Sender

S1

S2

S3

S4

S – subnetR - Router - Receiver

top related