City & Guilds Graduate Diploma
Unit 121
Computer Network (Level 6)
Outcome 3
Sockets Programming and Implementation
Client/Server Programs
Unit 121 - Basic Concept of Computer Network, Layered Architecture and Protocols
FTP & TFTP Server
Why do we need a FTP Service?
Purpose: To Transfer files between two computers
Goals of FTP Service
Promote sharing of files (programs and/or data)
Encourage indirect/implicit use of remote computers
Shield users from variations in file storage among hosts
Transfer data reliably and efficiently
Problems of File Transfer
At first, file transfer may seem simple
Heterogeneous systems use different:
Operating Systems
Character Sets
Naming Conventions
Directory Structures
File Structures and Formats
FTP need to address and resolve these problems
FTP & TFTP Server
FTP Connections
FTP & TFTP Server
FTP Connection
FTP & TFTP Server
FTP Data Transfer
FTP & TFTP Server
FTP Client Commands (issued by user interface)
FTP & TFTP Server
Summary of FTP connections Trivial FTP (TFTP)
FTP has 2 connections
- Control (persistent Used only to read and write files
connection) from/to a remote server
- Server issues a passive Cannot list directories
open on well-known 21 Useful for bootstrapping diskless
- Client uses an ephemeral systems
port to issue active open Workstations
- Server ultimately closes X terminals
control connection Simple and small:
- Data (ephemeral connection) 5 message formats
- Client issues passive open Runs on UDP
on an ephemeral port Designed to fit in ROM
- Client sends this port to Uses a stop and wait
server via PORT command protocol
- Server receives the port NO BUILT IN SECURITY
number and issues active FEATURES (login)
open using its well-known
20 to the received
ephemeral port
FTP & TFTP Server
FTP vs. TFTP
FTP provides (minimal) TFTP has NO login procedure
security through login TFTP must handle its own
procedure retransmissions since it uses
FTP Provides a reliable UDP
service through its use of TCP TFTP uses one connection
FTP uses two connections (stop and wait)
FTP provides many TFTP can only read and write
commands files
Web Server
What is a Web Server?
Program that understands the HTTP protocol and generates
appropriate responses
Clients connect to the machine
Clients send a request
Server reads request, generates response
Client interprets response appropriately
A Simplified Web Server
Client asks for file
Server finds appropriate file
Server sends back a response header followed by the requested files
data
Server closes connection
Web server
Responds to client requests by providing resources
URI (Uniform Resource Identifier)
Web server and client communicate with platform-independent Hypertext
Transfer Protocol (HTTP)
Web Server
How the WWW Works
Web Server
Domain Name Server System
Web Server
Example of an HTTP Request from a Web browser
HTTP response from a Web server
Web Server
HTTP Request Types
GET (default) and POST do basically the same thing: Send data from the
client to the server. However, they have some differences:
GET
Appends form data directly to the end of the URLvisible to users
(not suitable for sending passwords)
Limited to 2,048 characters for the entire URL
Result page can be bookmarked and cached
POST
Sends form data in the HTTP requestinvisible to users
Virtually no limit (but check your specific configuration)
Results are not cacheable or book markable
Web Server
Hosting a website: Self hosting Hosting a website: Hosting service
Register a domain name
Install a web server on a computer Assign name servers
Local access Host takes care of IP
Using domain <localhost> addressing
or IP address 127.0.0.1 Develop website locally
Necessary for server-side Upload website via FTP for
programming development global access
Global access E.g. Filezilla
Register a human-readable
domain name
Obtain IP address Apache Web Server
Static: Costs more
Dynamic: Needs dynamic Currently the most popular Web
DNS system, e.g. server
http://www.dyndns.com/
Stability
Efficiency
Portability
Open-source
Web Server
Introduction to HTTP
http request http request
Laptop w/ http response http response
Netscape Desktop w/
Server w/ Apache Explorer
HTTP: Hypertext Transfer Protocol
Communication protocol between clients and servers
Application layer protocol for WWW
Client/Server model:
Client: browser that requests, receives, displays object
Server: receives requests and responds to them
Protocol consists of various operations
Few for HTTP 1.0 (RFC 1945, 1996)
Many more in HTTP 1.1 (RFC 2616, 1999)
Web Server
What Happens Then?
Client downloads HTML document
Sometimes called container
page
Typically in text format (ASCII)
Contains instructions for rendering
(e.g., background color, frames)
Links to other pages
Many have embedded objects:
Images: GIF, JPG (logos, banner
ads)
Usually automatically retrieved
I.e., without user involvement
can control sometimes
(e.g. browser options,
junkbusters)
Web Server
So Whats a Web Server Do?
Respond to client requests, typically a browser
Can be a proxy, which aggregates client requests
Could be search engine spider or custom
May have work to do on clients behalf:
Is the clients cached copy still good?
Is client authorized to get this document?
Is client a proxy on someone elses behalf?
Run an arbitrary program (e.g., stock trade)
Hundreds or thousands of simultaneous clients
Hard to predict how many will show up on some day
Many requests are in progress concurrently
Mail Server
Three major components:
Simple Mail Transfer Protocol (SMTP) user agents, mail servers, SMTP
Protocol originated in 1982 (RFC821, Jon User Agent
Postel) a.k.a. mail reader
Standard message format (RFC822,2822, D. composing, editing, reading mail
Crocker) messages
Goal: To transfer mail reliably and efficiently e.g., Eudora, Outlook, elm,
Netscape Messenger
Mail Servers
mailbox contains incoming
messages for user
message queue of outgoing (to
be sent) mail messages
use SMTP protocol between mail
servers to send email messages
client: sending mail server
server: receiving mail
server gmail?
Mail Server
Simple Mail Transfer Protocol (SMTP)
SMTP clients and servers have
two main components
User Agents Prepares the
message, encloses it in an
envelope. (ex. Thunderbird,
Eudora)
Mail Transfer Agent
Transfers the mail across the
internet (ex. Sendmail, Exim)
Analogous to the postal
system in many ways
Mail Server
Simple Mail Transfer Protocol (SMTP)
SMTP also allows the use of
Relays allowing other MTAs to
relay the mail
Mail Gateways are used to
relay mail prepared by a
protocol other than SMTP and
convert it to SMTP
Mail Server
Format of an email
Mail is a text file
Envelope
sender address
receiver address
other information
Message
Mail Header defines the
sender, the receiver, the
subject of the message,
and other information
Mail Body Contains the
actual information in the
message
Mail Server
Format of an email
Mail Server
Connection Establishment
Mail Server
Message Progress
Mail Server
Connection Termination
TCP Connection Termination
Mail Server
Limitations in SMTP
Only uses NVT 7 bit ASCII format
How to represent other data types?
No authentication mechanisms
Messages are sent un-encrypted
Susceptible to misuse (Spamming,
faking sender address)
Mail Server
Solution: SMTP extensions
MIME Multipurpose Internet Mail Extensions
Transforms non-ASCII data to NVT (Network Virtual Terminal) ASCII
data
Electronic mail has a simple structure. Its
Text
simplicity, however, comes with a price. It
Application can send messages only in NVT 7-bit ASCII
Image format. In other words, it has some
Audio limitations. Multipurpose Internet Mail
Video Extensions (MIME) is a supplementary
protocol that allows non-ASCII data to be
sent through e-mail. MIME transforms non-
ASCII data at the sender site to NVT ASCII
data and delivers it to the client MTA to be
sent through the Internet. The message at
the receiving site is transformed back to
the original data.
Mail Server
First scenario
When the sender and the
receiver of an e-mail are on
the same mail server,
we need only two user agents
Second scenario
When the sender and the
receiver of an e-mail are on
different mail servers,
we need two UAs and a pair of
MTAs (client and server).
Mail Server
Third scenario
When the sender is
connected to the mail server
via a LAN or a WAN, we need
two UAs and two pairs of
MTAs
(client and server).
Fourth scenario When both sender and
receiver are connected to
the mail server via a LAN or
a WAN, we need two UAs,
two pairs of MTAs (client and
server), and a pair of MAAs
(client and server). This is
the most common situation
today
Mail Server
Push versus pull
USER AGENT : The first component of an electronic
mail system is the user agent (UA). It provides
service to the user to make the process of sending
and receiving a message easier
Some examples of command-driven user agents
are mail, pine, and elm
Some examples of GUI-based user agents are
Eudora, Outlook,
And Netscape
MESSAGE TRANSFER AGENT : The actual mail E-mail address
transfer is done through message transfer
agents (MTAs). To send mail, a system must
have the client MTA, and to receive mail, a
system must have a server MTA. The formal
protocol that defines the MTA client and server
in the Internet is called Simple Mail Transfer
Protocol (SMTP). As we said before, two pairs
of MTA client-server programs are used in the
most common situation (fourth scenario).
Figure 23.8 shows the range of the SMTP
Mail Server
POP (Post Office Protocol)
POP is used to retrieve mail for a single user, typically the POP server has
access from database email messages created by an SMTP server.
POPv1 is launched on October 1984. It was published in RFC 918.
POPv3 is the recently standard
POP use port 110
How POP3 Works
The server host starts the POP3 service by listening on TCP port 110.
A client establishes a TCP connection with the server host.
When the connection is established the server sends a greeting.
The client and the server exchange commands and responses until the
connection is closed or aborted.
The server can respond with a positive status sending "+OK" to the client
or with a negative status sending "-ERR" to the client (both in uppercase).
Mail Server
Authorization state
In this state, the client sends identification to the server. This is
implemented in two ways (More information on authentication is described
in RFC 1734):
- Using USER and PASS commands
- Using APOP command
Transaction state
In this state, the client can issue commands for listing, retrieving, and
deleting. Please note that the deleting action is not taken in this state. The
client must send the QUIT command and then the server goes to the
update state.
Update state
In this state, the server updates the mailbox according to the commands
received from the client in the transaction state and the TCP connection
ends. If the connection is broken for any reason before the quit command is
received from the client, the server does not enter the update state.Thus,
the server will not update anything.
Mail Server
Difference between POP3 and IMAP (Internet Mail Access Protocol )
POP3 works by reviewing the inbox on the mail server, and downloading the
new messages to your computer. IMAP downloads the headers of the new
messages on the server, then retrieves the message you want to read when
you click on it.
When using POP3, your mail is stored on your PC. When using IMAP, the mail
is stored on the mail server. Unless you copy a message to a "Local Folder"
the messages are never copied to your PC.
Mail Server
SMTP range
Mail Server
Pop3 and IMAP4
Mail Server
WEB-BASED MAIL
E-mail is such a common application that some websites today provide this service
to anyone who accesses the site. Three common sites are Hotmail, Yahoo, and
Google. The idea is very simple. Let us go through two cases:
Web-based e-mail, case 1
Web-based e-mail, case 2