You are on page 1of 58

Computer Science and Engineering

TY BTech Trimester-VII

Disclaimer:
a. Information included in these slides came from multiple sources. We have tried our best to cite the
sources. Please refer to the references to learn about the sources, when applicable.
b. The slides should be used only for preparing notes, academic purposes (e.g. in teaching a class), and
should not be used for commercial purposes.
TCP/IP Applications
• TCP/IP applications run directly on TCP or UDP layer.

BOOTP
DNS FTP SMTP Telnet HTTP TFTP SNMP DNS
Application DHCP
layer

53(s) 20 (s), 25 (s) 23 (s) 88 (c) 67 (s), 69 161(s),162 53(s)


21(s) 68 (c) (c)
TCP UDP

IP and lower layers

c : client, s : server

• These applications usually are part of a larger application, e.g. SMTP is used for email
application.
• Some applications e.g. DNS requires both UDP and TCP protocols.
• Client-server model is used by these applications.
– Server use ‘well known’ (in other words specified) TCP / UDP ports.
– Clients can select any port >1023 if the port is not specified.
2
Dynamic Host Configuration Protocol (DHCP)
• BOOTP requires manual mapping of MAC address and IP address in the server.
– It is not suitable when client machine move from one network to another because server allots IP
address based on the hardware address of the client.
– It is a static configuration protocol.
• DHCP was designed to handle situations where clients are mobile. IP address is allotted from an
IP pool. DHCP replaces BOOTP.
• DHCP provides static or dynamic address allocation that can be manual or automatic.
• DHCP uses the same UDP ports as BOOTP (Server 67, Client 68).

3
Dynamic Host Configuration Protocol (DHCP)
• DHCP has three modes assignment of IP addresses:
– Automatic IP address assignment is permanent.
– Dynamic IP address (unused) assignment is for limited period (lease) of time.
– Manual IP address is manually configured as in BOOTP.
• DHCP allows configuration of several other parameters and thus eliminates several TCP/IP
configuration tasks.
– DNS server
– Subnet mask
– Default TTL value
– MTU
– Source routing option
– Maximum fragment size
– Others

4
DHCP Message Format
OP : Operation code (Request=1. Response=2)
HTYPE : Hardware (network) type (Ethernet = 1).

octets HLEN : Hardware address length (MAC address = 6)


1 1 1 1 Hops : Set to 0 by Client. Intermediate relay
OP HTYPE HLEN Hops agent increments it by 1
Transaction Id Transc. Id: Random number to match requests and
Seconds Reserved responses
Client IP address
Your IP address
Seconds : Elapsed time since client started booting
Server IP address Client IP : Client’s IP address, if client does not have it
Router IP address then (0.0.0.0) .
Client hardware address (16 Your IP : Filled by DHCP server at request of client.
octets)
Server host name (64 octets) Server IP : Server address where boot file is stored
Router IP : IP address of router.
Boot-file name (128 octets)
Client HW: MAC address of client
Options area (64 octets)
Server host name : Domain Name of server where boot
file is stored
Boot filename : Null-terminated string consisting of full
pathname of the boot file.
5
Dynamic Host Configuration Protocol (DHCP)
• Message format : Same as BOOTP except
– Options area is at least 312 octets. DHCP messages are appended here.
– The reserved field is called flag field. The first bit is set to 1, if the client wants responses in broadcast
mode.
• Message types
– DHCPDISCOVER(1) Broadcast from a client to find DHCP server.
– DHCPOFFER(2) Response from DHCP server offering IP
address and other parameters.
– DHCPREQUEST(3) Message from client indicating selection of parameters values accepted.
DHCPREQUEST is also used to extend lease.
– DHCPDECLINE(4) Message from client indicating some error.
– DHCPACK(5) Acknowledgement from server.
– DHCPNACK(6) Message from server refusing request from client.
– DHCPRELEASE(7) Message from client releasing IP address.
– DHCPINFORM(8) Message from client for additional configuration parameters.

6
Dynamic Host Configuration Protocol (DHCP)
• Basic operation
Client Server
IP lease request (DHCPDISCOVER)

IP lease offer (DHCPOFFER)

IP lease selection (DHCPREQUEST)

IP lease acknowledgement (DHCPACK)

• DHCP server and client can be different networks. Relay agent (a router can act as relay agent)
forwards DHCP messages to the DHCP server.

7
Dynamic Host Configuration Protocol (DHCP)
Client DA IP 255.255.255.255, MAC FF.FF.FF.FF.FF.FF Server
SA IP 0.0.0.0, MAC 09.01.20.34.56.12 (Discover)

DA IP 255.255.255.255, MAC 09.01.20.34.56.12


SA IP 10.1.10.8, MAC 09.01.20.34.67.31 (Offer)

DA IP 255.255.255.255, MAC FF.FF.FF.FF.FF


SA IP 0.0.0.0, MAC 09.01.20.34.56.12 (Request)

DA IP 10.1.10.100, MAC 09.01.20.34.56.12


SA IP 10.1.10.8, MAC 09.01.20.34.67.31 (Ack)

• There can be several DHCP servers.


– The client sends Discover in broadcast mode.
– DHCP servers send their offers to HW address with DA IP as broadcast.
– Client selects one and informs all DHCP serves about the selection (Broadcast mode).
– Selected server sends acknowledgment to HW address with DA IP as broadcast .

8
Dynamic Host Configuration Protocol (DHCP)
• There is procedure for renewal of lease. Client may want to continue with same IP address.

– DHCP REQUEST message is used by the client after (0.5 leased period) to renew the lease. The
request is sent specific DHCP server that gave the lease.
– The server can renew lease or negate request by sending DHCPNACK.

9
Domain Name System (DNS)
 Small Internet mapping was done with Host file –
Two columns as name and address.
store host file on its disk.
update it periodically from a master host file.
Impossible to have one single host file.
Solution to this -
 Store it on a single computer and allow access to all others.
 It creates a huge traffic on Internet.
 Divide huge amount of information into smaller parts.
 Store each part on a different computer.
 Host that needs mapping contacts closest computer.
 This is used in DNS.

10
Domain Name System (DNS)
 Flat name Space :
A name is to assigned to an address.
A name is a sequence of characters without structure.
It can not be used in large system as Internet.
 Hierarchical Name Space :
• Each name is made up of several parts.
• Names are defined in an inverted-tree structure with the root at the top.
• The tree can have only 128 levels : level 0 (root) to level 127.
• Each node in the tree has a label, string with a max 63 characters.
• The root label is a null string (empty).
• Children of a node has different labels hence uniqueness.
• Full Domain name is a sequence of labels separated by dots.
• Always read from the node up to the root.
• Name must end with a null label.

11
Domain Name System (DNS)
• IP addresses are not very user friendly.
– Users are more comfortable with names than with digits.
– DNS allows users to specify names instead of IP address.
• IP address space consists of 232  4.29 Billion addresses. Flat directory would be very large.
Therefore hierarchical naming system is used.
• Hierarchical naming
– Software lab is given name LAB.SW.CS.UNIV, which is unique and readily understood.
– Hierarchical naming scheme is scalable.

UNIV

CS.UNIV CS TEL ADM

SW.CS.UNIV SW HW

LAB.SW.CS.UNIV LAB LAB

12
Domain Name System (DNS)
• Internet naming system is called Domain Name System (DNS). It maps IP addresses to names
and vice versa.
– DNS is implemented as distributed database on DNS ‘name servers’.
– Client process communicates with the name server to get an IP address.
• Terminology
– Domain : Complete sub-tree under a particular point in tree structure.
– Label : It identifies a local entity e.g. LAB.
– Domain name : It is name given to a node in the naming tree e.g. abc.xyz.org. (concatenation of labels
up to the root, FQDN)).

(.) root Label


---

org org domain

Domain name xyz


xyz.org domain
abc.xyz.org.

abc

13
Domain Name System (DNS)
• Domain name
– It is not case sensitive.
– It can be maximum 255 characters long.
– It can have characters a to z, numerals 1 to 9 and symbol -.
– Hosts with multiple IP addresses can be a assigned a single name.
– Hosts with single IP address can be assigned multiple domain name (for example to differentiate
various services it offers).

root
(.) Label
---

org org domain

Domain name xyz


xyz.org domain
abc.xyz.org.

abc

14
Domain Name System (DNS)
• Internet DNS tree
Root

Top level

edu com gov mil org net int fr in

2nd level edu Education


mit com Commercial
gov US govt.
3rd level
mil US military
cs
org Organizations other than above
net Network providers
lab pcg pcg.cs.mit.edu. int International organizations
lab.cs.mit.edu. fr, in Country specific (France, India)

• Domain names are registered with InterNIC(USA), RIPE (Europe), APNIC (Asia)

15
Domain Name System (DNS)
• Zone: Naming hierarchy is implemented as zones.
– A zone is a sub-tree, whose naming information is implemented in two or more name servers.
• Name servers map names to resource record.
– IP address is the most common resource record. There can be other kinds.

edu com gov

mit
Zone

cs civ

lab pcg

16
Domain Name System (DNS)

User

1
Host
name
Host
name
2

5
IP address
6 3 Query
IP address
Response 4
Transport layer

17
DNS in the Internet
 Three different sections :
 Generic Domains : defines generic hosts
Root

Top level

edu com gov mil org net int aero biz

2nd level edu Educational institutions


mit com Commercial org
gov govt. institutions
3rd level
mil military
cs
org Nonprofit Organizations
net Network support centers
lab pcg pcg.cs.mit.edu. int International organizations
lab.cs.mit.edu.

18
DNS in the Internet
 Country Domains : uses two-char country abbreviations( as US) at the first level.
Second level label can be organizational or national designations. Ex. State abbreviations (ca.us.).
Ex. mit.pu.ms.in
 Inverse Domain : used to map an address to name.
Server receives a request from the client to do a task.
Check whether client is on the authorized list.
Server sends a query ( PTR query) to inverse DNS & ask for mapping of address to a name.
In Inverse Domain first level node is arpa.
Second level node is in-addr ( inverse address) .
Rest of the domain defines IP addresses.
Ex. A class B address 132.34.45.121 is read as 121.45.34.132.in-addr.arpa.

19
Resource Record (DNS)
• A resource record is five-tuple :
Domain-name Time-to-live Class Type Value

Domain-name : Name to which this record is applicable.


Time-to-live : Life of the record.
Class : For Internet the class is IN.
Type, Value : A Value is IP address
MX Value is name of mail server
NS Value is name of the name server
CNAME Value is canonical name for an alias name
HINFO Value is OS/machine
PTR It is used for reverse look up (IP to name)

20
Query Methods
• There are two approaches
– Recursive
– Iterative
• Recursive
IP address of www.abc.xyz.org? IP address of www.abc.xyz.org?
Local Default Root
host IP address of www.abc.xyz.org NS IP address of www.abc.xyz.org NS

IP address of www.abc.xyz.org?
xyz.org org NS
NS IP address of www.abc.xyz.org

NS : Name server

21
Query Methods
• Iterative
IP address of www.abc.xyz.org?
IP address of www.abc.xyz.org?
root NS
List of org NS
Local Default IP address of www.abc.xyz.org?
host NS org NS
List of xyz.org NS
IP address of www.abc.xyz.org?
xyz.org NS
IP address of www.abc.xyz.org IP address of www.abc.xyz.org

• Caching
– When a name query is resolved with the help of NS of another domain, the resource record is stored in
cache memory for future use.
– Caching speeds up name resolution.
– Teach server keep TTL counter – for which the receiving server can cache information.
– This record has limited life time as it is not authoritative.
– Cache memory must be searched periodically, and for TTL = 0 mappings must be purged.

22
DNS Message Formats
• Message types
– Query
– Response
• Format : DNS message has five sections.
Header : Identifiers, Type of message (query, response),
Header number of queries and responses, Other
Question
Question : Queries
Answer
Answer : Resource records that answer queries
Authority
Authority : List of name servers that serve a domain
Additional
Additional : Other information

– Query consists of Header and Question sections.


– Response consists of all the five sections.

23
File Transfer Protocol (FTP)
• File system is OS specific. File organization, coding style, data type etc. may be different in
different systems.
• To exchange files between two systems requires a common protocol acceptable to the two
systems.
• There are two alternatives
– Virtual files
– It defines a virtual file structure for file transfer.
– A file is translated to a virtual file at the sending end, and virtual file is translated to local file at the other end.
– This approach is complex. FTAM (File Transfer, Access, and Management) protocol is based on this approach).
– Reduction approach
– Various file systems are reduced to a common minimal set of properties.
– Views and file operations limited by the common set of properties are possible.
– File Transfer Protocol (FTP) is based on this approach.
– FTP facilitates remote listing of directories, create new files, obtain copy of files, delete file, etc.

24
File Transfer Protocol (FTP)- Features
• Data representation : ASCII (7-bit), EBCDIC (8-bit), Image files or binary data (8-bit).
• File organization
– Structured files : Set of records, each delimited by EOR.
– Unstructured : String of bytes, end marked by EOF.
– EOR and EOF are represented as
EOR 0xFF+0x01
EOF 0xFF+0x02
EOR+EOF 0xFF+0x03
– Byte stuffing is used when 0xFF appears in source data.
– Page structure
• Transfer modes
– Stream mode File is transmitted as continuous stream without any modification. EOR/EOF are inserted
where applicable.
– Block mode File is transmitted as blocks of data. EOR at the end of each block and EOF at the end of file
are inserted.
– Compressed Sequence of same characters is represented as one character with replication count.
• Only a copy of a file is transferred. Original remains intact.
• Access control Login name and password are implemented.

25
FTP Operation
• FTP is based on TCP.
– Two TCP connections are maintained
– Control For commands, responses and authentication
– Data For transfer of file.
– Control connection is used by process Protocol Interpreter (PI).
– PI uses well known FTP server port 21 and syntax for communication.
– PI is responsible for conversion of local syntax to NVT and vice versa.
– Data connection is used by Data Transfer Process (DTP). DTP uses well known FTP server port 20.

Host Host
A FTP client FTP server B

DTP PI DTP PI
TCP Control
ports TCP 20 TCP 21
>1023 Data
IP and IP and
lower layers lower layers

26
File Transfer Protocol (FTP)
• The control connection is established by PI client.
– Client PI sends commands. Server PI responds.
– Some common commands are
– Authentication : USER (user name), PASS (password),
– Directory : LIST, CWD (Change), MKD (Make), RMD (Remove)
– Files : RETR (retrieve), STOR (store), DELE (delete),
– Mode : PASV (passive)
– Some sever responses are
– 150 (opening data transfer connection), 200 (Command OK), 331 (Username OK), 230 (User logged in), 226
(Closing data transfer connection)

Host Host
A FTP client FTP server B

DTP PI DTP PI
TCP Control
ports TCP 20 TCP 21
>1023 Data
IP and IP and
lower layers lower layers

27
File Transfer Protocol (FTP)
• If the command results in file transfer,
– Client DTP and Server DTP processes are started.
– TCP connection is established between them. There are two modes
– Passive mode
– Active mode
– File transfer takes place on the connection.
– Server closes the data transfer connection after the transfer is complete.
• The PI connection may continue for additional file transfers.
Host Host
A FTP client FTP server B

DTP PI DTP PI
TCP Control
ports TCP 20 TCP 21
>1023 Data
IP and IP and
lower layers lower layers

28
File Transfer Protocol (FTP)
• Data transfer modes
– Active mode (Default mode)
– Client PI specifies a port number for data transfer connection to the server on the control connection.
– Server DTP establishes data connection from its port 20 to the client port.
– Passive mode (Firewall friendly)
– Client PI requests passive mode.
– Server PI indicates a port (>1023).
– Client sets up data transfer connection to the specified server port.

Host Host
A FTP client FTP server B

DTP PI DTP PI
TCP Control
ports TCP 20 TCP 21
>1023 Data
IP and IP and
lower layers lower layers

29
File Transfer Protocol (FTP)
• Active mode: Firewall may restrict inbound connections. Thus active mode may face firewall
restrictions.
Outbound
control Outbound control connection :
Client connection Server Client : port x
Server : OK
Inbound data
Server establishes data transfer
Firewall transfer
connection from its port 20 to x
connection

• Passive mode: Data transfer connection is established by the client and thus is outbound
connection, which will not have firewall restrictions. Passive mode is firewall friendly.

Outbound
control Outbound control connection :
Client connection Server Client : Pasv
Server : y
Outbound
Client establishes data transfer
Firewall data transfer
connection from its port x to y
connection
30
FTP Commands

31
FTP Commands
 Access commands :
• USER : User information
• Pass : User password
• ACCT : Account information
• REIN : Reinitialize
• QUIT : Log out of the system
• ABOR : Abort the previous command
 File management commands
• CWD : Change to another directory
• CDUP : change to parent directory
• DELE : Delete a file
• LIST : List subdirectories
• NLIST : List names of subdirectories
• MKD : Create a new directory
• PWD : Display a new directory
• RMD : Remove directory
• RNFR : Identify a file to be rename
• RNTO : Rename the file
• SMNT Mount a file system
32
FTP Commands
 Data formatting commands:
• TYPE : A (ASCII) E (EBCDIC) I (Image) N (Nonprint) or T (Telnet)
• STRU : F (File) R (Record) P ( Page)
• MODE : S (Stream ) B (Block) C (Compressed)
 Port defining commands :
• PORT : (6-digit identifier) Client chooses a port
• PASV : Server chooses a port
 File transfer commands :
• RETR : Retrieves files, files are transferred from server to the client.
• STOR : Store files, files are transferred from client to the server.
• APPE : Similar to STOR except if file exists data must be appended to it.
• STOU : Same as STOR except that the file name will be unique in the directory, the existing file
should not be overwritten.
• ALLO : Allocate storage space for the files at the server
• REST : Position the file marker at a specified data point.
• STAT : Return the status of files

33
FTP Commands
 First digit: Denotes reply is good, bad or incomplete
• 1yz (Positive Preliminary reply)
• 2yz (Positive Completion reply
• 3yz (Positive Intermediate reply)
• 4yz (Transient Negative Completion reply)
 Second digit: Status of command
• x0z (syntax)
• x1z (information)
• x2z (connection)
• x3z (authentication and accounting)
• x4z (unspecified)
• x5z (file system).
 Third Digit : Additional information

34
Electronic Mail
• Basic components
– Mail user agent (MUA)
– It allows the users to compose, read, forward, save email.
– It fetches mails from the mail box using POP3 or IMAP4 protocol.
– It appends the outgoing mails to spool file (mail queue) using SMTP.
– Spool file
– It contains mails to be sent. MUA appends mails to it for transmission and MTA extracts mails from it for
delivery.

Mail server Mail server

MTA MTA
Exchange mails
Collect Deliver using SMTP
new new
mails mails

Mailbox Spool file

Fetch received mails Send mails to spool-file


(POP3, IMAP 4) using SMTP
MUA

35
Electronic Mail
– Mail box
– This file is owned by the user. The delivered mails are appended to this file.
– The authorized users can read and delete mails from the mail box.
– Mail transfer agent (MTA)
– It extracts mails from the spool file.
– It appends the mails to the mail box if the recipient are connected to the same server.
– It delivers mails to peer MTA if destination mail box is in another server. Simple mail transfer protocol is used
for this purpose.

Mail server Mail server

MTA MTA
Exchange mails
Collect Deliver using SMTP
new new
mails mails

Mailbox Spool file

Fetch received mails Send mails to spool-file


(POP3, IMAP 4) using SMTP
MUA

36
Electronic Mail
• Mail address
– It consists of character string in the format user@domain.
– User part identifies the mail box in the domain as indicated by domain part.
– User part is unique in the domain
– Domain part is unique globally. It identifies an organization, a host machine.
– Mail servers are announced with the help of DNS. DNS servers identify the mail servers that serve a
domain.
• Mail Format
– It consists of Header (Envelop) and body.
• Header
– It contains information about sender, receiver, subject, date, time etc.
– It consists of series of lines, each terminated by CR LF.
– Each line has type field followed by a colon and value. FROM: pcg@m…
• Body
– Header and body are separated by a blank line.
– Maximum size of body is limited to 1000 characters.

37
Simple Mail Transfer Protocol (SMTP)
• SMTP is based on TCP. Well known SMTP server port is 25. Client selects port >1023.
• All SMTP commands and messages are in 7-bit ASCII (Printable characters + LR CF).
• SMTP is used
– between two mail servers, and
– between a host and mail server for transfer of mail from the host to the server.

Mail server A Mail server B


SMTP SMTP
Spool file client server Mailbox
TCP port TCP port
TCP >1023 25 TCP
IP and IP and
lower lower
layers layers

38
Simple Mail Transfer Protocol (SMTP)
• SMTP client at A sees mail in the spool file. It invokes TCP connection to SMTP server B at port
25.
• After initial handshaking, it sends the mail to SMTP server at B, which places the mail in
recipient’s mail box.
C : Helo <…> C : DATA
S : 250 Service ready S : 354 Start mail input
C : MAIL FROM <…> C : <…>
S : 250 Service ready C : QUIT
C : RCPT TO <…> S : 251 Closing connection
S : 250 Service ready
Mail server A Mail server B
SMTP SMTP
Spool file client server Mailbox
TCP port TCP port
TCP >1023 25 TCP
IP and IP and
lower lower
layers layers

39
Simple Mail Transfer Protocol (SMTP)
• Commands from SMTP client
– HELO <Domain> Sending identification
– MAIL FROM: <…> Sender’s name
– RCPT TO: <…> Receiver’s name
– DATA Indicates beginning of mail transmission
– QUIT Close connection
– Other
• Responses from SMTP server
– 250 Service ready
– 251 Closing connection
– 354 Start mail input
– Other

40
POP3 and IMAP
• Recipient of a mail need to pull the mail from its mail server.
• POP3 (Post Office Protocol) and IMAP (Internet Mail access Protocol) are used for fetching mails
from mailbox to local machine.
– Local machine is the client. Mail server is also POP3 and IMAP server.
– POP3 works on TCP port 110.
– IMAP runs on TCP port 143.

Mail server Mail server

MTA MTA
Exchange mails
Collect Deliver using SMTP
new new
mails mails

Mailbox Spool file

Fetch received mails Send mails to spool-file


(POP3, IMAP 4) using SMTP
MUA

41
POP3 Phases
• It has three phases after TCP connection on port 110 is open.
– Authorization User sends username and password
– Transaction phase User retrieves message, marks message for
deletion
– Update After user quits, the server deletes the marked
messages
• POP3 supports ASCII characters.

Mail server Mail server

MTA MTA
Exchange mails
Collect Deliver using SMTP
new new
mails mails

Mailbox Spool file

Fetch received mails Send mails to spool-file


(POP3, IMAP 4) using SMTP
MUA

42
POP3 Commands
• USER [name]
• PASS [passwaord]
• LIST Lists the message numbers with their sizes
• RETR [msg number] Retrieves [msg]
• DELE [msg number] Marks message for deletion
• STAT Total number of messages and total size
• Other Quit, reset etc.
Mail server Mail server

MTA MTA
Exchange mails
Collect Deliver using SMTP
new new
mails mails

Mailbox Spool file

Fetch received mails Send mails to spool-file


(POP3, IMAP 4) using SMTP
MUA

43
IMAP4 (Internet Mail Access Protocol)
• IMAP is more sophisticated than POP3. It allows
– the user (client) to associate a mail to a folder. The client can create, delete and rename folders.
– A message on its arrival is associated to INBOX folder first. The user can then move it other folders.
– the client to fetch selectively message attributes e.g. all, body, envelope.
– searching the mail box for a given match criterion.
– maintaining several flags such as seen, answered, draft, deleted.

Mail server Mail server

MTA MTA
Exchange mails
Collect Deliver using SMTP
new new
mails mails

Mailbox Spool file

Fetch received mails Send mails to spool-file


(POP3, IMAP 4) using SMTP
MUA

44
MIME (Multipurpose Internet Mail Extension)
• SMTP allows only printable 7-bit ASCII characters (and CR and LF) to be sent.
– 8-bit codes that represent national language characters, executable files, binary objects cannot be transmitted.
• Servers may reject mail message > certain size.
• MIME is used to send non-ASCII characters (Pictures, audio, video, executable files).
• MIME transforms non-ASCII data to ASCII data and vice versa.
• MIME header is added to email header to define transformation parameters.
MIME ver (1.1)
Email header
Mime header Content type

Email body Content transfer encoding


Content id
Content description
• Content type e.g. <Image/JPEG>, <Video/MPEG>
• Content transfer encoding e.g. 7-bit, 8 bit, binary, base 64
• Content id : Identifies a message in multiple message environment.
• Content description : Textual description of content.

45
MIME (Multipurpose Internet Mail Extension)
• Content types/ subtypes
– Text Plain, rich text (formatted)
– Multipart Mixed (multiple types), parallel (multiple parts to be viewed simultaneously), alternative
(same data in different formats), digest
– Message RFC 822, partial (Fragmented), external body
– Image jpeg, gif
– Video mpeg
– Audio Basic
– Application Postscript, octet-stream

46
MIME (Multipurpose Internet Mail Extension)
• Content transfer encoding
– 7-bit US ASCII, maximal length of body 1000 characters.
– 8-bit encoding (with SMTP extension), maximal length of body 1000 characters.
– Binary encoding, body length can be > 1000 characters.
– Quoted printable encoding
– Useful when data is largely printable ASCII
– Other characters are represented as “=[Hexadecimal]”
» There are other rules as well.

– Base 64 encoding
– 3 eight-bit words are converted to 4-six bit words.
– Each six-bit word padded as 00xxxxxx (64 characters).
– 00xxxxxx mapped to ASCII characters.
– Thus 4 ASCII characters are user to represent 3 8-bit words.

47
Remote Login (Telnet)
• Remote login requires that the key strokes of terminal (or terminal emulator) are interpreted by
the system of remote host correctly.
• Telnet is a general purpose client-server program that allows access to an application running on
a remote host irrespective of is operating system.
• Telnet uses a canonical terminal representation, Network Virtual Terminal (NVT) between the
telnet client and telnet server.
– Local device characteristics are mapped to NVT and vice versa.

Local NVT NVT : Network virtual terminal


terminal transfer
syntax syntax

Network

Terminal Telnet Host with


client Telnet
server
48
Remote Login (Telnet)
• Telenet uses TCP and its well-known server port is 23. Client can have any port >1023.

Host Host
A B
Telnet Telnet
Control + data
client server
Terminal NVT NVT Terminal
driver driver
TCP port TCP port
TCP >1023 23 TCP
IP and IP and
lower lower
layers layers

49
Remote Login (Telnet)
• NVT uses 8-bit character set, which is same as 7-bit ASCII with additional bit at MSB position as
0 or 1.
• Telnet specifies additional commands for negotiating options and for signaling purposes. E.g.
DO, DON’T, WILL, WON’T …..
– These commands are 8-bit codes and identified by prefix character IAC (Interpret as command) with
code 255.
IAC Command code Option

– E.g. “IAC DO ECHO” is command to other end to echo back the received character.

Client IAC DO ECHO Server Client IAC WILL ECHO Server

Client IAC WILL ECHO Server Client IAC DON’T ECHO Server

50
Remote Login (Telnet)
• Options
– Transmit binary (Code 0): 8-bit binary instead of ASCII.
– Echo (Code 1): Echo back the received character.
– Terminal type (Code 24): Indicate some special terminal type.
– Output line width (Code 8)
– Output page size (Code 9)
– Etc.
• Some of the user commands are
– open <IP address> Sets up connection to remote host.
– close Closes the connection
– quit Quits the current Telnet session
– set<Variable><Value> Sets variable to specified value
– type <Terminal type> Sets a specific terminal emulation
– mode Toggle between ASCII and binary mode.

51
Hyper Text Transfer Protocol (HTTP)
• It is used for transporting WWW documents between client (web browser) and web server.
• It runs over TCP port 80 for server. Client selects any port > 1023.

Host A Host B
Web browser Web server
HTTP HTTP
client server
TCP port TCP port
TCP >1023 80 TCP
IP and IP and
lower lower
layers layers

52
Hyper Text Transfer Protocol (HTTP)
• Basic operation consists of three steps:
– Client opens a TCP connection and sends request with URL.
– Server responds.
– Server closes the connection.
– It is therefore stateless.
• Client’s request (Methods) can be of several types:
– GET : Request for getting information as identified by URL.
– POST : Request to put the attached entity as subordinate to the identified URL.
– PUT : Request to put the attached entity under the identified URL, replacing old
contents.
– DELETE : Request to delete the resource as identified by the URL.
– TRACE : Request to return the retrieved body of the Request. It is used as
application loop back for diagnostic purposes.
– COPY : It is request to copy the resource to the location specified.
– MOVE : It is request to move the resource to the location specified.
– HEAD : Same as GET except that only ‘header’ is returned.

53
Hyper Text Transfer Protocol (HTTP)
• HTTP Request message consists of
– Request line: Method (Command), URL, HTTP version.
– E.g. GET /xyz.html HTTP/1.1 …
– Other fields (Host, user agent, language, connection etc.).
• HTTP Response message consists of
– Status line : HTTP version, status code, status phrase
– E.g. HTTP/1.1 200 OK
– Other fields (Date, time, server, last-modified, content length, type etc.)
– Body (webpage, video, graphics, sound ….)
• Operation
– Client opens TCP connection to port 80.
– Client sends request.
– Server responds and closes connection.
– Client receives response and closes connection.
• Note that new TCP connection is required for each request.
– Non-persistent connection
– Limitations : Slow start, high overhead of connection buffers, time delay of two RTT for getting data.

54
Hyper Text Transfer Protocol (HTTP)
Web page request
HTTP GET /xyz.html HTTP/1.1 HTTP
client --- server
(Browser) ---
First TCP connection
Web page delivery
HTTP/1.1 200 OK
---
---

Contained object request


GET /abc/pqr HTTP/1.1
---
---
Second TCP connection
Object delivery
HTTP/1.1 200 OK
---
---

55
Hyper Text Transfer Protocol (HTTP)
• Persistent connections
– The server allows the TCP connection to continue. The client can send additional requests on this
connection.
– If the connection is not used by the client, server closes it after time out.
• Persistent connections types
– Without pipelining : Only one request at a time. Next request after the previous request is served.
– Time for service : one RTT per request
– With pipelining: There can be multiple requests one after the other.
– Time for service : One RTT for multiple requests.

2 RTT 2 RTT 2 RTT

RTT ~RTT
2 RTT
RTT

56
Hyper Text Transfer Protocol (HTTP)
• Cookies
– TCP connection is release by server immediately after sending response.
– Some applications require continuity of session e.g. ‘virtual shopping cart’.
– Cookie is special header (Set-cookie) sent by the server in its response.
– It contains session-Id, lifetime, path etc.
– The client’s browser keeps this in its cookie folder.
– The server also stores the cookie-id its database for future reference. It also takes note of pages visited.
– Cookie is returned by the client when making next request as cookie header line (Cookie xxxxx).
– This information enables the server to link this request to last service.
– The browser continues to put the cookie in future requests to the same site.
– The server thus gets the compete history of pages visited by the user.
– Cookies are often used to determine the user behaviour / tastes.
– The site may ask the user particulars (name, address, profession etc) and if these are provided, the cookie-id
gets associated with this information as well.

57
Hyper Text Transfer Protocol (HTTP)
• Static web documents
– So far we have discussed static web documents.
– Fixed content pages stored in the server.
– When requested by user, a copy of the fixed content is sent to the user.
• Dynamic documents
– The content is generated at the request of the user. Example
– User retrieves a blank form (static web page), fills it, and submits it.
– The server processes the received data, retrieves some relevant data from data base based on customer
supplied information, and generates a customized web page.

Browser Server CGI Database

– CGI (Common Gateway Interface): It interfaces to backend programs and scripts to accept input from forms
and generate HTML pages dynamically.
– Server returns the HTML page as response.

58

You might also like