Lec 2 - Application Layer - III - DHCP FTP
Lec 2 - Application Layer - III - DHCP FTP
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.
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
• 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.
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
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
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
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