0% found this document useful (0 votes)
33 views28 pages

Lec 2 - Application Layer - III - DHCP FTP

This document discusses DHCP and FTP protocols. DHCP is a client-server protocol that automatically provides IP addresses and other network configuration information to hosts on a network. It uses UDP and requires a DHCP server. FTP is used to transfer files between a client and server, using separate TCP connections for control information on port 21 and data transfer on port 20.

Uploaded by

Junaid Kaleem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views28 pages

Lec 2 - Application Layer - III - DHCP FTP

This document discusses DHCP and FTP protocols. DHCP is a client-server protocol that automatically provides IP addresses and other network configuration information to hosts on a network. It uses UDP and requires a DHCP server. FTP is used to transfer files between a client and server, using separate TCP connections for control information on port 21 and data transfer on port 20.

Uploaded by

Junaid Kaleem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

Computer and

Communication Networks
EE-357 -TE-54
By Dr Mir Yasir Umair
Assistant Professor, MCS, NUST
Application Layer
Lecture 02
DHCP & FTP

Application Layer
DHCP (Dynamic Host Configuration Protocol)
How computer gets IP address?
Manual IP address Allocation
192.168.1.2 192.168.1.2

If two hosts on the same network are accidently assigned same IP addresses,
there will IP conflict error.
DHCP to the rescue
Dynamic Host Configuration Protocol (DHCP) is a client/server protocol.
• It automatically provides IP address and other related configuration information such as
the subnet mask, default gateway, DNS Server Information etc to the host as it connects to
the network

Subnet Mask
o Indicates part of the IP address that forms the network range
• IP address: 192.168. 1. 1
• Subnet Mask: 255. 255. 255. 0
• LAN Range: 192. 168. 1. xxx
Default Gateway
o IP address of the router
DNS Server
o Server Responsible for translating names to IP addresses and vice versa
Lease Time
6
Ipconfig /all
DHCP Requirements
• Need atleast one DHCP server on the network.
o DHCP server is located in the router to facilitate
addressing of connected devices.

• Every host needs to run DHCP client

8
DHCP
DHCP uses UDP port 67 for server, port 68 for client

Note: Don’t use DHCP for devices such as servers, printers, routers,
switches, etc. These should be assigned static IP.
How DHCP Works? – DORA
Process
Step 1: DHCP DHCP discover
IP scope
Discover
MAC address
New host broadcasts
DHCP request to
everyone on network to
discover the DHCP DHCP DHCP DHCP
server CLIENT SERVER
DATABASE

Source:
0.0.0.0, 68 MAC address, IP#,
lease time
Receiver
255.255.255.255, 67
Broadcast to everyone
• Scope - a range of IP addresses
• IP lease - the IP# is assigned temporarily
• Reserved IP - servers are assigned fixed IP addresses
How DHCP Works? – DORA
Process
Step 2: DHCP Offer
IP scope
DHCP discover
DHCP server MAC address
broadcasts offer
message to everyone on DHCP offer
network since it doesn't IP#, lease time
know where new host
is DHCP DHCP DHCP
CLIENT SERVER
DATABASE
IP sender 192.168.1.1,
67
MAC address, IP#,
IP receiver lease time
255.255.255.255, 68
Broadcast to everyone
• Scope - a range of IP addresses
• IP lease - the IP# is assigned temporarily
• Reserved IP - servers are assigned fixed IP addresses
How DHCP Works? – DORA
Process
Step 3: DHCP Request IP scope
DHCP discover
MAC address
Host has received
atleast one IP address,
so it tells others which DHCP offer
IP address it picked. IP#, lease time
DHCP DHCP DHCP
Source: CLIENT SERVER
DHCP request DATABASE
0.0.0.0, 68
IP#, MAC address
Receiver MAC address, IP#,
255.255.255.255, 67 lease time
Broadcast to everyone

• Scope - a range of IP addresses


• IP lease - the IP# is assigned temporarily
• Reserved IP - servers are assigned fixed IP addresses
How DHCP Works? – DORA
Process
IP scope
Step 4: DHCP ACK DHCP discover
MAC address
DHCP server confirms
the host that it can start DHCP offer
using the address. IP#, lease time

Source: DHCP DHCP DHCP


CLIENT SERVER
IP sender 192.168.1.1, DHCP request DATABASE
67
IP#, MAC address
IP receiver MAC address, IP#,
255.255.255.255, 68 DHCP ack lease time
Broadcast to everyone IP#, lease time

• Scope - a range of IP addresses


• IP lease - the IP# is assigned temporarily
• Reserved IP - servers are assigned fixed IP addresses
Other DHCP Messages
• DHCPNAK — from server
o “no, you may not have that address; go to the INIT state”
• DHCPDECLINE — from client
o Client has detected another machine is using the offered address
• DHCPINFORM — from client
o Client already has a fixed IP address, but wants other network settings from the
server
• DHCPRELEASE — from client
o Server expires the lease immediately
Cases
What if the host logs off or the power is lost,
• Its IP address is returned to the pool to be re-assigned to another host when needed.

If there are Multiple DHCP servers on a network


• Each server can respond with an address offer.
• Host will choose one offer and assigned IP accordingly.

If simultaneous DHCP Requests from different hosts arrives the server


• DHCP uses Transaction IDs to keep track of ongoing procedures and to distinguish them
from one another
Lease - Recycle unused IPs so others can use again

• A lease is the length of time for which a DHCP client can use a
dynamically assigned IP address configuration. Before lease time expires,
the client must either renew the lease or obtain a new lease from DHCP.

• In practice, leases may very from 30 minutes to a week or so


FTP – File Transfer Protocol

Application Layer
FTP: the file transfer protocol
❖ Protocol used to transfer file to/from remote host
❖ Before the advent of the World Wide Web, FTP was mainly used
for file transfers.
❖ FTP is still often used, for instance, in cases where companies
need to exchange code updates, configurations, etc.
❖ Need not to deploy HTTP servers or use browsers.
❖ client/server model – Both needs to be up at the time of transfer
▪ client: side that initiates transfer (either to/from remote)
▪ server: remote host

FTP FTP
file transfer server
Client
user
at host remote file
system
FTP: the file transfer protocol
file transfer
FTP FTP FTP
user client server
interface
user
at host remote file
local file system
system

❖ transfer file to/from remote host


❖ client/server model
▪ client: side that initiates transfer (either to/from remote)
▪ server: remote host
❖ ftp: RFC 959
❖ ftp server: port 21

Application Layer
FTP: separate control, data
connections
• FTP uses two parallel TCP connections to transfer a file, a control
connection and a data connection.
o Control connection: (port 21)
• Used for sending control information such as user name,
password, FTP commands etc.
o Data connection (port 20)
• Used to upload or download a file.
• FTP is said to send its control information out-of-band

TCP control connection,


server port 21

TCP data connection,


FTP client server port 20 FTP server
FTP Operation
• User provides hostname of remote host and his username and
password causing the FTP client in localhost to establish a TCP
connection with the FTP server process in remote host on port 21.
• Once the server authorizes the user, a non-persistent TCP data
connection is initiated with the client.
• The user copies the required file stored on the remote file system (or
vice versa) and server then closes the data connection.
• Server opens another TCP data connection to transfer another file
(Control connections remains open throughout the duration of user
session)
Login

FTP Upload/
Retrieval/ Update

FTP Server
FTP Commands and Replies
▪ USER username: Used to send the user identification to the server.
▪ PASS password: Used to send the user password to the server.
▪ LIST: Used to ask the server to send back a list of all the files in the current
remote directory.
▪ RETR filename: Used to retrieve a file from the current directory of the
remote host.
▪ STOR filename: Used to store (that is, put) a file into the current directory of
the remote host.
The replies are three-digit numbers, with an optional message following the
number:
• 331 Username OK, password required
• 125 Data connection already open; transfer starting
• 425 Can’t open data connection
• 452 Error writing file
Browser based FTP
Dedicated FTP Client/ Server Apps
• FTP programs let you download or upload multiple files at once
Anonymous FTP
Most FTP sites allow anonymous
login.
o User does not need a personal
account (sometimes only e-
address is required)
o Usually for downloading only
o Not truly anonymous: your
internet address is known
HTTP vs FTP
Similarity: Both protocols run on top of TCP, commands are in ASCII
(human readable format) etc.
Comparators HTTP FTP
Control/ Data HTTP sends control Two parallel connections –
Connections info in-band control information out-of-band

User’s State Stateless Protocol Stateful - Maintains state about


the user by associating control
connection with specific user
account

Management Preferably for Large file downloads – can also


small file transfer set user privileges (read, write,
delete, modify etc)
FTP commands, responses
sample commands: sample return codes
• sent as ASCII text over • status code and phrase
control channel (as in HTTP)
• USER username • 331 Username OK,
• PASS password password required
• LIST return list of file in • 125 data connection
current directory already open;
• RETR filename transfer starting
retrieves (gets) file • 425 Can’t open
• STOR filename stores data connection
(puts) file onto remote • 452 Error writing
host file

Application Layer
Assignment
• At Wireshark – You need to observe DORA process and take screenshots

• List some names of the FTP servers – and sign up if possible – Screen shots of their
directories would be a plus

Application Layer

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy