1 Server-Client communication without connection  When the communication consists of sending and/or receiving datagram packets instead of a data stream.

Slides:



Advertisements
Similar presentations
Umut Girit  One of the core members of the Internet Protocol Suite, the set of network protocols used for the Internet. With UDP, computer.
Advertisements

Internet Control Protocols Savera Tanwir. Internet Control Protocols ICMP ARP RARP DHCP.
Universidad de Chile - Tupper 2007, Santiago - Fono: Fax: Módulo 9: Desarrollo de Aplicaciones.
Jan Java Networking UDP Yangjun Chen Dept. Business Computing University of Winnipeg.
Universidad de Chile - Tupper 2007, Santiago - Fono: Fax: Módulo 9: Desarrollo de Aplicaciones.
Socket Programming.
A CHAT CLIENT-SERVER MODULE IN JAVA BY MAHTAB M HUSSAIN MAYANK MOHAN ISE 582 FALL 2003 PROJECT.
User Datagram Protocol. Introduction UDP is a connectionless transport protocol, i.e. it doesn't guarantee either packet delivery or that packets arrive.
Prepared By E. Musa Alyaman1 User Datagram Protocol (UDP) Chapter 5.
1 Java Networking – Part I CS , Spring 2008/9.
COS 420 Day 18. Agenda Group Project Discussion Program Requirements Rejected Resubmit by Friday Noon Protocol Definition Due April 12 Assignment 3 Due.
1 L53 Networking (2). 2 OBJECTIVES In this chapter you will learn:  To understand Java networking with URLs, sockets and datagrams.  To implement Java.
Java Socket Support Presentation by: Lijun Yuan Course Number: cs616.
System Programming Practical session 10 Java sockets.
An Introduction to Internetworking. Why distributed systems - Share resources (devices & CPU) - Communicate people (by transmitting data)
Projekt współfinansowany przez Unię Europejską w ramach Europejskiego Funduszu Społecznego „Networking”
Chapter 19 Binding Protocol Addresses (ARP) Chapter 20 IP Datagrams and Datagram Forwarding.
Datagram Programming A datagram is an independent, self-contained message sent over the network whose arrival, arrival time, and content are not guaranteed.
An Introduction to Internetworking. Algorithm for client-server communication with UDP (connectionless) A SERVER A CLIENT Create a server-socket (listener)and.
Server-Client communication without connection When the communication consists of sending and/or receiving datagram packets instead of a data stream it.
USER DATAGRAM PROTOCOL (UDP) Prof. Crista Lopes. What is UDP ?  an unreliable transport protocol that can be used in the Internet.  an alternative to.
Internet Control Message Protocol (ICMP)
Babak Esfandiari (based on slides by Qusay Mahmoud)
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?
The Network Layer. Network Projects Must utilize sockets programming –Client and Server –Any platform Please submit one page proposal Can work individually.
Lecture 2 TCP/IP Protocol Suite Reference: TCP/IP Protocol Suite, 4 th Edition (chapter 2) 1.
Computer Networks. IP Addresses Before we communicate with a computer on the network we have to be able to identify it. Every computer on a network must.
PA3: Router Junxian (Jim) Huang EECS 489 W11 /
 Socket  The combination of an IP address and a port number. (RFC 793 original TCP specification)  The name of the Berkeley-derived application programming.
VIII. UDP Datagrams and Sockets. The User Datagram Protocol (UDP) is an alternative protocol for sending data over IP that is very quick, but not reliable:
RGEC MEERUT(IWT CS703) 1 Java Networking RGEC Meerut.
Chapter 6-2 the TCP/IP Layers. The four layers of the TCP/IP model are listed in Table 6-2. The layers are The four layers of the TCP/IP model are listed.
Practicum: - Client-Server Computing in Java Fundamental Data Structures and Algorithms Margaret Reid-Miller 13 April 2004.
Distributed Systems Concepts and Design Chapter 4.
1. I NTRODUCTION TO N ETWORKS Network programming is surprisingly easy in Java ◦ Most of the classes relevant to network programming are in the java.net.
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.
 2003 Joel C. Adams. All Rights Reserved. Calvin CollegeDept of Computer Science(1/11) Java Sockets and Simple Networking Joel Adams and Jeremy Frens.
The InetAddress Class A class for storing and managing internet addresses (both as IP numbers and as names). The are no constructors but “class factory”
Part 4: Network Applications Client-server interaction, example applications.
Distributed systems (NET 422) Prepared by Dr. Naglaa Fathi Soliman Princess Nora Bint Abdulrahman University College of computer.
By Vivek Dimri. Basic Concepts on Networking IP Address – Protocol – Ports – The Client/Server Paradigm – Sockets The Java Networking Package – The InetAddress.
CSI 3125, Preliminaries, page 1 Networking. CSI 3125, Preliminaries, page 2 Networking A network represents interconnection of computers that is capable.
Chapter 9: Multicast Sockets
UNIT-6. Basics of Networking TCP/IP Sockets Simple Client Server program Multiple clients Sending file from Server to Client Parallel search server.
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.
1 Kyung Hee University Chapter 11 User Datagram Protocol.
Agenda Socket Programming The OSI reference Model The OSI protocol stack Sockets Ports Java classes for sockets Input stream and.
TCP/IP1 Address Resolution Protocol Internet uses IP address to recognize a computer. But IP address needs to be translated to physical address (NIC).
Network Programming. These days almost all devices.
Network Programming Communication between processes Many approaches:
Socket Programming Ameera Almasoud
Chapter 11 User Datagram Protocol
MCA – 405 Elective –I (A) Java Programming & Technology
Block 14 Group Communication (Multicast)
TCP Transport layer Er. Vikram Dhiman LPU.
Byungchul Park ICMP & ICMPv DPNM Lab. Byungchul Park
Net 323: NETWORK Protocols
„Networking”.
Socket Programming.
An Introduction to Internetworking
Server-Client communication without connection
Server-Client communication without connection
Exceptions and networking
Presentation transcript:

1 Server-Client communication without connection  When the communication consists of sending and/or receiving datagram packets instead of a data stream it is called a connectionless communication  This means there is no “virtual link” created between both end of a communication.  This is very near to how the packages are actually delivered over the over the internet.  This is why the arriving, order or uniqueness of packages cannot be guaranteed.

2 Datagram management with JAVA  Communication is based on assembling UDP packages and sending them to the interent. An UDP package consists of:  Data: a bytes array  Destination Port : int  Destination Address: InetAddress  A server start by listening at a certain port for packages.  The client assembles a package and send it to the net.  The server receives the package (routed by the net to its final destination) and extracts the data.  If the server needs to answer, it extracts the sender address and port (the client must be listening for packages)

3 Classes for Datagrams in Java: Send  Create a socket for sending a Datagram to the internet  DatagramSocket ds = new DatagramSocket();  Create and assemble the Datagram  byte[] data = new byte[256];  InetAddress address = InetAddress.getByName(“  DatagramPacket pack = new DatagramPacket(data, data.length,address,4444);  Send  ds.send(pack);  Wait for an answer  socket.receive(pack); //make sure it is clean before, perhaps by using a new one !!! EchoUDPClient DateUDPClient

4  Start listening for Datagrams on a certain socket  socket = new DatagramSocket(4444);  Preparing a Datagram for receiving data  byte[] data = new byte[256];  DatagramPacket pack = new DatagramPacket(data,data.length);  Start listening for a package  socket.receive(pack);  Obtaining the data and address and port of sender  int port = pack.getPort();  InetAddress address = pack getAddress();  String content = new String(pack.getData());  Or just by using the data variable which points to the byte-array Classes for Datagrams in Java: Receive DateUDPServer EchoUDPServer

5 An UDP Ping Client  We will use the echo server by default  In a Unix machine there is normally an echo server listening at port 7 for UDP and for TCP requests  It is not the same server, but it is possible to open 2 sever sockets for the same port but for different protocols  The Ping client will send a package to the server with time of issue, which will be returned by the server  By comparing time in the Datagram and current time we can have the round-trip delay  The program will also calculate max/min and avg Pinging.java

6 Multicasting  What happens when a server has to distribute the same information to many clients and the information is too heavy ?  The server will spend too much time attending each client  In the case of a videoconference in real time this is impossible  There is a way to have the server transmitting the information only once and received by many  For this, the network must be “multicastingable”

7 The Multicast Principle PROG1 PROG2

8 Multicast Characteristics  To send/receive information in Multicast with Java is similar as doing it with UDP  Variations:  Sender should address packages to an IP number in the range between and  Receivers should have previously “expressed” the wish to receive them by joining a Multicast group (identified by a multicast address ).  The routers of the network will take care of delivering a copy to every host in the Internet which is in the group (not really true

9 Multicast in Java  MulticastSocket: extension of DatagramSocket  MulticastSocket( ) it is bound to any available port  MulticastSocket(int port) bound to a specific port  several multicast socekts can be bound simultanously to the same port ! (contrary to TCP o UDP)  Inherited methods (send, receive) + 3 new  joinGroup(InetAddress group)  leaveGroup(InetAddress group)  setTimeToLive(int ttl)

10 import java.io.*; import java.net.*; public class MulticastReceiver { public static void main(String[] args) throws IOException { MulticastSocket socket = new MulticastSocket(4446); InetAddress address = InetAddress.getByName(" "); socket.joinGroup(address); byte[] buf = new byte[256]; DatagramPacket packet; while(true) { packet = new DatagramPacket(buf, buf.length); socket.receive(packet); String received = new String(packet.getData()); System.out.println("Received: " + received); try { Thread.currentThread().sleep(0); } catch (InterruptedException e) { } Example of Multicast in Java import java.io.*; import java.net.*; import java.util.*; public class MulticastSender { static public void main(String args[]) { DatagramSocket socket = null; BufferedReader in = null; boolean moreQuotes = true; try { socket = new DatagramSocket(); while (true) { InetAddress grupo = InetAddress.getByName(" "); for (int i=1; i< 1000; i++) { String dString = i+"--"+(InetAddress.getLocalHost()); byte[] buf = dString.getBytes(); DatagramPacket packet = new DatagramPacket(buf, buf.length, grupo, 4446); socket.send(packet); try { Thread.currentThread().sleep(200); } catch (InterruptedException e) {} } } catch (IOException e) {} }

11 Sending video by Multicast MulticastMovieServer MulticastMovieClient

12 A Multicast Based Chat  There is no server.  Each participant runs the exactly same program, joining a common Multicast group The messages are “multicasted” over the net, thus everyone joining the group will receive them There is no guarantee about the arriving, arriving time, or duplication of messages MulticastChat

13 Spontaneous Networking  Multicasting is the right way to program systems when the participants in the session may come and go very frequently  This is the case of spontaneous networking with mobile devices in a room  Someone “announce” her presence to the other members by sending message to all at regular intervals  The fact that someone has left is recorded by the others when there have been no messages from her since a certain period of time

14 An Awareness Example  The MulticastRegister program will show all people participating in the multicast group  It implements a thread that will send every second a packet with the client's identification  It starts 3 other threads:  ReceiveThread: will listen to packets sent by other members of the group. When it receives one, it will register it in a vector containing a pair (participant-id, time) with the time the last packet received from a participant was received  ChckThread: check the vector every 2 seconds the vector and deletes the entries from the participants whose last package was received more than 10 seconds ago  RefreshThread: it simply refreshes the list showing the active participants according to the vector’s content

15 Reliable Multicast  Each participant process p maintains a sequence number S(p) for the messages it sends to a certain multicast group  It also maintains a register R(q) for each other process q participating with the number of the last message sent by that process  When p wants to send a message it includes the number S(p) and the pairs, afetr that it increments S(p).  A process k receiving this message will process it only if S(p) = R(p) +1  If S <= R(p) the message was already received before  If S > R(p) + 1 messages are missing, the process k sends a request to p  This means, processes should store messages they send in case they receive a request to send it again

16 Ordering Multicast messages In order to process all messages in the same order, processes maintain a queue with multicast messages. The principle is that all processes assign one and the same processing sequence number to a certain message sent to the group. Each process q maintains a number A(q), corresponding to the highest of the agreed sequence observed and a number P(q,g) corresponding to the highest of its own sequence of sent messages. When p wants to send a message: 1- p Sends in a reliable way (m is the message itself and i an identification) 2- Each process q answers with a proposition number for that message which will be P(q) = Max(A(q), P(q)) p collecta all the numbers and selects the highest for this message and sends it to the rest 5- all processes receive this num ber and use it for ordering the messages in the queue, which will eventually processed

17 MBone  Multicast is currently not widely deployed on the Internet so it is not possible to implement it across different networks. This is mainly because of the routers not supporting the IGMP  There is a subnet called MBone which communicate multicast-enabled islands, allowing the transport of multicast packets through tunnels.  A tunnel communicates the routers of two networks which are not physically adjacent.  Packages will be forwarded from router to the other as if there were actually neighboring networks

18 Broadcast  Broadcast is similar to Multicast but in a local network  Every Broadcast based network (like ethernet) has a broadcast IP address. Any message sent to this address will be received by all computers on the local network  Usually this is the last IP address of the subnet:  Class C: >  For a sub-network of 16 hosts >  A port number should be agreed

19 ¿ Broadcast or Multicast ?  If you can chose it is better to use Multicast because it does not disturb other machines  Sometimes is necessary to have privileges to write on a broadcast address.  Multicast allows many multicast groups in the same network  The generated traffic is the same: one package which is received by all members  Broadcast works in Java like common UDP. Only the IP address is special