Advanced Java Programming: programming of distributed application using TCP/IP Santiago, Aug. 2008 Nelson Baloian,

Slides:



Advertisements
Similar presentations
CCNA – Network Fundamentals
Advertisements

© 2007 Cisco Systems, Inc. All rights reserved.Cisco Public ITE PC v4.0 Chapter 1 1 OSI Transport Layer Network Fundamentals – Chapter 4.
Intermediate TCP/IP TCP Operation.
Lecture 7 Transport Layer
© 2007 Cisco Systems, Inc. All rights reserved.Cisco Public 1 Version 4.0 Network Services Networking for Home and Small Businesses – Chapter 6.
Content Introduction TCP Clients Iterative TCP Servers Concurent TCP Servers UDP Multicasting
Advanced Java Programming: programming of distributed application using TCP/IP Tokyo, Jan. Feb Nelson Baloian, Roberto Konow.
Universidad de Chile - Tupper 2007, Santiago - Fono: Fax: Módulo 9: Desarrollo de Aplicaciones.
Socket Programming.
1 Java Networking – Part I CS , Spring 2008/9.
Networking Theory (part 2). Internet Architecture The Internet is a worldwide collection of smaller networks that share a common suite of communication.
1 © 2003, Cisco Systems, Inc. All rights reserved. CCNA 1 v3.0 Module 11 TCP/IP Transport and Application Layers.
Introduction to Management Information Systems Chapter 5 Data Communications and Internet Technology HTM 304 Fall 07.
An Introduction to Internetworking. Why distributed systems - Share resources (devices & CPU) - Communicate people (by transmitting data)
Administrativo Clases 2 veces a la semana : –Ma – Vi 12:00 Sin Clase auxiliar.
An Introduction to Internetworking. Algorithm for client-server communication with UDP (connectionless) A SERVER A CLIENT Create a server-socket (listener)and.
What Is TCP/IP? The large collection of networking protocols and services called TCP/IP denotes far more than the combination of the two key protocols.
© 2007 Cisco Systems, Inc. All rights reserved.Cisco Public 1 Version 4.0 Application Layer Functionality and Protocols Network Fundamentals – Chapter.
Programming for information communication systems Programming of distributed application over TCP/IP networks Yerevan, Sept.- Oct Nelson Baloian,
What Can IP Do? Deliver datagrams to hosts – The IP address in a datagram header identify a host IP treats a computer as an endpoint of communication Best.
Process-to-Process Delivery:
Chapter 17 Networking Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William Stallings.
Lecture 2 TCP/IP Protocol Suite Reference: TCP/IP Protocol Suite, 4 th Edition (chapter 2) 1.
1 Chapter Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer.
Chapter 6: Packet Filtering
SEED Infotech Pvt. Ltd. 1 Networking in Java. SEED Infotech Pvt. Ltd. 2 Objectives of This Session Describe issues related to any type of network using.
Copyright 2003 CCNA 1 Chapter 9 TCP/IP Transport and Application Layers By Your Name.
Jaringan Komputer Dasar OSI Transport Layer Aurelio Rahmadian.
TCP/IP: Basics1 User Datagram Protocol (UDP) Another protocol at transport layer is UDP. It is Connectionless protocol i.e. no need to establish & terminate.
Lector: Aliyev H.U. Lecture №14: Telecommun ication network software design for data bases and servers. TASHKENT UNIVERSITY OF INFORMATION TECHNOLOGIES.
Jozef Goetz, Application Layer PART VI Jozef Goetz, Position of application layer The application layer enables the user, whether human.
Component 9 – Networking and Health Information Exchange Unit 1-1 ISO Open Systems Interconnection (OSI) This material was developed by Duke University,
1 Version 3.0 Module 11 TCP Application and Transport.
Chapter Three Network Protocols By JD McGuire ARP Address Resolution Protocol Address Resolution Protocol The core protocol in the TCP/IP suite that.
© 2007 Cisco Systems, Inc. All rights reserved.Cisco Public 1 Version 4.0 OSI Transport Layer Network Fundamentals – Chapter 4.
TCP/IP TCP/IP LAYERED PROTOCOL TCP/IP'S APPLICATION LAYER TRANSPORT LAYER NETWORK LAYER NETWORK ACCESS LAYER (DATA LINK LAYER)
TCP/IP Transport and Application (Topic 6)
The Transmission Control Protocol (TCP) Application Services (Telnet, FTP, , WWW) Reliable Stream Transport (TCP) Connectionless Packet Delivery.
1 Networking Chapter Distributed Capabilities Communications architectures –Software that supports a group of networked computers Network operating.
CCNA 1 v3.0 Module 11 TCP/IP Transport and Application Layers.
Chapter 15 – Part 2 Networks The Internal Operating System The Architecture of Computer Hardware and Systems Software: An Information Technology Approach.
Transport Layer COM211 Communications and Networks CDA College Theodoros Christophides
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”
Multimedia and Networks. Protocols (rules) Rules governing the exchange of data over networks Conceptually organized into stacked layers – Application-oriented.
TCP/IP (Transmission Control Protocol / Internet Protocol)
Networking Basics CCNA 1 Chapter 11.
1. Layered Architecture of Communication Networks: TCP/IP Model
4343 X2 – The Transport Layer Tanenbaum Ch.6.
1 Kyung Hee University Chapter 11 User Datagram Protocol.
Data Communications and Networks Chapter 6 – IP, UDP and TCP ICT-BVF8.1- Data Communications and Network Trainer: Dr. Abbes Sebihi.
McGraw-Hill Chapter 23 Process-to-Process Delivery: UDP, TCP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
TCP/IP1 Address Resolution Protocol Internet uses IP address to recognize a computer. But IP address needs to be translated to physical address (NIC).
1 Network Communications A Brief Introduction. 2 Network Communications.
Process-to-Process Delivery:
IST 201 Chapter 11 Lecture 2. Ports Used by TCP & UDP Keep track of different types of transmissions crossing the network simultaneously. Combination.
Application Layer Functionality and Protocols Abdul Hadi Alaidi
The Transport Layer Implementation Services Functions Protocols
Chapter 3 Internet Applications and Network Programming
Understand the OSI Model Part 2
Process-to-Process Delivery:
Networking Theory (part 2)
An Introduction to Internetworking
An Introduction to Internetworking
Administrativo Clases 1 vez a la semana : Sin Ayudantia
Process-to-Process Delivery: UDP, TCP
Computer Networks Protocols
Tokyo, Feb Nelson Baloian, Teaching assistant: Roberto Konow
Networking Theory (part 2)
Networking Theory (part 2)
Presentation transcript:

Advanced Java Programming: programming of distributed application using TCP/IP Santiago, Aug Nelson Baloian,

Content 0. Introduction (concepts of distributed systems) 1. TCP/IP client & server programming –Client programming: –a simple client (date, echo) –a pop3 client –A SMTP client 2. Server programming (and their clients) –Simple client-server example with serializing example –File Servers: simple whole file iterative server (not secure) –Simple whole file robust server –Simple whole file concurrent server –Stateless random access file server –TCP/IP Chat with awareness –A simple extensible web server –Parallel downloading techniques –Awareness in a TC/IP peer to peer environment and the latecomers problem

Content 3. UDP programming -simple UDP client-server example -a "ping" program – -multicasting -multicasting chat -awareness in a multicasting environment -broadcasting vs. multicasting 4. RMI Client-server programming -a simple example will be used to show: remiregistry, concurrency automatic stub distribution -a sequential file server with state -Automatic teller machine example -RMI-based chat with awareness 5- Introduction to servlets and jsp -principles - parameters (from request and parameter file) -using forms -implementing state with cookies/sessions 6- JDBC

Evaluation Attending to classes (at least 80%) Homeworks (5)

Why distributed systems - Share resources (25 years ago) - Communicate people (now) - Performance, scalability (always) - Fault tolerant systems (always)

Which distributed programs do I use daily ? 1- ICQ p2p file sharing 4- web browser-server 5- database software 6- file server

Can we deduce how were they developed ? 1- Programming language and resources used 2- Connection style 3- Communications architecture 4- Software architecture 5- Server design (if any)

Internet : two different ways to deliver a message to another application The UDP: User Defined Package: like writing a letter TCP or UDP Applications’ programmers decide on this according to their needs

Every layer has the illusion of talking to the same one located at the other host A SERVER A CLIENT 4444 The UDP: User Defined Package: like writing a letterRead write sequence UDP or TCP communication Internet frames and addresses electric pulses

Implementation of Communications in a TCP/IP Network At a low level (¿future “assembler of the communications”?) Based on the “sockets” & “ports” abstractions Originally developed for BSD UNIX but now present in almost all systems (UNIX, LINUX, Macintosh OS, Windows) The destination of a message is determined by the computer’s IP number and the port number Every machine has 2**16 ports The origin of the message is also a socket but most of the times the port number is not important Ports are associated to services (programs)

The 3 basic communication forms UDP communication reflects almost what really happens over the internet. An application sends a packet trough a socket addressed to a certain IP number and port. There should be another application on that host listening to packets coming to that port (which is agreed beforehand) TCP simulates a data flow. A client must establish a communication with the server before starting sending/receiving data. The server must be waiting for such request. Multicast fits well for group communication when the group is not well defined beforehand (spontaneous networking). It is also based in the sending of UDP packages but all “interested” applications may receive it. It does not require a central server

Protocolos for communication Every service is normally identifyed by a port –Web: HTTP (port 80) –Mail: SMTP (port 25) –File transfer protocol: FTP (21) –telnet: 22/23 More common services ports at: Servers with/without Connection –connectionless style: UDP –connection-oriented style TCP

The SOCKET A SERVER 1 When a server wants to start listening it must create a socket bound to a port. The port is specified with a number. A SERVER 2A SERVER If a client wants to communicate with server 1 should try to communicate with computer through port 4444

UDP: communication with datagrams DATAGRAM: an independent, self-contained message sent over the internet whose arrival, arrival time and content are not guaranteed (like regular mail in some countries....) A SERVER A CLIENT message 4444 Once a server is listening, the client should create a datagram with the server’s address, port number and, the message ?

Sending datagrams with UDP protocol Then it should open a socket and send the datagram to the internet. The “routing algorithm” will find the way to the target computer A SERVER A CLIENT ?

Before the datagram leaves the client, it receives the address of the originating computer and the socket number A SERVER A CLIENT ! Sending datagrams with UDP protocol

After the datagram is sent, the client computer may start hearing at the port created for sending the datagram if an answer from the server is expected A SERVER A CLIENT ?

Sending datagrams with UDP protocol The server can extract the client’s address and port number to create another datagram with the answer A SERVER A CLIENT answer ?

Sending datagrams with UDP protocol Finally is sends the datagram with the answer to the “client”. When a datagram is sent there is no guarantee that it will arrive to the destination. If you want reliable communication you should provide a checking mechanism, or use... A SERVER A CLIENT ?

TCP: communication with data flow With TCP a communication channel between both computers is built and a reliable communication is established between both computers. This allows to send a data flow rather tan datagrams. A SERVER A CLIENT ?

TCP: communication with data flow After the client contacts the server, a reliable channel is established. After this, client and server may begin sending data through this channel. The other should be reading this data: They need a protocol !!!! A SERVER A CLIENT bla

TCP: How is reliability achieved ? The internet itself works only with the datagram paradigm. Internet frames are may “get lost” (destroyed): For every frame delivered carrying a part of the data flow there is a confirmation! Sending bla bla bla Sending 1st bla Ack 1st bla Sending 2nd bla Ack 2nd bla Sending 3rd bla Ack 3rd bla

What if a message get lost ? The server waits a certain amount of time. If it does not receive any confirmation it sends the message again. Sending bla bla bla Sending 1st bla Ack 1st bla Sending 2nd bla Sending 2nd bla again Ack 2nd bla No confirmation !!! LOST !!!

The Window for improving efficiency The transmitter will handle a set of not acknowledged packets Sending 1st bla Ack 1st bla Sending 2nd bla Ack 2nd bla Sending 3rd bla Ack 3rd bla

TCP or UDP Protocol: decision at the transport level What does it means for the programmer/designer: –By choosing one or the other protocol for establishing a connection between machines the programmer/designer decides about the reliability and speed of the communication. TCP provides high reliability: data are only sent if the communication was established. An underlying protocol is responsible for retranslating, ordering, eliminating duplicate packages UDP reflects just what the internet does with the packages: best effort delivery, no checking. –Also the programming style is quite different : With TCP the data is sent a flow (of bytes, in principle) which can be written, read as if they were stored in a file. With UDP the programmer must assemble the package and send it to the internet without knowing if it will arrive its pretended destination

When to use one or another Considerations –TCP imposes a much higher load to the network than UDP (almost 6 times) –We can expect high package loss when the information travels trough many routers. –Inside a LAN UDP communications may be reliable is there is not much traffic. Although with some congestion we can expect some packages to be lost inside the LAN In general, it is recommended especially for beginners (but also to skilled programmers) to use only TCP to develop distributed applications. Not only it is more reliable but the programming style is also simpler. UDP is normally used if the application needs to implement hardware supported broadcasting or multicasting, or if the application cannot tolerate the overload of TCP

Mark with a + the applications to use TCP and with a = those to use UDP Video conference Temperature every second Web server and client Stock values every 5 seconds

The client-server paradigm (do you remember the WEB ?) The web server program Web resources request answer THE INTERNET request answer The web client program

1- The server opens a channel and starts listening to requests. A SERVER Web resources THE INTERNET A CLIENT 1 ?

2- A client who knows it, sends a request and waits for the answer A SERVER Web resources THE INTERNET A CLIENT 2 2

3- The server, analyses the request and answers properly according to the protocol A SERVER Web resources THE INTERNET A CLIENT 3 3 This may involve the reading of a file

Why Client/Server ? It is a communication protocol model (listener/caller) TCP/IP does not provide any mechanism which would start running a program in a computer when a message arrives. A program must be executing BEFORE the message arrives in order to establish a communication (daemons). Is there really no other mean to communicate ? –Multicasting (but the sender does not know who is receiving and in this case there is no dialogue) Most programs do not act as pure servers or client –It very frequent to have a server of o a certain program act as a client of another –Sometimes a group of programs are client and servers from each other at the same time!

The Client-Server Model Client Server 1 Server 2 Server 3 request answer

Services Provided by Multiple Servers Client Server 2 Server 3 Server 1

Proxy servers & caches Client Proxy/ca che Server 2 Server 1

Peer-to-peer Applications (p2p) Application + Coordination Application + Coordination Application + Coordination

Communication Architectures for Distributed Applications Servers as Clients –Programms do not behave as pure servers or as pure clients. For example, a file server can ask another compter for a timestamt to register the last change of a file. –When all application must behave at the same time as client and server we can organize the communication in two basic ways: Every application can open a communication channel with each other application (network configuration): P2P applications There is a commincation server and all applications open one communication channel with it (star configuration): multiple chat servers.

Network communication architecture Every application opens an exclusive channel qith each other application present in the session There may be up to n*(n-1)/2 channels open for n applications Advantages: –It avoids bottlencks in the communications Drawbacks: –All applications must be aware of all other taking part in the session –The dynamic is more complicated when managing consistency when applications enter and quit the session

Star communication architecture The applications open a channel with the server and send their communication requests to the server. This server takes the message and forwards it to its final destination There are up to n channels open for n applications Advantages: –The managing og the communication parameters is more easy to manage –The problem of incomming and outgoing of applications is more easy to tackle Drawbacks: –The server can get oveloaded –The channels may get overloaded.

Replicated Architecutres Every application has a copy of the application and the data The modifications (data) are distributed to all participants in some way Synchronization is normally achieved by distributing the events, not the state of the data Problems with latecommers Communication architecture may be that of a star or network type

Replicated Architecture Data view Data Appl

Semi-replicated Architectures Data are kept centralized by a single application Every client mantains its own actualized view of the data There is a single data model, while the views and controllers are replicated Permits the use of different interfaces (browser) Synchronisation by events or by state Communication architecture normaly centralized (the data are located at the server)

Semi-replicated Architecture Data

Centralized Architecture Data and view are mantained centralized Every client has a graphic server for displaying the view Synchonization by state (the view) Communications architecture centralized It provoques a big traffic of data over the network (the whole view is transmitted) Are frecuently of general use (like netmeeting)

Full centralized Architecture view / commands

Nowadays there is a lot of middleware which make distributed programming much easier Libraries for distributed programming (middleware) RPC, CORBA, RMI

Goals of the Middleware Provide a framework for making development of distributed system easier Hide (encapsulate) communications details Make distributing programming similar to local programming Standardization of communication protocols and data format This help comes not for free !!!

Web-Based Distributed Systems Applications talk to each other using HTTP protocol Trough port 80 (usually the only available) Thin clients – Fat Servers Use of Web and Application servers The server is “extended” to implement new services

J2EE Basic Architecture Database Server Web Server Application Server Client: Web Browser Communication via JDBC HTML Pages Servlets JSP pages EJB