View
218
Download
3
Category
Tags:
Preview:
Citation preview
1
The Internet
2
The Internet is an open system
Details publicly availableA lot of software is freeLots of publicly available expertise available via such things as newsgroupsDangers with privacy
3
Implications of open systems
Wide variety of implementations, for example of TCP/IPCost of implementation lessHigh level of compatibilityWide variety of developers selling products
4
Examples of open systems and code
HTTPTCP/IPJavaLinuxApache
5
Network topolocies
Bus networkRing networkHub network
6
Bus network
Terminator
Devices: computers, printers etc
7
Ring network
ComputerComputer
PrinterMass storage device
8
Hub network
Ports
Backplane
9
The Internet has a layered architecture
Level of functionalityEach level draws upon facilities in a lower levelAs you proceed downwards you get nearer the computerAchieves separation of concerns
10
Internet history (i)
ARPA started the ARPAnet networkARPAnet originally used the NCP protocol1974 Cerf and Kahn developed TCP/IP
11
Internet history (ii)Splitting of ARPAnet into MILnet and ARPAnetRenaming of ARPAnet as InternetDevelopment of Web at CERNDevelopment of new protocols to cope with huge growth
12
Internet protocols(i)Telnet, used for connectionsFile Transfer Prototcol (FTP), used for file transferSimple Mail Transfer Protocol (SMTP), used for electronic mailKerberos, used for security functions
13
Internet protocols(ii)Network File System (NFS), used for transparent file sharingTrivial File Transfer Protocol (TFTP), used for fast transmission of filesTransmission Control Protocol (TCP), used for fast transmission of files.
14
Internet protocols(iii)User Datagram Protocol (UDP), used for fast transfer of data, unreliable.HyperText Transfer Protocol (HTTP), used for transferring Web documentsInternet Protocol (IP), basic functioning of moving data
15
Identifying computers on the Internet
A basic function of any network is naming: identifying computers and other resources using some unique name.Dotted quad notation identifies an IP addressDomain naming uses symbolic names
16
IP addressesIP addresses expressed in dotted quad identify a computer. Addresses can be class A, class B, class C or class D. They identify a network and a computer on the entwork.
17
An example: the class A address
Network address Computer address
1 bit 7 bits 24 bits
1 bit used to designate class A
7 bits used to identify network
24 bits used to identify computer
18
Dotted quad notation
Used to identify a computer, four 8 bit quantities reflecting the 32 bits used in the Internet
101.23.111.128Example
19
The loopback address
The address 127.0.01 is known as the loop-back address.
Any data which is sent to this address from a computer will return straight to the computer
20
Domain Name SystemDotted quad suffers from a major problem: difficult to rememberBetter for symbolic names to be usedThis is the purpose of the Domain Name System (DNS)
21
An example
www.gold.ac.uk
Name of the computer
Name of organisation
Academic organisation, edu used in America
Country of origin
22
Some domainscom, a commercial companyedu or ac, educational insitutiongov, governmental organisationmil, military organisationmuseum, museums
23
Hierarchic naming
com edu gov …… uk fr
mit
cs
athena
athena.cs.mit.edu
The computer athena in the cs department at MIT
24
import java.net.*;
public class Whoami {
public static void main(String[] args)
throws Exception {
if(args.length < 1) {
System.err.println(
“You need to supply a Machine name");
System.exit(1);
}
InetAddress a =
InetAddress.getByName(args[0]);
System.out.println(a);
}
}
25
Client and serversA network can be envisioned as a set of clients and serversServers provide a service, for example a Web server delivers Web documentsClients call on the services provided by a server
26
Distributed Computing in Java
"The Network is the Computer"--Scott McNealy, CEO of Sun Microsystems
Make computing across networks as simple and reliable as stand-alone computing
In Java, programming across networks is based on simple IO. So we will review that.
27
What are the main distributed computing tasks: Remember Mickey
Mouse Fetch the Water:
Fetch some information from a distant machine machine over there and move it to this machine here, or vice versa.
The easiest way to do this is via Sockets. This is based on streams and is very like IO. We will start our Java here.
28
Make a connection to a water supply:
Connect to a database, possibly residing on one or more other machines.
Java DataBase Connectivity (JDBC), is an abstraction away from the messy, platform-specific details of SQL.
We will start with the messy way.
29
Make your water available:Provide services via a Web server. Three ways to do this in Java:
Applets: download the Java Code and run it on your own machine
Servlets: run it on the Web server
Java Server Pages (JSPs)incorporate in web pages.
30
Control brooms from afar:
Execute methods on Java objects that live on remote machines. This is accomplished with Java’s
Remote Method Invocation (RMI).
31
Integrate with other pre-written spells.
Use code written in other languages, running on other architectures.
Common Object Request Broker Architecture (CORBA), which is supported In Java.
32
Other Java technologiesEnterprise Java Beans
Separate out functionality from connection
JINI Add and remove objects
33
ConcurrencyRemember in Mickey: there are lots of brooms at the same poolThere are essentially two ways to do this:
HeavyWeight Processes: keep them quiet separate
LightWeight Proceses: interleave them
Java supports Lightweight processes through the use of threads
34
Layers of Distribution in Java
1. Sockets
The model here is computer to computer connection
2. RMI (Remote Method Invocation)The model here is object to object connection. Relies on the same semantics, probably same language And still need to know where it is
35
3. CORBA (Common Object Request Broker Architecture)
Here the language and location are abstracted away.
4. Voyager and mobile agents Here objects can be moved
36
Ports and socketsA port is a logical TCP/IP idea, not to be confused with a hardware portPorts are used for data communicationsNumberedSome ports are dedicated to certain applications
37
Some dedicated ports80 is used for Web traffic25 is used for the Simple Mail Transfer Protocol110 is used for the Post Office Protocol version 3 email service21 is used for the File Transfer Protocol
38
Sockets and server sockets
A socket is a connection into a computerA server socket is used to create a socket on a serverJava contains facilities for setting up sockets and server sockets and connecting streams
39
Address of Computer: IP Address
Address of a connection to a computer: Port (e.g. 25 for telnet)
Communication Channel through a port: Socket
40
Sockets and data input in Java
Socket ss = new Socket(“igor.gold.ac.uk”, 2048);InputStream is = ss.getInputStream();BufferedReader bf = new BufferedReader (new InputStreamReader(is));
Creates a BufferedReader to the computer igor at Goldsmiths College via port 2048, data can now be read from igor
41
Sockets and data output in Java
Socket ss = new Socket(“scorpio.gold.ac.uk”, 2048);OutputStream os = ss.getOutputStream();PrintWriter pw = new PrintWriter(os, true):
Sets up a PrintWriter object attached to the computer scorpio at Goldsmiths College. The client can then write data to this computer. Note that true in the PrintWriter constructor flushes data from the buffer automatically
42
The ServerSocket classUsed to generate sockets at a server.Has a constructor which specifies the port to be used.Method accept blocks until a client connection is made and then generates a Socket object.
43
StreamsAbstraction for arbitrary data streamse.g. System.out.println()
System is in java.langin out and err are static fields in System
each is a stream (actually a subclass, e.g PrintStream)
44
There are InputStreams and OutputStreams
These are abstract classes
Children are things like input byte streams
45
Generating streams at a server
ServerSocket ss = new ServerSocket(200);//Wait for a connectionwhile (true)
{ System.out.println (“waiting for client”);
Socket Client = ss.accept();
InputStream is = sockS.getInputStream();OutputStream os = sockS.getOutputStream();// is and os can then be used for communication// to the server
46
// Time Server
import java.net.*;import java.io.*;import java.util.*;
public class TimeServer {
public static void main (Stringargs[]) throws IOException {
int port = 1234;
ServerSocket server = newServerSocket(port);
while (true) { System.out.println("Waiting for
client..."); Socket client = server.accept();
System.out.println("Client from"+client.getInetAddress()+"connected.");
OutputStream out =client.getOutputStream();
Date date = new Date(); byte b[] =
date.toString().getBytes(); out.write(b);}
}
47
// TimeClient
import java.net.*;import java.io.*;
public class TimeClient {
public static void main (String args[]) throws IOException {
Socket server = new Socket ("localhost",1234);
System.out.println("Connected to"+server.getInetAddress());
InputStream in = server.getInputStream();
byte b[] = new byte[100]; int num = in.read(b);
String date = new String(b);
System.out.println("Server said: "+date); }}
Recommended