Computer Networks - Villanova University
Download
Report
Transcript Computer Networks - Villanova University
Computer Networks
Boots Cassel
Villanova University
Client - Server Computing
Direction of initiation determines which
side is which
– Client initiates
– Server responds
Same system may be client and server
Parameterization of clients
Parameter specifies machine where server
resides
Optional parameter specifies the port where
the server listens
– Include the port number parameter in defining
clients
– Especially useful for testing new versions
Addressing
Specify the machine
– name gets converted to IP address
Specify the port number
– Which running process to connect to.
How do you know
Which machine
– you have to know the name or the IP address of
the partner
• Names get converted by a Domain Name Service
Which port
– Common services have assigned port numbers
– telnet = 23, http = 80, etc.
Domain Name Service
Structure of Internet Names
– gadget.netlab.csc.villanova.edu
– Lookup in order from right to left
• netlab and csc are both entries in the villanova DNS,
so that lookup can go directly from villanova to
netlab without using the csc DNS
• That is always an option in configuring the servers
DNS - Christie’s table
; Addresses for the canonical names
;
localhost.netlab.csc.villanova.edu.
IN A 127.0.0.1
christie.netlab.csc.villanova.edu.
IN A 153.104.203.200
doyle.netlab.csc.villanova.edu.
IN A 153.104.203.210
gadget.netlab.csc.villanova.edu.
IN A 153.104.203.42
missmarple.netlab.csc.villanova.edu. IN A 153.104.203.7
lordpeter.netlab.csc.villanova.edu. IN A 153.104.203.41
poirot.netlab.csc.villanova.edu.
IN A 153.104.203.148
koko.netlab.csc.villanova.edu.
IN A 153.104.203.45
sherlock.netlab.csc.villanova.edu.
IN A 153.104.203.44
cadfael.netlab.csc.villanova.edu.
IN A 153.104.203.43
columbo.netlab.csc.villanova.edu.
IN A 153.104.203.46
weber.netlab.csc.villanova.edu.
IN A 153.104.203.205
matlock.netlab.csc.villanova.edu.
IN A 153.104.203.203
samspade.netlab.csc.villanova.edu.
IN A 153.104.203.204
poe.netlab.csc.villanova.edu.
IN A 153.104.203.50
Port number usage
Some implementations do not allow the
user to specify a port number
– uses the protocol’s reserved number only
– Allowing a port number to be specified makes
it easier to test the implementation
• allow the “real” version to run while testing a
different version
Server
Usually runs in privileged condition
– needs to access protected resources
– be careful about what access it gives to clients
Responsibilities
– Authenticate client identity
– Enforce authorization restrictions
– Data protection: security and privacy
– Protection: system resources from abuse
Connectionless vs
Connection-oriented
Directly related to the choice of transport
protocol
– UDP: connectionless
– TCP: connection-oriented
Can build connection-oriented client/server
application over a connectionless transport
layer
Silly to do the converse
Server state
Stateless server
– no memory of past interaction
– each request must be fully qualified
Stateful server
– records state information
– reduces needed content in subsequent messages
– depends on reliable network communication
– vulnerable to system failures, reboots
Idempotent operations
An operation that always yields the same
result, regardless of repetition or missing
prior steps
– READ or WRITE, without automatic increment
of pointer
– not idempotent - increment, add amount to
total, etc.
Concurrent processes
Multiprogramming
– Apparent simultaneous execution
Multiprocessing
– Real simultaneous execution
Server Concurrency
Need to serve requests from multiple clients
Process
– Fundamental unit of computation
– Address space plus at least one thread of
execution
• instruction pointer tells where in the process the
thread is currently executing
Threads
Similar to a process except
– a thread is owned by a process
– a thread may share common resources
belonging to a process
A thread has a private copy of local
variables
Concurrent processes
In a uniprocessor system
– Each process gets a slice of the CPU time in turn
– All appear to run at the same time
If each process has only one thread of execution,
that process shares the CPU with other processes on
a time sharing plan
If a process has more than one thread, the CPU time
is divided among the threads.
– OS varies: divide time among all threads or divide among
processes and multiple threads share the time allotted to their
parent process
In a multiprocessor system, each process or thread
may be allocated a separate CPU
Threads in servers
A process may respond to client requests by
spawning a separate thread for each client
Clients appear to be served simultaneously
but actually receive intermingled slices of
the CPU time.
Unix concurrency
Different operating systems handle
concurrency in idfferent ways
– unix: fork() creates an exact copy of the calling
process and continues execution from exactly
the same place in the code.
• Copy includes the stack showing function calls,
local and global variables
• Original and forked process continue from the same
point in execution
• One distinction: fork returns a value: new process
returns 0, original returns non zero value
Unix concurrency example
Sum = 0;
pid = fork();
if (pid != 0 ) { /* original */
printf (“The original process\n”);
}else {
/* the new process */
printf (“The new process\n”);
Concurrency in Windows
_beginthread
– parameter specifies what is to be executed
Not necessarily executing the same code as
the calling process
Sockets
A de facto standard interface to TCP/IP
protocols
Defined in BSD unix
Adapted by other operating systems
Initiating concurrent
subprocesses
Windows:
– _beginthread
• parameter specifies what to execute as thread
unix
– fork
• new process is a copy of the initiating process
• pid identifies each