Data Communication I Lecture 4a
presented by Werner Wild, CEO Evolution Innsbruck, San Francisco, Zurich Contact:
[email protected]
Today’s Lecture Plan
Globe, Review TCP , UDP
Resolver Discovery Services URN
resolution breaks into 2 steps:
– finding the appropriate resolver (RDS), and – then resolving the URN. kris RDS fer: r nd o e b u n: b o t z o. n l i ng l c . e nz:w elecom : e on r n .t u : ph n k r s u 2. A nd
Client
i 13. F . Fin
d ur n:ph one :nz: wel ling 4. + t on: 64bu b 4-5 end 55orfe 555 r:kr URN 5 is
urn.telecom.co.nz
Resolver
Alternative Architectures Locating
resources is a more difficult problem if those resources are mobile. This includes people, hardware, data and programs. Alternative architectures must be designed to locate mobile resources. – Globe – Nomad
Globe The
Globe system details a location service that is designed to: – scale globally (load distribution), and – handle mobility (via locality of reference).
Distributed
Object Model:
– One ‘object’ is split over n hosts. – Object is a composite -> unit of identity. Developed
at Virje University in Holland.
Globe Quad Tree (Load Balancing)
The Globe location service divides the world geographically using a quad tree. When load increases above a load threshold in a region, the region is further divided.
Near empty regions are (physically) merged with neighbors. But still exist logically.
How it works (Insertion). A rooted hierarchical tree. Insertions start at leaf:
Ref A, A Ref B, ... root Ref
– bottom up,
– to the root,
Root must contain all references.
Ref B, Ref A
Ref B
Ref A
Ref B
B
Ref A
A
How it works (Location).
Searches also start at local leaf, – geographic locality -> root is not traversed, – worst-case is to root
Uses heuristics to organize the nodes. B finds A A finds C
root Ref A, Ref B, ...
Ref B, Ref A
?
Ref A
?
B
Ref A
A
C
How it works (Mobility).
Updates also start at local leaf, – geographic locality -> root is not traversed, – worst-case is to root
Only need to update until we find an existing reference, then update. E.g. A moves to A’
root Ref A, Ref B, ...
Ref A
Ref A’ A
Ref A
A’ A
Problems Root
must know all references (Scale!).
– Uses heuristics to partition the root onto n physical distributed machines. Searching
is fast, but:
– only for logically close objects (A&C). Updating
location due to mobility,
– slower the further the object moves. So,
resolution times are inconsistent.
Nomad The
Nomad Location Service is designed
– specifically to handle mobility, in – large scale distributed systems. Application
Object Cluster Model:
– n application objects per cluster, – cluster is the unit of identity, and location. Developed
in New Zealand
applications
Review the Transport Layer
technology
transport protocol
Layer Architecture Application
Transport
mail, file transfer, web
tcp, udp
Application
Transport
ip Internet
Internet
Internet
Media access
Media access
Media access
Roles and Responsibilities Logical
communication between processes Message oriented – Best effort, single message delivery Connection
oriented
– Sequenced, error free, stream – Flow and congestion control
The Transport Layers application ? UDP User
Datagram Protocol Independent segments Best effort delivery
TCP Transmission
Control
Protocol Reliable stream Manages segments (parts of stream)
Multiplexing
application
UDP
TCP IP
IP (network layer) receives all segments for host IP delivers to appropriate transport layer Transport protocol delivers to socket (application)
The Role of Headers transport header network header
source destination other port port header
source destination protocol host host
Each
protocol has a header Network header addresses machines – Denotes protocol (TCP or UDP) Transport
header addresses ports (sockets)
data
Port and Sockets Previously
seen from the application layer. Port numbers 16 bits, 0->65535. Port numbers 0->1023 are well known port numbers, and are restricted. Why does a transport header have both source and destination port numbers? Surely the destination port number alone is sufficient to identify the recipient?
Simple Example Client
is assigned some random unused port X by its host. The SMTP server runs on well known port 25. Reply
is to destination port X, with src port 25
host A
source port: x dest. port: 25
server B
source port:25 dest. port: x
port use: simple smtp
What About Two Clients? host A
source port: x dest. port: 25
server B
source port:25 dest. port: x
Source IP: C Dest IP: B source port: y dest. port: 80
port use: simple smtp
Web client host A
Web client host C
Source IP: A Dest IP: B source port: x dest. port: 80
Source IP: C Dest IP: B source port: x dest. port: 80
Web server B port use: Web server
Ports and Sockets - Detail Server
listens on a socket for a connection Connect request causes new socket on same port Server uses new thread to service connection
listener thread
worker worker
TCP server socket socket port
UDP “best
effort” service, segments may be: – lost – delivered out of order
connectionless:
– no handshaking between sender, receiver – each segment handled independently
Why
have UDP?
no connection establishment (which can add delay) simple: no connection state at sender, receiver small segment header no congestion control: UDP can blast away as fast as desired
More on UDP includes UDP used
for
header
– DNS – SNMP – Multimedia streaming Loss tolerant Rate sensitive
src port no dest port no length
checksum
reliable
data
transfer
– add reliability at application layer
32 bits
UDP Checksum Goal: detect “errors” in transmitted segment Sender
treat segment contents as sequence of 16-bit integers checksum: addition (1’s complement sum) of segment contents sender puts checksum value into UDP checksum field
Receiver
compute checksum of received segment check if computed checksum equals checksum field value: – NO - error detected – YES - no error detected. But maybe errors nonetheless?
TCP Socket Structure Client process
Server process 3-way handshake
client socket stream data
“public” socket “connection” socket
TCP Steps Client Server (on hostId) Create public socket with port = x
Create socket Connect to hostId, port x Send request on client socket
Wait for connection create connection socket Read request from connection socket Write reply to connection socket
Read reply from client socket Close client socket
Java server (TCP) import java.io.*; import java.net.*; class TCPServer {
Create welcoming socket at port 6789 Wait, on welcoming socket for contact by client Create input stream, attached to socket
public static void main(String argv[]) throws Exception { String clientSentence; String capitalizedSentence; ServerSocket welcomeSocket = new ServerSocket(6789); while(true) { Socket connectionSocket = welcomeSocket.accept(); BufferedReader inFromClient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream()));
Java server (TCP), cont Create output stream, attached to socket Read in line from socket
DataOutputStream outToClient = new DataOutputStream(connectionSocket.getOutputStream()); clientSentence = inFromClient.readLine(); capitalizedSentence = clientSentence.toUpperCase() + '\n';
Write out line to socket
outToClient.writeBytes(capitalizedSentence); } }
}
End of while loop, loop back and wait for another client connection
Example: Java client (TCP) import java.io.*; import java.net.*; class TCPClient { public static void main(String argv[]) throws Exception { String sentence; String modifiedSentence; Create input stream Create client socket, connect to server Create output stream attached to socket
BufferedReader inFromUser = new BufferedReader(new InputStreamReader(System.in)); Socket clientSocket = new Socket("hostname", 6789); DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream());
Example: Java client (TCP), cont. Create input stream attached to socket
BufferedReader inFromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); sentence = inFromUser.readLine();
Send line to server
outToServer.writeBytes(sentence + '\n'); modifiedSentence = inFromServer.readLine();
Read line from server
System.out.println("FROM SERVER: " + modifiedSentence); clientSocket.close(); }
}
The End. We
learned about:
– the Socket API connecting them to the transport layer.
reliable (TCP) vs. unreliable (UDP) msg transfer
Thank
you for your attention !
Sources For
the preparation of this lectures a lot of sources where used – my special thanks go to : – – – –
Univ. Auckland Univ. California – San Diego (UCSD) Univ. Hongkong … many others …