Title: Internet Protocols I
1Internet Protocols I
Incheon Paik
2Some Protocols
- HTTP Communication
- Connectionless Communication
- Stateless Communication
(1) TCP Connection Request
(2) HTTP Request
Server
Client
(3) HTTP Response
(4) TCP Connection Close
3Some Protocols
- HTTP Message
- Start Line Client Request Information /
Response Status Information - Message Header Additional Information for HTTP
Message such as Date, Program Name, Version,
Cookie, User Authentication, Cache - Message Body Contents for Request or Response.
In case of POST, Input data consists of data
stream encoded in request message.
4Some Protocols
- Client Request Message in HTTP
- Request HTTP Command, URI, and HTTP Version,
Header NameHeader Value, Request Message Body - HTTP Command GET, HEAD, POST/ OPTIONS, PUT,
DELETE, LINK, UNLINK, TRACE - Server Response Message in HTTP
- Response Message HTTP Version, Status Code,
Code Description, Response Header, Response
Message Body - Response Status Code (Reference 100-199),
(Success 200-299), (Redirection 300-399),
(Incomplete 400-499), (Server Error 500-599)
5Some Protocols
- HTTP Message Header
- HTTP Header Used for transmitting any kinds of
information between client and server, Header
Name Blank Header-value - General Header Client Request, Server Response,
Cache setup, Connection, Date, etc - Client Request Header Client information and
preferred data type, Accept Character set,
encoding type, and authorization - Response Header Server Information, Message
processing methods for response message. Web
server information, Cookie setup, authenticate
information. - Entity Header HTTP message body information,
encoding method of message, contents length, MD5
information, encoding method of contents
transmission, MIME type
6Some Protocols
- MIME Type
- As HTTP transmission deal with multimedia
documents, pre-defined method to deal with that
data by client should be described. - MIME(Multipurpose Internet Mail Extension) Type
- Client Using Accept Header, Clients can define
their preferred media type - Server Describe MIME Type in Content-Type
Header - MIME Type form Type/Subtype (ex
application/x-javascript) - Standard MIME Type
- Text, Multipart, Message, Application, Image,
Audio, Video
7CGI Communication
- CGI(Common Gateway Interface)
- Transmit Messages by GET/POST Method
- Characteristics
- Extend Web Server, Dynamic Response, Only Install
in Server Side - Overhead, Security, Interactive pages, Cannot
keep the connection Problems
Process 1
Process 1
Process 1
Web Server
CGI Program
Processes
8Extended CGI
- ASP (Active Server Page) of Microsoft
- Combine HTML, Server side Script, and Server side
Component - Written in Jscript, VBScript, and run on IIS
Server - Can use COM Component
- Java Servlet and JSP
- Platform Independent, Safe and Effective Thread
Service, Object Oriented Paradigm - Easy to interoperate with Legacy Application
- JSP is similar to ASP, and provide HTML script
language and JavaBeans Component - Object Web
- CORBA (Common Object Request Broker Architecture)
- EJB (Enterprise JavaBeans)
- DCOM (Distributed Common Object Model)
9Motivations of Servlet and JSP
Slide 9-18, Used the Material by Philippe Rochat
- Faster than CGI (no process creation overhead)
- Java is Internet oriented
- Servlet API
- Security
- Session support
- Code reuse and portability
- JDBC support
- Next step Enterprise Java Beans (EJB)
10Object Web
RMI/IIOP
JSP
DBMS
EJB
HTML/XML
HTTP
Web Server
IIOP
CORBA
HTTP
Servlet
Applet
Legacy Application
11Servlet and Servlet Container
Servlet Application 1
Servlet Application 2
Servlet Application N
Java Servlet API
Servlet Container 1
Servlet Container 2
Servlet Container N
- Servlet Container
- - To run servlet, there need to be JVM to run
Java servlet class and - servlet container to provide servlet
applications with system service. - Deliver HTTP request of a client to servlet
application, - and HTTP response of the servlet applcation to
the client
12How-to Write Servlet
- Very Similar to applet
- Must inherits
- HttpServlet
- Must implements one of
- doGet
- doPost
- doPut
-
- Receives
- HttpServletRequest
- HttpServletResponse
13Execution of JSP
Handler Request
JSP Request
JSP Handler Servlet
Servlet Container
Web Browser
Web Server
Servlet Invocation
JSP File Check
Java file Compile
Class Loading
JSP file Compile
JSP Servlet
Class File (.class)
JSP File (.jsp)
Java File (.java)
- A user requests .jsp file through URL.
- Web server requests JSP handler to process .jsp
file - JSP/Servlet container pass the corresponding
.jsp file to JSP handler servlet - JSP Handler Servlet
- Check JSP file, execute the existing .class
servlet when no change - When there was change, generate .java source
code from .jsp - Compile the java source
- when .class file was generated normally, execute
the servlet.
14Servlet and JSP Examples
- Refer to Apache Tomcat
- When you install Apache Tomcat,
- http//localhost8080/examples/servlets/
- http//localhost8080/examples/jsp/
15Introduction toJava Remote Method Invocation
(RMI)
16Distributed Objects
- Objects that can communicate with objects on
heterogeneous run-time environments - Distribute Objects Standard Protocol ex JRMP
- Robust
- Reliable
- Transparent
- Distributed Objects Technology
- Multi-Platform
- Transparent access to distributed objects
- Language Neutral RMI, CORBA, DCOM
17Java Remote Method Invocation (RMI)
- Can use objects on remote different run-time
environments as like objects on a local run-time
environment - Abstraction of low-level network code on
distributed network to provide developers an
environment where they focus on their application
development.
18Introduction to RMI
- Distributed Processing on Network
- Define of Remote Interface
- Object Serialization
- java.rmi and java.rmi.server
- Create Stub and Skeleton
19Communication of Remote Object and Client
JVM
JVM
Remote Object
Client
Stub
Skeleton
RMI Client Application
RMI Server Application
Network
20Writing Java RMI Application
- Writing RMI Application
- Definition of Remote Interface
- Definition of Remote Implementation Class
- Write RMI Server Application
- Write Client Application
- Compile and Run the Application
- Compilation of the Implementation Class
- Creation of Stub and Skeleton using rmic
command - Compilation of the Server Application
- Run the RMI Registry and Start the Server
Program - Compilation of the Client Program
- Run the Client
21Hello Example RMI
Interface
import java.rmi.Remote import
java.rmi.RemoteException public interface
Hello extends Remote String sayHello()
throws RemoteException
22Hello Example RMI
HelloImpl object
Implementation (Server)
import java.rmi.Naming import
java.rmi.RemoteException import
java.rmi.RMISecurityManager import
java.rmi.server.UnicastRemoteObject public
class HelloImpl extends UnicastRemoteObject
implements Hello public HelloImpl() throws
RemoteException super()
public String sayHello() return "Hello
World!" public static void
main(String args) // Create and
install a security manager if
(System.getSecurityManager() null)
System.setSecurityManager(new RMISecurityManager()
)
try HelloImpl obj new HelloImpl()
// Bind this object instance to the name
"HelloServer" Naming.rebind("HelloServer",
obj) System.out.println("HelloServer bound
in registry") catch (Exception e)
System.out.println("HelloImpl err "
e.getMessage()) e.printStackTrace()
Compile Skeleton Creation javac
Hello.java javac HelloImpl.java rmic HelloImpl
23Hello Example RMI
A Client Application
import java.rmi.Naming import
java.rmi.RemoteException public class
HelloClient public static void main(String
args) String message "Hello This is my
test message" // "obj" is the identifier
that we'll use to refer // to the remote
object that implements the "Hello" //
interface Hello obj null try
obj (Hello)Naming.lookup("//"
"/HelloServer") message obj.sayHello()
catch (Exception e)
System.out.println("HelloClient exception "
e.getMessage()) e.printStackTrace()
System.out.println("Message " message)
// end of main // end of HelloClient
24Hello Example RMI
File policy
grant // Allow everything for now permission
java.security.AllPermission
Start Registry Server Run Server and Client
rmiregistry java Djava.security.policypoli
cy HelloImpl javac examples/hello/HelloClient.j
ava java Djava.security.policypolicy
HelloClient
Run the RMI Server
Compile the Client
Please ensure there is the policy file in the
current directory
Run the Client
25RMI Structure
- Protocol
- Java Remote Method Protocol (JRMP)
- For distribute object environment by pure Java
environment - RMI/IIOP Can communicate with CORBA
- JRMP
- Communication Mechanism between Stub and
Skeleton - Object Serialization Types of parameters and
return type of a remote method should follow Java
serialization mechanism
26Stub and Skeleton
JVM
JVM
Remote Method Invocation
Remote Method Invocation
Remote Object
Client
Stub
Skeleton
Data Transformation
Remote Method Return
RMI Client Application
RMI Server Application
Unmarshalling
Unmarshalling
Marshalling
Marshalling
Object Serialization
Network
27Stub and Skeleton
- Stubs and Skeleton
- When RMI client invokes a remote method of a
remote object, it uses stub reference of the
remote object instead of remote object reference. - For marshalling and unmarshalling of stub and
skeleton, object serialization and
deserialization are used. - Condition of Object for Object Serialization
- Object should implementjava.io.Serialization
interface - Built-in types can be serialized basically
- Member variables should implement the
Serializable interface or be declared as
transient - Static member variables can not be serialized.
28JRMP Class
Marshall/Unmarshall (Object Serialization)
Virtual connection
Network connection
Creation of reference to remote object
Managing connection to remote object
29Introduction toCommon Object Request Broker
Architecture(CORBA)
30Contents
- Overview of distributed programming challenges
- Overview of CORBA architecture
- CORBA programming with Java ORB
- WWW, Java and CORBA
- GIOP and IIOP
- Trends in Internet
31CORBA Contributions
- CORBA addresses two challenges of developing
distributed system - Making distributed application development no
more difficult than developing centralized
programs. - Easier said than done due to
- Partial failures
- Impact of latency
- Load balancing
- Event Ordering
- Providing an infrastructure to integrate
application components into a distributed system - i.e., CORBA is an "enabling technology"
32CORBA Architecture
33Related Works
- Related technologies for application integration
include - Traditional RPC
- Provides "procedural" integration of application
serveices - Doesn't provide object abstractions
- Does not address inheritance of interfaces
- Widows DCOM
34CORBA Components
- The CORBA specification is comprised of several
parts - 1. An Object Request Broker (ORB)
- 2. Basic Object Adapter (BOA), Portable Object
Adapter(POA) - 3. An Interface Definition Language (IDL)
- 4. A Static Invocation Interface (SII)
- 5. A Dynamic Invocation Interface (DII)
- 6. A Dynamic Skeleton Interface(DSI)
- 7. Interface and implementation repositories
- 8. Programming language mappings
- 9. An Interoperability Spec(GIOP and IIOP)
- Other documents form OMG descirbe common object
services built upon CORBAservices - e.g. , Event services, Name services, Lifecycle
service
35Object Request Broker
- The Object Request Broker(ORB) is the central
component in CORBA - An ORB provides mechanisms for invoking methods
on local/remote objects - ORB mechanisms automate
- Object location, creation, activation and object
management - Message exchange between objects
- CORBA ORB provides security also.
36Interface Definition Language (IDL)
- Developing flexible distributed applications
on heterogeneous platforms requires a strict
separation of interface from implementation(s) - Benefits of using an IDL
- Ensure platform independence
- e.g., Windows NT to UNIX
- Enforce modularity
- e.g., must separate concerns
- Increase robustness
- e.g., reduce opportunities for network
programming errors - Enable language independence
- e.g., C, Smalltalk, COBOL to C, Java
37CORBA IDL
- OMG IDL is an object-oriented interface
definition language - Used to specify interfaces containing operations
and attributes - OMG IDL support interface inheritance (both
single and multiple inheritance) - OMG IDL is designed to map onto multiple
programming languages - e.g., C, C, Smalltalk, COBOL, Modula 3, DCE,
Java, etc. - OMG IDL is similar to Java interfaces, class and
C class
38Initial OMG IDL Bank Specification
- // Bank.idl
- module Bank
- interface Account
- float balance()
-
- interface AccountManager
- Account open(in string name)
-
39OMG IDL Compiler
- A OMG IDL compiler generates client stubs and
server skeletons - Stubs and skeletons automate the following
activities (in conjunction with the ORB) - Client proxy factories
- Prameter marshalling/demarshalling
- Implementation class interface generation
- Object registration and activation
- Object location and binding
40Producing IDL file, Client, and Object
Implementation
41Application Interfaces
- Interfaces described using OMG IDL may be
application-specific, e.g., - Databases
- Spreadsheets
- Spell checker
- Network manager
- Air traffic control
- Documents
- Medical imaging systems
- Objects may be defined at any level of
granularity - e.g., from fine-grained GUI objects to multi-mega
byte multimedia "Blobs"
42OMG IDL Features
- OMG IDL is a superset of C, Java, etc.
- Note, it is not a complete programming language,
it only defines interfaces - OMG IDL supports the following features
- Modules
- Interfaces
- Operations
- Attributes
- Inheritance
- Basic types(e.g., double, long, char, etc).
- Arrays
- Sequence
- Struct, enum, union, typedef
- Consts
- Exceptions
43Object References
- An "Object reference" is an opaque handle to an
object - Object references amy be passed among processes
on separate hosts - The underlying CORBA ORB will correctly convert
object references into a form that can be
transmitted over the network - Presumably by converting it to a "stringfied"
reference - The ORB passes the receiver's implementation a
pointer to a proxy in its own address space - This proxy refers to the object's implementation
- Object references are a powerful feature of CORBA
- e.g., supports "peer-to-peer" interactions
44Object Adaptor
- CORBA "object adaptors" provide services for
binding object references to their associated
object implementations - Several types of object adaptors are available
- Basic Object Adaptor(BOA)
- Objects and object references are known to the
ORB - Thus, an object implementation has to explicitly
register objects to be activated - Object-Oriented Database Adaptor(OODA)
- This adapter uses a connection to an o-o db to
access the objects stored in it. - Since the OODB provides the emthods and
persistent storage, object may be registerd
implicitly.
45Object Adaptor
- Creation and Analysis of Object Reference
- Method Invocation
- Interaction
- Activation and Deactivation of Object and
Implementation - Matching to Object Implementation According to
Object Reference - Registration of Object
- Problem of BOA
- Inconsistency of Specification
- Difference of BOA Implementation
- Problem in Server Portability
46Portable Object Adaptor
- Allow the Persistent Object
- Allow more Object Implementation
-
- Characteristics
- Map an Object Reference to the Servant that
Implements that object - Allow Transparent Activation of Objects
- Associate Policy Information With Objects
- Make a CORBA object persistent over several
server process lifetimes - Object ID Namespace
- Policy of Multi-Threading, Security, Object
Management - Multi POA with different policy and name space
exist in a server
47EXAMPLE
- Hello Example
- Look at the demonstration
- You can exercise the CORBA programming using JDK
simply.
48Internet Inter-ORB Protocol (IIOP)
- The mapping of the GIOP message transfer to
TCP/IP connections is called IIOP - GIOP can map to Novell IPX and OSI also
- TCP/IP Connection Usage
- Servers must listen for connection requests.
- A client needing a objects services must
initiate a connection with the address specified
in the IOR, with a connection request - The listening server may accept or reject the
connection. - Once a connection is accepted, the client may
send Request, LocateRequest, or CancelRequest
messages by writing to the TCP/IP socket it owns
for the connection.
49CORBA Common Services
- Basic Services to build distributed object system
- Naming, Event, Persistence, Life Cycle,
Concurrency, Externalization, Relation,
Transaction, Timing, License, Security,Property,
Query, Trader, Collection, Startup, Interface
type Version Management Services
50CORBA Common Facilities
- Software Components to provide some application
function - Horizontal facilities, Vertical facilities
- Horizontal facilities Compound Presentation,
Compound Interchange, Internalization, Time
Operations, Mobile Agent, System Management - Vertical facilities Healthcare, Financial
Facilities.