Block 14 Group Communication (Multicast)

Slides:



Advertisements
Similar presentations
Universidad de Chile - Tupper 2007, Santiago - Fono: Fax: Módulo 9: Desarrollo de Aplicaciones.
Advertisements

Jan Java Networking UDP Yangjun Chen Dept. Business Computing University of Winnipeg.
2: Application Layer 1 Socket programming Socket API r introduced in BSD4.1 UNIX, 1981 r explicitly created, used, released by apps r client/server paradigm.
Universidad de Chile - Tupper 2007, Santiago - Fono: Fax: Módulo 9: Desarrollo de Aplicaciones.
Socket Programming.
User Datagram Protocol. Introduction UDP is a connectionless transport protocol, i.e. it doesn't guarantee either packet delivery or that packets arrive.
1 Java Networking – Part I CS , Spring 2008/9.
1 L53 Networking (2). 2 OBJECTIVES In this chapter you will learn:  To understand Java networking with URLs, sockets and datagrams.  To implement Java.
1 Overview r Socket programming with TCP r Socket programming with UDP r Building a Web server.
Java Socket Support Presentation by: Lijun Yuan Course Number: cs616.
System Programming Practical session 10 Java sockets.
1 Server-Client communication without connection  When the communication consists of sending and/or receiving datagram packets instead of a data stream.
2: Application Layer1 Socket Programming. 2: Application Layer2 Socket-programming using TCP Socket: a door between application process and end- end-transport.
Datagram Programming A datagram is an independent, self-contained message sent over the network whose arrival, arrival time, and content are not guaranteed.
2: Application Layer 1 Socket Programming TCP and UDP.
Building an ftp client and server using sockets we now know enough to build a sophisticated client/server application!  ftp  telnet  smtp  http.
CS 352-Socket Programming & Threads Dept. of Computer Science Rutgers University (Thanks,this slides taken from er06/
CS4273: Distributed System Technologies and Programming I Lecture 5: Java Socket Programming.
IX. Multicast Sockets.
Multicast Sockets What is a multicast socket?
2: Application Layer1 Socket programming Socket API r introduced in BSD4.1 UNIX, 1981 r explicitly created, used, released by apps r client/server paradigm.
 Socket  The combination of an IP address and a port number. (RFC 793 original TCP specification)  The name of the Berkeley-derived application programming.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae david streader, VUW Echo Networking COMP
UDP vs TCP UDP Low-level, connectionless No reliability guarantee TCP Connection-oriented Not as efficient as UDP.
RGEC MEERUT(IWT CS703) 1 Java Networking RGEC Meerut.
Distributed Systems Concepts and Design Chapter 4.
Lecture 9 Network programming. Manipulating URLs URL is an acronym for Uniform Resource Locator and is a reference (an address) to a resource on the Internet.
Lector: Aliyev H.U. Lecture №10 Multicast network software design TASHKENT UNIVERSITY OF INFORMATION TECHNOLOGIES THE DEPARTMENT OF DATA COMMUNICATION.
UDP User Datagram Protocol. User Datagram Protocol (UDP) UDP is the protocol available to network programmers who wish to send datagrams UDP datagrams.
L 2 - 1 3( 1/ 20) : Java Network Programming. The Socket API The previous contents describe client-server interaction that application programs use when.
 2003 Joel C. Adams. All Rights Reserved. Calvin CollegeDept of Computer Science(1/11) Java Sockets and Simple Networking Joel Adams and Jeremy Frens.
6/5/2016 Slides from Distributed Computing, M. L. Liu And Distributed system design and concepts 1 Chapter 6: Group Communication.
2: Application Layer1 Socket programming Socket API Explicitly created, used, released by apps Client/server paradigm Two types of transport service via.
IP multicasting SWE 344 Internet Protocols & Client Server Programming.
Part 4: Network Applications Client-server interaction, example applications.
By Vivek Dimri. Basic Concepts on Networking IP Address – Protocol – Ports – The Client/Server Paradigm – Sockets The Java Networking Package – The InetAddress.
1 Socket programming Socket API r introduced in BSD4.1 UNIX, 1981 r explicitly created, used, released by apps r client/server paradigm r two types of.
UNIT-6. Basics of Networking TCP/IP Sockets Simple Client Server program Multiple clients Sending file from Server to Client Parallel search server.
1 COMP 431 Internet Services & Protocols Client/Server Computing & Socket Programming Jasleen Kaur February 2, 2016.
Presentation: Special Repetition Recap on Distributed Principles.
Java Programming II Java Network (I) Java Programming II.
1 Lecture 9: Network programming. 2 Manipulating URLs URL is an acronym for Uniform Resource Locator and is a reference (an address) to a resource on.
1 CSCD 330 Network Programming Fall 2013 Some Material in these slides from J.F Kurose and K.W. Ross All material copyright Lecture 8a Application.
CSE 501N Fall ‘09 22: Introduction to Networking November Nick Leidenfrost.
UDP User Datagram Protocol. About the UDP A commonly used transport protocol Does not guarantee either packet delivery or order The packets may travel.
Agenda Socket Programming The OSI reference Model The OSI protocol stack Sockets Ports Java classes for sockets Input stream and.
1 Network Communications A Brief Introduction. 2 Network Communications.
School of Engineering and Computer Science Victoria University of Wellington Copyright: Peter Andreae david streader, VUW Echo Networking COMP
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 33 Networking.
Network Programming Communication between processes Many approaches:
Socket Programming Ameera Almasoud
Object-Orientated Analysis, Design and Programming
Echo Networking COMP
Client-Server and Multicast Communication
Network Programming in Java CS 1111 Ryan Layer May 3, 2010
MCA – 405 Elective –I (A) Java Programming & Technology
Client-server Programming
Group Communication 11/3/2018.
Chapter 2: outline 2.1 principles of network applications
Socket programming - Java
Text extensions to slides © David E. Bakken,
Socket Programming.
Socket Programming 2: Application Layer.
CPSC 441 UDP Socket Programming
Chapter 2: Application layer
Server-Client communication without connection
Server-Client communication without connection
Socket Programming with UDP
CS18000: Problem Solving and Object-Oriented Programming
Review Communication via paired sockets, one local and one remote
Presentation transcript:

Block 14 Group Communication (Multicast) Jin Sa 2018/7/5 Client-server programming

Client-server programming Outline Concepts Java basic multicast implementation Program examples 2018/7/5 Client-server programming

Client-server programming Unicast vs. Multicast 2018/7/5 Client-server programming

Multicast applications Multicast allows the efficient distribution of information between a single multicast source and multiple receivers. Examples of multicast applications are audio/video services such as IPTV and conferencing services such as NetMeeting 2018/7/5 Client-server programming

Client-server programming Multicast group A set of processes form a group, called a multicast group. The processes can be on different hosts on different networks. Each process in a group can send and receive message. A message sent to the group can be received by each participating process in the group. 2018/7/5 Client-server programming

Client-server programming Multicast operations Primitive operations: join, leave, send and receive Note that joining a group means that the process is entitled to receive a message sent to the group. It still needs to issue a receive operation in order to receive messages. 2018/7/5 Client-server programming

IP Multicast addresses - 1 Instead of a single process, a multicast datagram is meant to be received by all the processes that are currently members of a specific multicast group. Hence each multicast datagram needs to be addressed to a multicast group instead of an individual process. A multicast address is the shared address of a group. A multicast group is specified by a multicast IP address, and a port number. 2018/7/5 Client-server programming

IP Multicast addresses - 2 The multicast addresses are in the range of 224.0.0.0 to 239.255.255.255. (The address 224.0.0.0 is reserved and should not be used by any application. ) 2018/7/5 Client-server programming

The Java Basic Multicast API -1 At the transport layer, the basic multicast supported by Java is an extension of UDP (the User Datagram Protocol) Datagram - recap 2018/7/5 Client-server programming

The Java Basic Multicast API - 2 In addition to the classes provided for datagram, Java provides the MulticastSocket class A MulticastSocket is a DatagramSocket, with additional capabilities for joining and leaving a multicast group. 2018/7/5 Client-server programming

Implementing multicast operations in Java 2018/7/5 Client-server programming

Joining a multicast group // join a Multicast group // at port 3456 and // IP address 239.1.2.3 InetAddress group = InetAddress.getByName("239.1.2.3"); MulticastSocket s = new MulticastSocket(3456); s.joinGroup(group);   2018/7/5 Client-server programming

Sending message to a multicast group InetAddress group = InetAddress.getByName("239.1.2.3"); MulticastSocket s = new MulticastSocket(3456); String msg = "a multicast message."; DatagramPacket hi = new DatagramPacket(msg.getBytes( ), msg.length( ),group, 3456); s.send(hi); 2018/7/5 Client-server programming

Receiving messages sent to a multicast group InetAddress group= InetAddress.getByName("239.1.2.3"); MulticastSocket s=new MulticastSocket(3456); s.joinGroup(group); byte[] buf = new byte[1000]; DatagramPacket recv = new DatagramPacket(buf,buf.length); s.receive(recv); 2018/7/5 Client-server programming

Leaving a multicast group MulticastSocket s = new MulticastSocket(3456); … … s.leaveGroup(group); 2018/7/5 Client-server programming

Time-To-Live (TTL) for Multicast Packets -1 Need to propagate a multicast message from a host to a neighboring host delivering the message to all the participants. Uses the Time To Live (ttl) parameter to decide how "far" from a sending host a given multicast packet should be forwarded. 2018/7/5 Client-server programming

Time-To-Live (TTL) for Multicast Packets - 2 The time-to-live (ttl) parameter limits the count of network links or hops that the packet will be forwarded on the network. The value for ttl can range from 0 to 255. The larger the ttl, the greater the distance a data packet will travel. 2018/7/5 Client-server programming

Time-To-Live (TTL) for Multicast Packets - 3   MulticastSocket s = new MulticastSocket(3456); s.setTimeToLive(1); 2018/7/5 Client-server programming

Time-To-Live (TTL) for Multicast Packets - 4 The recommended ttl settings are: 0 localhost 1 local network 32 same site 64 same region 128 same continent 255 unrestricted, i.e. the world 2018/7/5 Client-server programming

Multicast program examples Example1Sender Example1Receiver Example 2 Student activity Example3 OneLinerChatroom 2018/7/5 Client-server programming

Client-server programming Example1 Example1Sender Set a multicast group address Create a multicast socket on a port Create a datagram packet to be sent to the group Send the datagram packet using the multicast socket Example1Receiver Set the same multicast group address Create a multicast socket with the same port number Join the group Create a datagram packet as a placeholder Issue a receive method to receive a data packet. To run: (needs internet) run Example1Receiver several times to have a few participants in the group (internet on!!!) Run Example1Sender Source code on E:clientserverprogramming0708/multicast/MultiExample1sender and MultiExample1receiver 2018/7/5 Client-server programming

Fragment of code for Example1Sender (hand out) InetAddress group = InetAddress.getByName("239.1.2.3"); MulticastSocket s = new MulticastSocket(3456); String msg="Hi everyone!"; DatagramPacket packet = new DatagramPacket(msg.getBytes(), msg.length(), group,3456); s.send(packet); 2018/7/5 Client-server programming

Fragment of code for Example1Receive (hand out) InetAddress group = InetAddress.getByName("239.1.2.3"); MulticastSocket s = new MulticastSocket(3456); s.joinGroup(group); byte[] buf = new byte[100]; DatagramPacket recv = new DatagramPacket(buf, buf.length); s.receive(recv); System.out.println(new String(recv.getData())); 2018/7/5 Client-server programming

Client-server programming Student activity Example1Sender_loop Set a multicast group address Create a multicast socket on a port Loop Get message from scanner Create a datagram packet containing the message to send to group Send the datagram packet using the multicast socket Example1Receiver_loop Set the same multicast group address Create a multicast socket with the same port number Join the group Create a datagram packet as a placeholder Issue a receive method to receive a data packet. 2018/7/5 Client-server programming

Student activity: Example1Receiver_loop_1 public class Example1Receiver_loop_1 { public static void main(String[] args) { try { System.out.println("Enter the process name : "); Scanner in = new Scanner(System.in); String processName = in.nextLine(); InetAddress group = InetAddress.getByName("239.1.2.3"); MulticastSocket s = new MulticastSocket(3456); s.joinGroup(group); byte[] buf = new byte[100]; DatagramPacket recv = new DatagramPacket(buf, buf.length); // see the next slide // Loop // * Issue a receive method to receive a data packet // * display message. } }// end main }// end class Set up and join a Multicast group Set up DatagramPacket for receiving message 2018/7/5 Client-server programming

Student activity: Example1Receiver_loop_1 public class Example1Receiver_loop_1 { public static void main(String[] args) { // see the previous slide // * Set a multicast group address // * Create a multicast socket on a port int count = 0; while (count < 10) { s.receive(recv); System.out.println(new String(recv.getData())); System.out.println("received from:" + recv.getAddress() + " and port no: " + recv.getPort()); } s.close(); } catch (Exception ex) { ex.printStackTrace(); }// end main }// end class Loop Issue a receive method to receive a data packet. Display message received 2018/7/5 Client-server programming

Student activity: Example1Sender_loop_1 public class Example1Sender_loop_1 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); try { InetAddress group = InetAddress.getByName("239.1.2.3"); MulticastSocket s = new MulticastSocket(3456); // See the next slide // Loop // * Get message from scanner // * Create a datagram packet containing the message to send to group // * Send the datagram packet using the multicast socket } s.close(); } catch (Exception ex) { ex.printStackTrace(); } }// end main }// end class Create a Multicast group 2018/7/5 Client-server programming

Student activity: Example1Sender_loop_1 public class Example1Sender_loop_1 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); try { // See the previous slide // * Set a multicast group address // * Create a multicast socket on a port int count=1; while (count<10) { System.out.println("Enter the text for sendingto the group: "); String msg = scan.nextLine(); DatagramPacket packet = new DatagramPacket(msg.getBytes(), msg.length(), group, 3456); s.send(packet); System.out.println(msg +" has been sent."); count++; } s.close(); } catch (Exception ex) { ex.printStackTrace(); } }// end main }// end class Loop Get message via keyboard. Set up Datagram Packet containing the message Send datagramPacket 2018/7/5 Client-server programming

Student activity: Example1Receiver_loop_1 public class Example1Receiver_loop_1 { public static void main(String[] args) { try { System.out.println("Enter the process name : "); Scanner in = new Scanner(System.in); String processName = in.nextLine(); // see the next slide // Loop // * Issue a receive method to receive a data packet // * display message. } }// end main }// end class Set up and join a Multicast group Set up DatagramPacket for receiving message 2018/7/5 Client-server programming

Student activity: Example1Receiver_loop_1 public class Example1Receiver_loop_1 { public static void main(String[] args) { // see the previous slide // * Set a multicast group address // * Create a multicast socket on a port int count = 0; while (count < 10) { } s.close(); } catch (Exception ex) { ex.printStackTrace(); }// end main }// end class Loop Issue a receive method to receive a data packet. Display message received 2018/7/5 Client-server programming

Student activity: Example1Sender_loop_1 public class Example1Sender_loop_1 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); try { // See the next slide // Loop // * Get message from scanner // * Create a datagram packet containing the message to send to group // * Send the datagram packet using the multicast socket } s.close(); } catch (Exception ex) { ex.printStackTrace(); } }// end main }// end class Create a Multicast group 2018/7/5 Client-server programming

Student activity: Example1Sender_loop_1 public class Example1Sender_loop_1 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); try { // See the previous slide // * Set a multicast group address // * Create a multicast socket on a port int count=1; while (count<10) { System.out.println(msg +" has been sent."); count++; } s.close(); } catch (Exception ex) { ex.printStackTrace(); } }// end main }// end class Loop Get message via keyboard. Set up Datagram Packet containing the message Send datagramPacket 2018/7/5 Client-server programming

Exercises for the practicals Implement example 1 on slide 21 Implement student activity on slide 24 (Option) Implement the OneLinerChatroom example on slide 34. 2018/7/5 Client-server programming

Example2– a very simple oneliner chatroom (Option) Everyone in the group does the same thing: Each person joins a group After joining, each person can send one message to the group After joining, each person can receive all the messages sent to the group. 2018/7/5 Client-server programming

Oneliner chatroom:Two class MultiExample2SenderReceiver Get the participant’s name Set a multicast address and port number for the group Create a separate thread (MultiReadThread) to receive multicast messages repeatedly from other members Send the message “hello” once to the group by creating a datagram packet creating a multicast socket and issue send MultiReadThread Set the same multicast group address as everyone else Create a multicast socket with the same port number Joint the group Repeatedly issue a receive method to receive data packets. To Run Run MultiExample2SenderReceiver on E: clientServerProgramming/multicast Run the file a few times to create a few participants Hit return when ready to say hello. 2018/7/5 Client-server programming