Professional Documents
Culture Documents
Client-server paradigm
Client-server paradigm
Typical network app has two pieces: client and server Client: initiates contact with server (speaks first) typically requests service from server, for Web, client is implemented in browser; for e-mail, in mail reader Server: provides requested service to client, via replies e.g., Web server sends requested Web page, mail server delivers e-mail
application transport network data link physical
request
reply
application transport network data link physical
Fundamental motivation
TCP/IP does not automatically create running programs when messages arrive So a program must be waiting to accept communications when requests arrive This is the server while the other party is the client
Client-server applications
Have one of two types of interaction: connectionless style (UDP) or connection-oriented mode (TCP)
Socket types
Socket identification:
IP address of client and server hosts port number of client and server applications
Socket types:
reliable, byte stream-oriented (TCP)
Unreliable, connection-less datagram (UDP) Raw Socket (IP)
Server Process
UNIX
version
Server Process
socket()
UDP
bind()
Client Process
1 2
recvfrom()
get a blocked client
Client Process
read()
procees request
write()
read()
sendto()
recvfrom()
5
Server Process
Winsock
or Unix
Server Process
version
TCP
socket()
UDP
bind()
Client Process
1 2
recvfrom()
get a blocked client
Client Process
recv()
process request
send()
recv()
sendto()
recvfrom()
6
IP (Raw) Socket
To use RAW sockets in Unix it is mandatory that one have root authority. To create a RAW socket write: s=socket(AF_INET,SOCK_RAW,[protocol])
Then you can send or receive over it. Raw sockets are used to generate / receive packets of a type that the kernel doesn't explicitly support.
A familiar example is PING. Ping works by sending out an ICMP echo packet.
It formats an ICMP echo packet and sends it out over a SOCK_RAW, waiting for a response.
10
Thank you
11