Presentation is loading. Please wait.

Presentation is loading. Please wait.

Multicast Sockets What is a multicast socket?

Similar presentations


Presentation on theme: "Multicast Sockets What is a multicast socket?"— Presentation transcript:

1 Multicast Sockets What is a multicast socket?
unicast sockets provide a point to point connection. There is one sender and one receiver. Multicast sockets have one sender and many receivers

2 Unicast vs. Multicast

3 Why doesn’t everyone use Mcast sockets?
Not all routers will pass Multicast sockets. Multicasting may not be supported on your network. TTLs limit a packets spread. TTL = max # of routers a packet is allowed to cross.

4 What are some Applications for Mcast?
appliances can look for a lookup server MCast. suppose I plug in a PNP printer MCast is good for discovery Unicast is good for correspondance. Etherswitch does a kind of routing that protects net legs from traffic.

5 IP multicast service model
RFC1112 : Host Extensions for IP Multicasting Senders transmit IP datagrams to a "host group" Members of host group could be present anywhere in the Internet Members join and leave the group and indicate this to the routers Senders and receivers are distinct Routers listen to all multicast addresses and use multicast routing protocols to manage groups

6 IP multicast group address
receivers can be anywhere Class D address space high-order three 3bits are set ~ Some well-known address have been designated RFC1700 ~

7 Link-Layer Multicast Addresses
Ethernet and other LANs using 802 addresses: 1 28 bits 23 bits IP multicast address Group bit 0x01005e LAN multicast address Lower 23 bits of Class D address are inserted into the lower 23 bits of MAC address (see RFC 1112)

8 Multicast Announcement (Lookup initiated discovery)
Discoverer Lookup Service 1. Announcements (sent via UDP Multicast) IP Address port:4160 2. Request Message (sent via TCP unicast) 3. Response Message (Sent via TCP unicast)

9 Lookup Service Client Lookup Service Service Object Service Attributes
1. Query the Lookup service 2. Gets Service Proxy Service Provider Client Service Object Service Attributes 3. Interact with service

10 Source distribution tree
Notation: (S, G) S = Source G = Group B A D F C E R R Receiver 1 Receiver 2

11 Protocol Characteristics
Multicast UDP to IP , port 4160 Interval secs. Multicast Packet length never to exceed 512 bytes.

12 Etherswitch/mcast Etherswitch passes all mcast traffic through.
Etherswitch isolates only unicast traffic. Ethernet 10 mbps – 100 mpbs 1Gbps 10 Gb/s. Now we can do VIDEO on the Ethernet.

13 Broadcast Video CCIR-601 Standard Video
720-x480 pixels at 16 bits per PEL at 30 Frames per second. 160 Mb/s, uncompressed. Suppose you don’t use a video camera to make video!

14 What is video? Image sequences + audio How can I make image sequences?
Screen capture….are almost NOISE FREE. Inter-frame coherence. Difference frames can be coded efficiently.

15 Java Net Classes Class Description DatagramPacket
This class represents a datagram packet. DatagramSocket This class represents a socket for sending and receiving datagram packets. InetAddress This class represents an Internet Protocol (IP) address. MulticastSocket The multicast datagram socket class is useful for sending and receiving IP multicast packets. ServerSocket This class implements server sockets. Socket This class implements client sockets (also called just "sockets"). URL A pointer to a "resource" on the World Wide Web. URLConnection The superclass of all classes that represent a communications link between an application and a URL.

16 Class InetAddress public boolean equals(Object obj); public byte[] getAddress(); public static InetAddress[] getAllByName(String host); public static InetAddress getByName(String host); public String getHostName(); public static InetAddress getLocalHost(); public int hashCode(); public String toString(); This class represents an Internet Protocol (IP) address. Applications should use the methods getLocalHost(), getByName(), or getAllByName() to create a new InetAddress instance.

17 IP Multicast in Java Java has a Multicast Socket Class
Use it to “join” a multicast group. MulticastSocket s = null; InetAddress group = null; try { group = InetAddress.getByName(“ ”); s = new MulticastSocket(5555); s.joinGroup(group); } catch (UnknownHostException e) { } catch (IOException e) { }

18 IP Multicast in Java Receive DatagramPackets on a MulticastSocket
DatagramPacket recv = new DatagramPacket(buf, buf.length); try { s.receive(recv); } catch (IOException e) { System.out.println("mcastReceive: " + e.toString()); return; } // get message String msg = new String(recv.getData(), recv.getOffset(), recv.getLength());

19 IP Multicast in Java To send, just send a DatagramPacket to the multicast address, port (no need to use a MulticastSocket, although you could) group = InetAddress.getByName(“ ”); s = new DatagramSocket(); DatagramPacket snd = new DatagramPacket(buf, buf.length, group, 5555); try { s.send(snd); } catch (IOException e) { System.out.println("mcastSend: " + e.toString()); return; }

20 Class Socket // Constructors (partial list) public Socket()
public Socket(InetAddress address, int port); public Socket(String host, int port); // Methods (partial list) public void close(); public InetAddress getInetAddress(); public int getLocalPort(); public InputStream getInputStream(); public OutputStream getOutputStream(); public int getPort(); public String toString();

21 Class Socket This class implements client sockets (also called just sockets). A socket is a end point for communication between two machines. The actual work of the socket is performed by an instance of the SocketImpl class. It is possible to modify some TCP parameters: SO_LINGER SO_TIMEOUT TCP_NODELAY Enable/disable TCP_NODELAY (disable/enable Nagle's algorithm).

22 Class ServerSocket // Constructors (partial list)
public ServerSocket(int port); public ServerSocket(int port, int count); // Methods (partial list) public Socket accept(); public void close(); public InetAddress getInetAddress(); public int getLocalPort(); public String toString();

23 Class ServerSocket A ServerSocket waits for requests to come in over the network. It performs some operation based on that request, and then possibly returns a result to the requester. The actual work of the ServerSocket is performed by an instance of the SocketImpl class. The abstract class SocketImpl is a common superclass of all classes that actually implement sockets. It is used to create both client and server sockets. A plain socket implements the SocketImpl methods exactly as described, without attempting to go through a firewall or proxy.

24 UDP Based Applications
UDP - unreliable packet based delivery service. The basic unit of transfer is called a Datagram. Datagrams are small, fixed-length messages. Datagram based services do have some advantages: Speed Message-oriented service.

25 Datagrams Datagram packets - implement a connectionless, packet based, delivery service. messages are routed based packet content. Multiple packets sent from one machine to another might be routed differently, and might arrive in any order. Packets may be lost or duplicated during transit. The class DatagramPacket represents a datagram in Java.

26 Class DatagramPacket //Constructors
public DatagramPacket(byte ibuf[], int ilength); public DatagramPacket( byte ibuf[], int ilength, InetAddress iaddr, int iport); // Methods public synchronized InetAddress getAddress(); public synchronized int getPort(); public synchornized byte[] getData(); int getLength(); void setAddress(InetAddress iaddr); void setPort(int iport); void setData(byte ibuf[]); void setLength(int ilength);

27 Class DatagramSocket class represents a socket for sending/receiving datagrams. Addressing information in the packet header. A socket are bound to an address There is no special datagram server socket class. packets can be lost, timeouts are important.

28 Class DatagramSocket // Constructors DatagramSocket()
DatagramSocket(int port) DatagramSocket(int port, InetAddress iaddr) // Methods void close() InetAddress getLocalAddress() int getLocalPort() int getSoTimeout() void receive(DatagramPacket p) void send(DatagramPacket p) setSoTimeout(int timeout)

29 Echo Services A common network service is an echo server
An echo server simply sends packets back to the sender A client creates a packet, sends it to the server, and waits for a response. Echo services can be used to test network connectivity and performance. There are typically different levels of echo services. Each provided by a different layer in the protocol stack.

30 UDPEchoClient.java import java.net.*; import java.io.*; import java.util.*; public class UDPEchoClient { static int echoPort = 7; static int msgLen = 16; static int timeOut=1000; public static void main(String argv[]) { try { DatagramSocket sock = new DatagramSocket(); DatagramPacket pak; byte msg[] = new byte[msgLen]; InetAddress echoHost = InetAddress.getByName(argv[0]); pak = new DatagramPacket(msg,msgLen,echoHost,echoPort); sock.send(pak); sock.setSoTimeout(timeOut); sock.receive(pak); } catch (InterruptedIOException e) {System.out.println("Timeout");} catch (Exception e) {} }}


Download ppt "Multicast Sockets What is a multicast socket?"

Similar presentations


Ads by Google