CN Lab Manual
CN Lab Manual
LABORATORY MANUAL
2023-2024
COMPUTER NETWORK LABORATORY
TE-AI & DS ENGINEERING SEMESTER-I
Subject Code:317524
TEACHINGSCHEME EXAMINATIONSCHEME
-: Name of Faculty:-
Prof. Dumbre A.S.
Jaihind College of Engineering,Kuran.
Index
Group A
Sr.No Title Page No
1. Demonstrate the different types of topologies and types
of transmission media by using a packet tracer tool.
2. Setup a wired LAN using layer 2 switch.it includes
prepration of cable,testing of cable using line tester,
configuration machine using Ip addresses, testing using
PING utility and demonstrating the PING packets
captured traces using wireshark packet anyalyzer tool.
3. Setup a WAN which contains wired as well as wireless
LAN by using a packet tracer tool. Demonstrate transfer
of a packet from LAN 1 (Wired LAN) to LAN2 (wireless
LAN).
4. Write a Program to Demonstrate Sub-netting and Find
Subnet mask.
GROUP B
5. Write a program using TCP socket for wired network
for following a. Say Hello to Each Other b. File
Transfer.
6. Write a program using UDP sockets to enable file
transfer(script,Text,Audio and video one file each)
between two machines.
7. Study and Analyze the performance of HTTP, HTTP’S
and FTP protocol using packet tracer tool.
8. To study the SSL protocol by capturing the packets
using Wireshark tool while visiting any SSL secured
website (banking, e-commerce etc.)
9. Illustrate the steps for implementation of S/MIME
email security through Microsoft office outlook.
10. To study the IPSec (ESP and AH) protocol by
capturing the packets using wireshark tool.
GROUP C
11. Installing and Configuring DHCP server and assign
IP addresses to client machines using DHCP server.
12. Write a Program for DNS lookup. Given an IP
address input, it should return URL and vice versa.
GROUP A
Assignment No 1.(Group A)
Roll No
Date
Signature
Assignment No: 01
Problem Definition:
Demonstrate the different types of topologies and types of transmission media by using a packet
tracer tool.
1.1 Prerequisite:
a) IP Address
b) OSI & TCP/IP Model
c) Networking Devices
1.3 Outcome:Students could run the practical for all topologies in Packet tracer
1.5 Theory
1.6.1 Introduction
What is Topology?
Network topologies describe the methods in which all the elements of a network are
mapped. The topology term refers to both the physical and logical layout of a network.
Type of Network Topology
Point to Point
Bus Topology
Ring Topology
Star Topology
Mesh Topology
Tree Topology
Hybrid Topology
How to select a Network Topology?
Types of Networking Topologies
Two main types of network topologies in computer networks are
1) Physical topology 2) Logical topology
1) Physical topology:
This type of network is an actual layout of the computer cables and other
network devices 2) Logical topology:
Logical topology gives insight’s about network’s physical design.
Different types of Physical Topologies are:
P2P Topology
Bus Topology
Ring Topology
Star Topology
Tree Topology
Mesh Topology
Hybrid Topology
Point to Point
Point-to-point topology is the easiest of all the network topologies. In this the
method, network consists of a direct link between two computers.
P2P Topology
Diagram
Advantages:
This is faster and highly reliable than other types of connections since there is a direct connection.
No need for a network operating system
Does not need an expensive server as individual workstations are used to access the files
No need for any dedicated network technicians because each user sets their permissions
Disadvantages:
The biggest drawback is that it only be used for small areas where computers are in close
proximity.
You can’t back up files and folders centrally
There is no security besides the permissions. Users often do not require to log onto their
workstations.
Bus Topology
Bus topology uses a single cable which connects all the included nodes. The
main cable acts as a spine for the entire network. One of the computers in the
network acts as the computer server. When it has two endpoints, it is known as
a linear bus topology.
Advantages:
Here are pros/benefits of using a bus topology:
Cost of the cable is very less as compared to other topology, so it is widely used to build
small networks.
Famous for LAN network because they are inexpensive and easy to install.
It is widely used when a network installation is small, simple, or temporary.
It is one of the passive topologies. So computers on the bus only listen for data being sent,
that are not responsible for moving the data from one computer to others.
Disadvantages:
Here are the cons/drawbacks of bus topology:
In case if the common cable fails, then the entire system will crash down.
When network traffic is heavy, it develops collisions in the network.
Whenever network traffic is heavy, or nodes are too many, the performance time of the
network significantly decreases.
Cables are always of a limited length.
Ring Topology
0 1
Offers equal access to all the computers of the
networks Faster error checking and
acknowledgment.
Disadvantages:
Here are drawbacks/cons of ring topology:
Unidirectional traffic.
Break in a single ring can risk the breaking of the entire network
Modern days high-speed LANs made this topology less popular.
In the ring, topology signals are circulating at all times, which develops unwanted power
consumption.
It is very difficult to troubleshoot the ring network.
Adding or removing the computers can disturb the network activity.
Star Topology
Mesh Topology
The mesh topology has a unique network design in which each computer on the
network connects to every other. It is develops a P2P (point-to-point) connection
between all the devices of the network. It offers a high level of redundancy, so even if
one network cable fails, still data has an alternative path to reach its destination.
Mesh Topology:
In this topology, every nodes or device are directly connected with each other.
Mesh Topology
Advantages:
Here, are pros/benefits of Mesh topology
The network can be expanded without disrupting current
users. Need extra capable compared with other LAN
topologies.
No traffic problem as nodes has dedicated links.
Dedicated links help you to eliminate the traffic problem.
A mesh topology is robust.
It has multiple links, so if any single route is blocked, then other routes should be used for
data communication.
P2P links make the fault identification isolation process easy.
It helps you to avoid the chances of network failure by connecting all the systems to a
central node.
Every system has its privacy and security.
Disadvantages:
Installation is complex because every node is connected to every node.
It is expensive due to the use of more cables. No proper utilization of systems.
Complicated implementation.
It requires more space for dedicated links.
Because of the amount of cabling and the number of input-outputs, it is expensive to
implement.
It requires a large space to run the cables.
Tree Topology
Tree Topology
Tree topologies have a root node, and all other nodes are connected which form a hierarchy.
So it is also known as hierarchical topology. This topology integrates various star
topologies together in a single bus, so it is known as a Star Bus topology. Tree topology is a
very common network which is similar to a bus and star topology.
Advantages:
Here are pros/benefits of tree topology:
Failure of one node never affects the rest of the
network. Node expansion is fast and easy.
Detection of error is an easy process
It is easy to manage and maintain
Disadvantages:
Here are cons/drawback of tree topology:
It is heavily cabled topology
If more nodes are added, then its maintenance is difficult
If the hub or concentrator fails, attached nodes are also
disabled. Hybrid Topology
Hybrid Topology
Hybrid topology combines two or more topologies. You can see in the above architecture in
such a manner that the resulting network does not exhibit one of the standard topologies.
For example, as you can see in the above image that in an office in one department, Star
and
P2P topology is used. A hybrid topology is always produced when two different basic
network topologies are connected.
Advantages:
Here, are advantages/pros using Hybrid topology:
Offers the easiest method for error detecting and troubleshooting
Highly effective and flexible networking topology
It is scalable so you can increase your network size
Disadvantages:
The design of hybrid topology is complex
It is one of the costliest processes
How to select a Network Topology?
Here are some important considerations for selecting the best topology to create a network
in your organization:
Bus topology is surely least expensive to install a network.
If you want to use a shorter cable or you planning to expand the network is future, then star
topology is the best choice for you.
Fully mesh topology is theoretically an ideal choice as every device is connected to every
other device.
If you want to use twisted pair cable for networking, then you should build star topologies.
Assignment Questions:
1. What is Topology and why is it necessary ?
2. Explain with examples where different type of topologies are used ?
3. Which among all the topologies is the best topology used and why ?
Assignment No 2.(Group A)
Title Setup a wired LAN using layer 2 switch. It includes prepration of cables,
testing of cable using line tester, configuration machine using IP
addresses, testing using PING utility and demonstrating the PING
packets captured traces using wireshark packet anyalyzer tool.
Subject Computer Network
Roll No
Date
Signature
Assignment No: 02
Problem Definition:
Setup a wired LAN using Layer 2 Switch. It includes preparation of cable, testing of
cable using line tester, configuration machine using IP addresses, testing using
PING utility and demonstrating the PING packets captured traces using Wireshark
Packet Analyzer Tool.
1.1 Prerequisite:
a) IP Address
b) OSI & TCP/IP Model
c) Networking Devices
1.5.1 Introduction
Create files and store them in one computer, access those files from the other computer(s)
connected over the network.
Connect a printer, scanner, or a fax machine to one computer within the network and let
other computers of the network use the machines available over the network.
Network Cables
Network cables are used to connect computers. The most commonly used cable is CAT cable
& RJ-45.
Network Card
Network card is a necessary component of a computer without which a computer
cannot be
connected over a network. It is also known as the network adapter or Network
Interface Card
(NIC). Most branded computers have network card pre-installed. Network cards
are of two
types: Internal and External Network Cards.
A local area network (LAN) is a computer network that interconnects computers within
a limited area such as a residence, school, laboratory, university campus or office building and
has its network equipment and interconnects locally managed. By contrast, a wide area network
(WAN) not only covers a larger geographic distance, but also generally involves leased
telecommunication circuits or Internet links. An even greater contrast is the Internet, which is a
system of globally connected business and personal computers. Ethernet and Wi-Fi are the two
most common transmission technologies in use for local area networks.
Wireless LAN:
A wireless local area network (WLAN) is a wireless computer network that links two or more
devices using a wireless distribution method (often spread-spectrum orOFDM radio) within a
limited area such as a home, school, computer laboratory, or office building. This gives users
the ability to move around within a local coverage area and yet still be connected to the network.
A WLAN can also provide a connection to the wider Internet.
Most modern WLANs are based on IEEE 802.11 standards and are marketed under the Wi Fi
brand name.
People can access the network from where they want; they are no longer limited by the
length of the cable
Some places and vehicles have Wireless LANs. This means that people can access the
internet even outside their normal work environment, for example when they ride a train.
Setting up a wireless LAN can be done with one box called wireless access point or
wireless router. This box can handle many connections at the same time. Wired networks
require cables to be laid. This can be difficult for certain places.
Conclusion: Successfully doe the Setup of wired LAN using Layer 2 Switch. It
includes preparation of cable, testing of cable using line tester, configuration
machine using IP addresses, testing using PING utility and demonstrating the PING
packets captured traces using Wireshark Packet Analyzer Tool.
.5 Assignment Questions:
1. Explain LAN, PAN, MAN & WAN?
2. Write down the Difference between TCP/IP Model & OSI Model? 3.
Which Topology you have implemented in your laboratory? Why? 4.
Explain various IEEE Standards for Wireless LAN?
5. How to Configure Wireless LAN Explain step by Step?
6. Which Security protocols are used in Wireless LAN?
7. Explain Ping, Traceroute, Telnet, Ipconfig Commands?
Assignment No 3.(Group A)
Title Setup a Wired which contains wired as well as wireless LAN by using a
packet tracer tool. Demonstrate transfer of a packet from LAN1 (Wired
LAN) to LAN2 (Wireless LAN).
Roll No
Date
Signature
Assignment No: 03
Problem Definition:
Setup a WAN which contains wired as well as wireless LAN by using a packet tracer
tool. Demonstrate transfer of a packet from LAN 1 (wired LAN) to LAN2 (Wireless
LAN).
1.1 Prerequisite:
a) IP Address
b) OSI & TCP/IP Model
c) Networking Devices
1.3 Outcome:Students could run the practical for all topologies in Packet tracer
1.5 Theory
1.5.1 Introduction
A computer network simply means any set of computers and other devices like
smartphones, smart TVs, video game systems and routers that are able to
communicate back and forth
with each other. Different protocols, or rule systems, exist that let computers
understand
each other and transmit data.
A LAN, or local area network, is a small network, often within a home or business
or
perhaps within a larger environment like a corporate office park or acacm
olp
leugse.
Devices on a LAN often use the LAN's infrastructure to connect to the public
internet, but
Howthteoyscealenco
t fateNnectw
om
orm
ku np
To icoaltoegw
y?ith each other directly through thequ
LA
icN
klym. orer
Fo
instance, it's not usually necessary to send a file to the public internet in order to
A wide area network usually traverses multiple geographical areas. The gein t titerto
neat is the most
printer on the same LAN. A LAN can use wireless commucnoicnante
iocnti,owns odr
ire
both.
prominent example of the WAN network type, though other wide area
networks exist for scientific purposes, military and government work, and to
connect far-flung offices and data centers within some big corporations.
TOPOLOGY
WLAN Configuration
WLANs (Wireless LANs) are very common in today’s World. Everywhere there
are a lot of wireless networks. Even now, you are in many of these wireless
signals. It is not an healthty life but they are in our lives. In this lesson we will
focus WLAN Packet Tracer Configuration and we will learn How to Configure
a WLAN on Packet Tracer.
For Our WLAN Configuration on Packet Tracer, we will use the below
topology that is consist of one One Wireless Access Point, One Server , Three
Laptops and One Smartphone. Smartphones are everywhere, even in Cisco
Packet Tracer for many years:
Now, let’s sumamrize what will we do for Packet Tracer WLAN Configuration :
■ PlaceWirelessInterfaceCardtoLaptops
■ IPCheckonWLANDevices
■ DHCPServerConfiguration
■ IPCheckonWLANDevicesagain
We will check the IP addresses of the laptops. For now, checking only one of them is
enough. Because, in the beginning, if there is no Static IP Configuration and no DHCP,
an IP from a special block is assigned to the devices. These are APIPA (Automatic
Private IP Addressing) addresses. These addresses are from the block
“169.254.x.x/25”.
Simple, when we say this type of IP address in a device, we can say that it has no IP
address.
Conclusion: Successfully done the Setup for WAN which contains wired as well as wireless LAN
by using a packet tracer tool. Demonstrate transfer of a packet from LAN 1 (wired LAN) to
LAN2 (Wireless LAN).
Assignment Questions:
1. What is Topology and why is it necessary ?
2. Explain with examples where different type of topologies are
used ? 3. Which among all the topologies is the best topology used
and why ?
Assignment No 4.(Group A)
Roll No
Date
Signature
Assignment No: 04
Problem Definition:
PROBLEM STATEMENT:
6.1 Prerequisite:
1. IP Address Classes
2. Classless & Classful IP Addressing
6.2 LearningObjectives:
1. Understand the concept Subneting.
2. Understand the Concept of Supernet.
6.3 Theory
6.4.1 Introduction
Classes of Address
0 1
IP Address Classes
The 5 IP classes are split up based on the value in the 1st octet: Class A:
0-127
Class B: 128-191
Class C: 192-223
Class D: 224-239
0 1
Class E: 240-2552
Examples of IP Address
14.23.120.8 - The first byte of the address represents 14 which lies between 0 and 127, hence
Class A address.
134.11.78.56 - The first byte of address is 134 which lies between 128 and 191 hence the
address belongs to Class B.
193.14.56.22 - As first byte is 193 which is between 192 and 223, hence the address belongs
to Class C.
Subnet Mask
Frequently, the Network & Host portions of the address need to be separately extracted.
In most cases, if you know the address class, it’s easy to separate the 2 portions.
■ Specifies part of IP address used to identify a subnetwork.
■ Subnet mask when logically ANDed with IP address provides 32-bit network address
Default Mask:
Has predetermined number of 1s
Class A, B and C contains 1s in network ID fields for default subnet mask.
Computer Network laboratory (2015) Pattern TE Computer
Class A 11111111.00000000.00000000.00000000
Class B 11111111.11111111.00000000.00000000
Class C 11111111.11111111.11111111.00000000
IP Subnetting:
● Forexample,divisionofaClassBaddressintoseveralClassCaddresses
● SomeofthehostIDsareusedforcreatingsubnetIDs
Need for Subnetting:
● ItmaybedesirabletosubdividethehostsinClassCsubnets
■ Often, there is a limitation on the number of hosts that could be hosted on a single
network segment
Subnetting Principle:
● A hop is the distance a data packet travels form one node to the other .
■ Number of Subnets=(2n)
■ Although the 2 formulas look identical, the key is to remember the number you’re trying
to calculate, hosts or subnets.
■ Eg., suppose you are asked to determine the number of subnets available & the number of
hosts available on each subnet on the network 192.168.1.0
■ Using the subnet & hosts formulas, the answers are easily calculated. Of course, you must
know your powers of 2 to calculate the answers
Example:
■ Host IP Address: 138.101.114.250
Major Informations:
■ Host IP Address:
138.101.114.250 ■ Network Mask:
255.255.0.0
Determine the Network (or Subnet) where this Host address lives: 1.
2. Perform a bit-wise AND operation on the IP Address and the Subnet Mask
4. The result is the Subnet Address of this Subnet or “Wire” which is 138.101.114.192
Address 3. Add 0’s for the rest of the bits in the Network
Determine which bits in the address contain Network (subnet) information and which contain
Host information:
■ Use the Network Mask: 255.255.0.0 and divide (Great Divide) the from the rest of the
address.
■ Use Subnet Mask: 255.255.255.192 and divide (Small Divide) the subnet from the hosts
between the last “1” and the first “0” in the subnet mask.
114 255
Host Portion
❑ 210 = 1,024
❑26=64
❑ 64 host per subnets
Conclusion:
Hence we have studied Subnetting and the importance of subnetting.
AssignmentQuestions:
1. What is subnetting?
2. What is the importance of subnetting?.
3. How to find the first and last address of subnet?
4. What is the difference between supernetting and subnetting?
5.What is classful and classless ip address?
6. What is subnet mask? How to find subnet mask?
GROUP B
Assignment No 5.(Group B)
Title Write a Program using TCP socket for wired network for following
A. Say Hello to Each Other.
B. File Transfer.
Roll No
Date
Signature
Assignment No: 05
Problem Definition:
Problem Definition:Write a program using TCP socket for wired network for following a.
Say Hello to Each other b. File transfer
1.1Prerequisite:
a) Socket b) Network Programming c) Ports
Header
LearningObjectives:
1. TounderstandWorkofSocket
2. DifferentmethodsassociatedwithClient&ServerSocket
NewConcepts:
1. Client Server Communication
2. Port Address
1.3 Theory:
1.3.1 Introduction
Theory: Socket Programming: The Berkeley socket interface, an API, allows
communications between hosts or between processes on one computer, using the concept of a
socket. It can work with many different I/O devices and drivers, although support for these
depends on the operating system implementation. This interface implementation is implicit for
TCP/IP, and it is therefore one of the fundamental technologies underlying the Internet. It was
first developed at the University of California, Berkeley for use on Unix systems. All modern
operating systems now have some implementation of the Berkeley socket interface, as it has
become the standard interface for connecting to the Internet. Programmers can make the socket
interfaces accessible at three different levels, most powerfully and fundamentally at the RAW
socket level. Very few applications need the degree of control over outgoing communications
that this provides, so RAW sockets support was intended to be available only on computers used
for developing Internet related technologies. TCP TCP provides the concept of a connection. A
process creates a TCP socket by calling the socket() function with the parameters PF_INET or
PF_INET6 and SOCK_STREAM. Server Setting up a simple TCP server involves the following
steps: Creating a TCP socket, with a call to socket(). Computer Networks Lab 2 Binding the
socket to the listen port, with a call to bind(). Before calling bind(), aprogrammer must declare a
sockaddr_in structure, clear it (with bzero() ormemset()), and the sin_family (AF_INET or
AF_INET6), and fill its sin_port (the listening port, in network byte order) fields. Converting a
short int to networkbyte order can be done by calling the function htons() (host to network
short).
Preparing the socket to listen for connections (making it a listening socket), with acall to
listen().
Accepting incoming connections, via a call to accept(). This blocks until anincoming connection
is received, and then returns a socket descriptor for theaccepted connection. The initial
descriptor
remains a listening descriptor, andaccept() can be called again at any time with this socket,
until
it is closed. Communicating with the remote host, which can be done through send() andrecv().
Eventually closing each socket that was opened, once it is no longer needed, using close(). Note
that if there were any calls to fork(), each process must close the sockets it knew about (the
kernel keeps track of how many processes have a descriptor open), and two processes should
not
use the same socket at once. Client: Setting up a TCP client involves the following steps: 1.
Creating a TCP socket, with a call to socket(). 2. Connecting to the server with the use of
connect, passing a sockaddr_in structurewith the sin_family set to AF_INET or AF_INET6,
sin_port set to the port theendpoint is listening (in network byte order), and sin_addr set to the
IPv4 or IPv6address of the listening server (also in network byte order.) 1. Communicating with
the server by send()ing and recv()ing.Terminating the connection and cleaning up with a call to
close(). Again, if therewere any calls to fork(), each process must close() the socket. Functions:
1.
socket(): socket() creates an endpoint for communication and returns a descriptor. socket()
takes
three arguments: domain, which specifies the protocol family of the created socket. For
example:
PF_INET for network protocol IPv4 or PF_INET6 for IPv6). type, one of: Computer Networks
Lab 3 SOCK_STREAM (reliable stream-oriented service) SOCK_DGRAM (datagram service)
SOCK_SEQPACKET (reliable seq enced packet service), r SOCK_RAW (raw protocols atop
the network layer).protocol usually set to 0 to represent the default transport protocol for the
0r PF_INET1or PF_INET6 andSOCK_STREAM, UDP
specified domain and type values (TCP fo
for those PF_ values and SOCK_DGRAM), but whichcan also explicitly specify a protocol. The
function returns -1 if an error occurred. Otherwise, it returns an integer representing the
newly- assigned descriptor. Prototype: int socket(int domain, int type, int protocol); connect():
connect() returns an integer representing the error code: 0 represents success, while -1
represents an error.
Certain types of sockets are connectionless, most commonly user datagram protocol sockets.
For
these sockets, connect takes on a special meaning: the default target for sending and receiving
data gets set to the given address, allowing the use of functions such as send() and recv() on
connectionless sockets. Prototype: int connect(intsockfd, conststructsockaddr *serv_addr,
socklen_taddrlen); bind(): bind() assigns a socket an address. When a socket is created using
socket(), it is given an address family, but not assigned an address. Before a socket may accept
incoming connections, it must be bound. bind() takes three arguments: sockfd, a descriptor
representing the socket to perform the bind onmy_addr, a pointer to a sockaddr structure
representing the address to bind to. addrlen, a socklen_t field representing the length of the
sockaddr structure. It returns 0 on success and -1 if an error occurs. Prototype: int
bind(intsockfd,
structsockaddr *my_addr, socklen_taddrlen); listen() listen() prepares a bound socket to
accept
incoming connections. This function is only applicable to the SOCK_STREAM and
SOCK_SEQPACKET socket types. It takes two arguments: sockfd, a valid socket descriptor.
Computer Networks Lab 4 backlog, an integer representing the number of pending connections
that can be queued up at any one time. The operating system usually places a cap on this
value.
Once a connection is accepted, it is dequeued. On success, 0 is returned. If an error occurs, -1
is
returned. Prototype: int listen(intsockfd, int backlog); accept() Programmers use accept() to
accept a connection request from a remote host. It takes the following arguments: sockfd, the
descriptor of the listening socket to accept the connection from. cliaddr, a pointer to the
sockaddr structure that accept() should put the client'saddress information into. addrlen, a
pointer to the socklen_t integer that will indicate to accept() how largethe sockaddr structure
pointed to by cliaddr is. When accept() returns, the ocklen_t integer then indicates how many
bytes of the cliaddr structure wereactually used. The function returns a socket corresponding
to
the accepted connection, or -1 if an error occurs. Prototype: int accept(intsockfd,
structsockaddr
*cliaddr, socklen_t *addrlen); Blocking vs. nonblocking B rkeley sockets can operate in one of
two modes: blocking or non-blocking. A 0
blocking so1
cket will not "return" until it has sent (or
received) all the data specified for the operation. This may cause problems if a socket
continues to listen: a program may hang as the socket waits for data that may never arrive. A
socket is typically set to blocking or nonblocking mode using the fcntl() or ioctl() functions.
Cleaning up The system will not release the resources allocated by the socket() call until a
close() call occurs.
This is especially important if the connect() call fails and may be retried. Each call to socket()
must have a matching call to close() in all possible execution paths.
Algorithm: Server Program
4. Perform communication with client Receive from client: String line = is.readLine(); Send to
client: os.writeBytes(“Hello\n”)
0 1
Socket Types
There are four types of sockets available to the users. The first two are most commonly used
and the last two are rarely used.
Processes are presumed to communicate only between sockets of the same type but there is no
restriction that prevents communication between sockets of different types.
● Stream Sockets − Delivery in a networked environment is guaranteed. If you send
through the stream socket three items "A, B, C", they will arrive in the same order − "A,
B, C". These sockets use TCP (Transmission Control Protocol) for data transmission. If
delivery is impossible, the sender receives an error indicator. Data records do not have
any boundaries.
● Datagram Sockets − Delivery in a networked environment is not guaranteed. They're
connectionless because you don't need to have an open connection as in Stream Sockets
– you build a packet with the destination information and send it out. They use UDP
(User Datagram Protocol).
● RawSockets−Theseprovideusersaccesstotheunderlyingcommunicationprotocols,
which support socket abstractions. These sockets are normally datagram oriented,
though their exact characteristics are dependent on the interface provided by the
protocol. Raw sockets are not intended for the general user; they have been provided
mainly for those interested in developing new communication protocols, or for gaining
access to some of the more cryptic facilities of an existing protocol.
Here is the description of the parameters −
● socket_family − This is either AF_UNIX or AF_INET, as explained earlier.
● socket_type−ThisiseitherSOCK_STREAMorSOCK_DGRAM.
● protocol−Thisisusuallyleftout,defaultingto0.
Once you have socket object, then you can use required functions to create your client or server
program. Following is the list of functions required –
SERVER SOCKET METHODS
0 1
3 s.accept()This passively accept TCP client connection, waiting until connection arrives (blocking).
Methods Associated with Socket:The following diagram shows the complete Client and Server
interaction −
0 1
CONCLUSION Thus we have successfully implemented the socket programming for TCP
Questions:
0 1
Assignment No 6.(Group B)
Title Write a Program using UDP sockets to enable file transfer (Script, Text,
Audio and Video one file each) between two machines.
Roll No
Date
Signature
0 1
Assignment No: 06
Problem Definition:
Problem Definition:Write a program using UDP Sockets to enable file transfer (Script,
Text, Audio and Video one file each) between two machines
1.1Prerequisite:
a)SocketHeader b)NetworkProgramming c)Ports
LearningObjectives:
1. TounderstandWorkofSocket
2. DifferentmethodsassociatedwithClient&ServerSocket
NewConcepts:
1. Client Server Communication
2. Port Address
1.3 Theory:
1.3.1 Introduction
What is UDP?
UDP is a connectionless and unreliable transport protocol.The two ports serve to identify the end
points within the source and destination machines. User Datagram Protocol is used, in place of
TCP, when a reliable delivery is not required.However, UDP is never used to send important
data such as web-pages, database information, etc. Streaming media such as video,audio and
others use UDP because it offers speed.
Why UDP is faster than TCP?
The reason UDP is faster than TCP is because there is no form of flow control. No error
checking,error correction, or acknowledgment is done by UDP.UDP is only concerned with
speed. So when, the data sent over the Internet is affected by collisions, and errors will be
present. UDP packet's called as user datagrams with 8 bytes header. A format of user
datagrams
is shown in figur 3. In the user datagrams first 8 bytes contains header information and the
remaining bytes contains data.
LINUX SOCKET PROGRAMMING:
The Berkeley socket interface, an API, allows communications between hosts or between
processes on one computer, using the concept of a socket. It can work with many different I/O
devices and drivers, although support for these depends on the operating-system
implementation.
This interface implementation is implicit for TCP/IP, and it is therefore one of the fundamental
technologies underlying the Internet. It was first developed at the University of California,
Berkeley for use on Unix systems. All modern operating systems now have some
implementation of the Berkeley socket interface, as it has become the standard interface for
connecting to the Internet. Programmers can make the socket interfaces accessible at three
different levels, most powerfully and fundamentally at the RAW socket level. Very few
applications need the degree of control over outgoing communications that this provides, so
RAW sockets support was intended to be available only on computers used for developing
Internet-related technologies. In recent years, most operating systems have implemented
support
for it anyway, including Windows XP. The header files: The Berkeley socket development
library has many associated header files. They include: Definitions for the most basic of socket
structures with the BSD socket API Basic data types associated with structures within the BSD
socket API Definitions for the socketaddr_in{} and other base data structures.
The header files:
The Berkeley socket development library has many associated header files.
They include: <sys/socket.h>
Basic data types associated with structures within the BSD socket API
<sys/types.h> Socket API<sys/types.h>
Definitions for the socketaddr_in{} and other base data structures
<sys/un.h>
Definitions and data type declarations for SOCK_UNIX streams
UDP: UDP consists of a connectionless protocol with no guarantee of delivery. UDP packets
may arrive out of order, become duplicated and arrive more than once, or even not arrive at all.
Due to the minimal guarantees involved, UDP has considerably less overhead than TCP. Being
connectionless means that there is no concept of a stream or connection between two hosts,
instead, data arrives in datagrams. UDP address space, the space of UDP port numbers (in ISO
terminology, the TSAPs), is completely disjoint from that of TCP ports. Server: Code may set up
a UDP server on port 7654 as follows:
sock = socket(PF_INET,SOCK_DGRAM,0);
sa.sin_addr.s_addr = INADDR_ANY;
sa.sin_port = htons(7654);
bound = bind(sock,(struct sockaddr *)&sa, sizeof(struct sockaddr));
if (bound < 0) fprintf(stderr, "bind(): %s\n",strerror(errno)); listen(sock,3);
bind() binds the socket to an address/port pair. listen() sets the length of the new connections
queue.
while (1)
{
printf ("recv test ... \n");
recsize = recvfrom(sock, (void *)hz, 100, 0, (struct sockaddr *)&sa, fromlen);
printf ("recsize: %d\n ",recsize);
if (recsize < 0)
fprintf(stderr, "%s\n", strerror(errno));
sleep(1);
printf("datagram: %s\n",hz);
}
This infinite loop receives any UDP datagrams to port 7654 using recvfrom(). It uses the
parameters: l socket l pointer to buffer for data l size of buffer l flags (same as in read or other
receive socket function)
Client: A simple demo to send an UDP packet containing "Hello World!" to address 127.0.0.1,
port 7654 might look like this:
#include #include #include #include #include
#include int main(int argc, char *argv[])
{
int sock; struct sockaddr_in sa;
int bytes_sent, buffer_length;
char buffer[200];
sprintf(buffer, "Hello World!");
buffer_length = strlen(buffer) + 1;
sock = socket(PF_INET, SOCK_DGRAM, 0);
sa.sin_family = AF_INET;
sa.sin_addr.s_addr = htonl(0x7F000001);
sa.sin_port = htons(7654); bytes_sent = sendto(sock, buffer, buffer_length, 0, &sa,
sizeof(struct sockaddr_in) );
if(bytes_sent < 0) printf("Error sending packet: %s\n", strerror(errno) );
return 0;
}
In this code, buffer provides a pointer to the data to send, and buffer_length specifies the size
of
the buffer contents. Typical UDP client code
● CreateUDPsockettocontactserver(withagivenhostnameandserviceportnumber)
● CreateUDPpacket.
● Callsend(packet),sendingrequesttotheserver.
● Possiblycallreceive(packet)(ifweneedareply).
Typical UDP Server code
● CreateUDPsocketlisteningtoawellknownportnumber.
● Create UDP packet buffer Call receive(packet) to get a request, noting the address of the
client.
● Processrequestandsendreplybackwithsend(packet).
APPLICATION :
Socket programming is essential in developing any application over a network.
Title Study and Analyze the performance of HTTP, HTTP’S, and FTP
protocol using packet tracer tool.
Roll No
Date
Signature
Assignment No: 07
Problem Definition:Study and Analyze the performance of HTTP, HTTPS and FTP protocol using
Packet tracer tool.
The File Transfer Protocol (FTP) is a standard network protocol used for the transfer of
computer files between a client and server on a computer network.
FTP employs a client-server architecture whereby the client machine has an FTP client
installed
and establishes a connection to an FTP server running on a remote machine. After the
connection has been established and the user is successfully authenticated, the data transfer
phase can begin.
Worth noting: Although FTP does support user authentication, all data is sent in clear text,
including usernames and passwords. For secure transmission that protects the username and
password, and encrypts the content, FTP is often secured with SSL/TLS (FTPS) or replaced with
SSH File Transfer Protocol (SFTP).
FTP topology.PNG
3. Now try using an FTP client built in the Laptop to send files to an FTP server configured in
the Server.
From the Laptop’s command prompt, FTP the server using the server IP address by typing: ftp
192.168.1.2
Provide the username(cisco) and password(cisco) [which are the defaults] for ftp login.
PC0 has an FTP client which can be used to read, write, delete and rename files present in the
FTP server.
The FTP server can be used to read and write configuration files as well as IOS images.
Additionally, the FTP server also supports file operations such rename, delete and listing
directory.
4. Create a file in the Laptop then upload it to the server using FTP.
To do this, open the Text Editor in the Laptop, create a file and give it your name of choice.
Type any text in the editor then save your file. e.g. myFile.txt.
0 1
5. Now upload the file from the Laptop to the server using FTP. (An FTP connection has to be
started first. But this is what we’ve done in step 3)
put MyFile.txt
6. Once file upload is successful, go to the Server FTP directory to verify if the file sent has
been received . To do this, go to Server-> Services->FTP. Here look for MyFile.txt sent from the
laptop.
1
MyFile.txt really send to sever.PNG
Something extra: To check other FTP commands supported by the FTP client running on the
Laptop(or PC), you can use a question mark (?) on the Laptop’s command prompt as shown
below:
You can see the put command that we used to upload our file to the FTP server. Other
commands listed include:
For example, we can open an HTTP directory in the server by typing: cd /http. This will change
the current directory from FTP directory to HTTP directory
Once the http directory is open, you can upload a file to the HTTP server. You’re now uploading
a file to an HTTP folder(directory) using FTP.
To see this working, let’s open an HTTP directory and upload(put) a file to it using FTP:
You can now check up in the HTTP directory in the server and verify that the file uploaded from
the Laptop(MyFile.txt) is well received:
MyFile.txt really send to HTTP server
Notice that we are uploading files to an HTTP Server directory using File Transfer Protocol.
(FTP). This is what actually happens when you use an FTP client such as FileZilla client to
upload files to a website. In our case here, we are using an FTP client built-in the Laptop.
This may interest you: The first FTP client applications were command-line programs
developed
b
Weifnodroewosperating systems had graphical user interfaces, and are still shipped with most
and Linux operating systems. (Actually this is what we have been using this far). Many FTP
clients(e.g. FileZilla) and automation utilities have since been developed for desktops, servers,
mobile devices, and hardware. FTP has also been incorporated into productivity applications,
such as HTML editors.
We’ll create an html file in our Laptop, upload it to HTTP server directory using FTP, then try
to access the file from the Laptop’s browser.
On the Laptop, open the text editor, then type some markup(html) and save the file with the
extension .html. See all this below:
File2 HTML code
Now upload the file( File2.html) to the HTTP server using FTP. This is easy. We’ve already
done it previously!
If you’re already in the HTTP directory, you just need to type: put File2.html. If no, first ftp the
server(ftp 192.168.1.2), provide the login username(cisco) and password(cisco); change the
current directory to HTTP(cd /http) , and finally upload the html file onto the HTTP
directory(put File2.html)
Check whether the html file uploaded has been received in the HTTP
directory: Go to Server->Services-> HTTP. Then look up for the file in the File
Manager.
File2 HTML really uploaded into HTTP directory.PNG
Now edit index.html file in the HTTP directory so as to include a link to File2 that we’ve just
uploaded. This will make File2 accessible from the Laptop’s browser. To do this, locate
index.html then click edit. Proceed to edit it as shown below. Then save and accept
overwrite.Index.html editing to include File2 html.PNG.
Finally, try to access the newly uploaded file from the Laptop’s browser.
So go to the Laptop’s browser and access the server using the server’s IP address. By doing this,
the browser is making an http request to the server. The server will respond to the Laptop with
the index.html file containing a link to File2 which we’ve uploaded from the Laptop using FTP.
Conclusion:: Successfully studied and Analyze the performance of HTTP, HTTPS and FTP
protocol using Packet tracer tool.
Assignment Questions:
Title To study the SSL protocol by capturing the packets using wireshark tool
while visiting any SSL secured website (banking, e-commerce etc.)
Roll No
Date
Signature
Assignment No: 08
Title:
To study the SSL protocol by capturing the packets using Wireshark tool while visiting any SSL
secured website (banking, e-commerce etc.)
Outcomes:
Retrieve SSL protocol by capturing the packets using Wireshark.
Theory:
SSL, or Secure Sockets Layer, is an encryption-based Internet security protocol. It was first
developed by Netscape in 1995 for the purpose of ensuring privacy, authentication, and data integrity
in Internet communications. SSL is the predecessor to the modern TLS encryption used today.
SSL initiates an authentication process called a handshake between two communicating devices to
ensure that both devices are really who they claim to be.
SSL also digitally signs data in order to provide data integrity, verifying that the data is not tampered
with before reaching its intended recipient.
There have been several iterations of SSL, each more secure than the last. In 1999 SSL was updated
to become TLS.
Once your browser is logging pre-master keys, it’s time to configure Wireshark to use those logs to
decrypt SSL.
Open Wireshark and click Edit, then Preferences. The Preferences dialog will open, and on the left,
you’ll see a list of items. Expand Protocols, scroll down, then click SSL.
The final step is to capture a test session and make sure that Wireshark decrypts SSL successfully.
□ Startanunfilteredcapturesession,minimizeit,andopenyourbrowser.
□ Visitasecuresiteinordertogeneratedata,andoptionallysetadisplayfilterof‘ssl’to
minimize the session noise.
□ Clickonanyframecontainingencrypteddata.
In my case, I’ll select one that contains HTTP traffic with text/HTML encoding, since I’d like to see
the source code the web server is sending to my browser. But any encrypted transmissions that use a
pre-master secret or private key will work with this method. That includes all data utilizing Perfect
Forward Encryption (PFE) through Diffie-Hellman or comparable key exchanges.
Once you’ve selected an encrypted data frame, look at the Packet byte view, and specifically the
tabs underneath the view. You should see an entry for Decrypted SSL data, among others.
You’ll notice that my session still looks like it’s full of garbage, and no HTML is visible. That’s
because my web server (and most Apache servers) use GZIP compression by default.
When you click the Uncompressed entity body tab, which only shows up in this case with SSL
decryption enabled, you can view the source code of the site. For instance, here’s the title element
of the default Apache page in plaintext.
In the list of options for the SSL protocol, you’ll see an entry for (Pre)-Master-Secret log filename.
Browse to the log file you set up in the previous step, or just paste the path.
When you’ve finished setting the (Pre)-Master-Secret log filename, click OK and return to
Wireshark.
Conclusion:
Title Illustrate the steps for implementation of S/MIME email security through
Microsoft office outlook.
Roll No
Date
Signature
Assignment No: 09
Problem Definition: Illustrate the steps for implementation of S/MIME email security through
Microsoft® Office Outlook.
Prerequisite:
Learning Objectives:
1. Understand the concept and working of Encrypted mails
Theory
S/MIME allows users to send encrypted and digitally signed emails . This protocol allows
recipients of the email to be certain the email they receive is the exact message that began
with
the sender. It also helps ensure that a message going to an outbound recipient is from a
specific
sender and not someone assuming a false identity.
and digital signatures. All these elements work together to enhance privacy and security for
both
encrypts the path between two email servers. The protocol is also compatible with Secure
Sockets Layer (SSL) which masks the connection between email messages and Office 365 (a
drive in a data center so if a hacker gets access, he or she won’t be able to interpret the
information.
If you’re sending information like your Social Security number over email, it’s important that it’s
2. Economical
Instead of purchasing security equipment, you can simply rely on email encryption that’s
3. Timesaving
Instead of wasting time using several programs to make sure a connection is secure, you can rely
4. Regulation compliance
If you work in the healthcare industry, for example, and you haven’t taken the right steps to
secure medical data, you could be in violation of HIPAA laws [6]. Encryption helps you avoid those
missteps.
Malicious emails sometimes contain viruses masked as innocent email attachments. If you or
someone else send an attachment using encrypted email, the email has a digital signature to
the outsider, an encrypted email will have a bunch of random letters, digits, or symbols instead of
readable text. The person with the private key to decrypt it, typically the receiver, will be able
● S/MIME encryption works as long as both the sender and recipient have mailboxes that
support it. Windows Outlook is the most popular version that works with this method.
● Office 365 Message Encryption is best for users with valid Microsoft Office licenses who
can use this tool to encrypt the information and files sent via email. It’s also a top choice
● PGP/MIME is a more affordable and popular option that other email clients may prefer
to use. It’s reliable and integrated into many of the apps we use today
Other email products may have their own brand of encryption, but the science behind it is the
same. Only senders and recipients who have exchanged keys or digital signatures can
Encrypting email may sound complicated, but it’s not. Microsoft has a reputation for providing its
users with simple ways to encrypt data, from files to folders to emails, too. It makes sense that
they would include built-in tools for Outlook, their proprietary email system. You don’t need a
separate software tool or plug-in to start sending secure messages. Just follow these steps to
begin.
For Outlook users, encrypting a single email is simple. First, you must have a digital signature. To
80.Make sure the box is checked next to Secure Email Certificate, and check the box next
1
. to “Send These Certificates with Signed Messages”
11.Click OK to save your settings and start using Outlook
You can now send encrypted messages to a recipient with the next steps.
1. Open the window to compose a new message and select the Options tab, then More
Options
2. Click the dialog box (triangle with arrow pointing down) in the lower-right corner
3. Choose Security Settings and check the box next to Encrypt message contents and
attachments
After you’ve sent and received a message that you’ve both signed and encrypted, you don’t have
Outlook:
□ OpentheFiletabinOutlook
□ SelectOptions,thenTrustCenter,andTrustCenterSettings
□ FromtheEmailSecuritytab,selectEncryptedemail
□ ChecktheboxnexttoEncryptcontentandattachmentsforoutgoingmessages
□ UseSettingstocustomizeadditionaloptions,includingcertificates
Have you ever wondered about the security of your private email conversations? Whether at work,
school, or home, sending emails comes with a bit of a risk. There’s one thing you can do to
discourage data breaches and attacks on your sensitive data, however. Use encrypted email.
Learn how to practice this common-sense method for communicating in our step-by-step guide.
But first, let’s look at why you should embrace encryption for your email correspondence.
Emails sent over an open network can be intercepted and malicious actors can see email
contents, attachments, or even take over your account.To drive home the importance of email
security, take a look at some alarming statistics that show the widespread cybersecurity issues
that may
have affected you in the past and still pose a threat today:In 2016, 3 billion Yahoo accounts were
hackedAccording to research by cybersecurity company, Symantec, emails with a malicious
URL make up a total of 12.3% of all emails As these numbers illustrate, emails are a point of
vulnerability for many unsuspecting users. However, it’s not all doom and gloom, there are ways
to protect yourself and your information.To help safeguard against hackers and ensure your
privacy is maintained, you can use encryption. Encryption ensures that your emails remain
Conclusion:Thus we have studied the steps for implementation of S/MIME email security through
Microsoft® Office Outlook.ets received from / sent to Face book, and how many of each were also
HTTP packets successfully.
Assignment No 10.(Group B)
Title To study the IPSec (ESP and AH ) protocol by capturing the packets using
wireshark tool.
Roll No
Date
Signature
Assignment No: 10
Title: To study the IPsec (ESP and AH) protocol by capturing the packets using Wireshark tool.
Outcomes:
Retrieve IPsec (ESP and AH) protocol by capturing the packets using Wireshark tool.
.
Theory:
The IP security (IPSec) is an Internet Engineering Task Force (IETF) standard suite of
protocols between 2 communication points across the IP network that provide data
authentication, integrity, and confidentiality. It also defines the encrypted, decrypted and
authenticated packets. The protocols needed for secure key exchange and key management are
defined in it.
What is ISAKMP?
ISAKMP stands for Internet Security Association and Key Management Protocol. These are
two key components of an IPSEC VPN that must be ipnlace in order for it to function normally
and protect the public traffic that is being forwadred between the client and VPN server or VPN
server to VPN server.
ESP may be used to ensure confidentiality, the authentication of data origins, connectionless integrity,
some degree of traffic-level confidentiality, and an anti-replay service (a form of partial sequence integrity
which guards against the use of commands or credentials which have been captured through password
sniffing or similar attacks).3
Authentication Header
Authentication Header (AH) is a new protocol and part of the Internet Protocol Security (IPsec)
protocol suite, which authenticates the origin of I P packets (datagrams) and guarantees the
integrity of the data. The AH confirms the originating source of a packet and ensures that its
contents (both the header and payload) have not been changed since transmission.
Conclusion : Successfully studied the IPsec (ESP and AH) protocol by capturing the packets using
Wireshark tool.
0 1
GROUP C
0 1
Assignment No 11.(Group C)
Title Installing and configuring DHCP server and assign IP addresses to client
machines using DHCP server.
Roll No
Date
Signature
0 1
Assignment No: 11
Problem Definition:
Installing and configuring DHCP server and assign IP addresses to client machines using
DHCP server
Objective:
To install DHCP server.
To configure DHCP server.
Theory:
Same Network:
Although the practice is not very common, the administrator may put the client and the server on
the same network as shown in Figure 1.
In this case, the operation can be described as follows:
1
1. TheDHCPserverissuesapassiveopencommandonUDPportnumber67andwaitsfor a client.
2. Abootedclientissuesanactiveopencommandonportnumber68.Themessageis
encapsulated in a UDP user datagram, using the destination port number 67 and the source port
number 68. The UDP user datagram, in turn, is encapsulated in an IP datagram. The reader may
ask how a client can send an IP datagram when it knows neither its own IP address (the source
address) nor the server’s IP address (the destination address). The client uses all 0s as the source
address and all 1s as the destination address.
3. TheserverrespondswitheitherabroadcastoraunicastmessageusingUDPsourceport number 67
and destination port number 68. The response can be unicast because the server knows the IP
address of the client. It also knows the physical address of the client, which means it does not
need the services of ARP for logical to physical address mapping. However, some systems do not
allow the bypassing of ARP, resulting in the use of the broadcast address.
0 1
Different Networks:
As in other application-layer processes, a client can be in one network and the server in another,
separated by several other networks. Figure2 shows the situation.
0 1
❑ Hardware length. This is an 8-bit field defining the length of the physical address in bytes. For
example, for Ethernet the value is 6.
❑ Hop count. This is an 8-bit field defining the maximum number of hops the packet
can travel.
❑ Transaction ID. This is a 4-byte field carrying an integer. The transaction identification is set
by the client and is used to match a reply with the request. The server returns the same value in
its reply.
❑ Number of seconds. This is a 16-bit field that indicates the number of seconds elapsed since
the time the client started to boot.
❑ Flag. This is a 16-bit field in which only the leftmost bit is used and the rest of the bits should be
set to 0s. A leftmost bit specifies a forced broadcast reply (instead of unicast) from the server.
If the reply were to be unicast to the client, the destination IP address of the IP packet is the
address assigned to the client. Since the client does not know its IP address, it may discard the
packet. However, if the IP datagram is broadcast, every host will receive and process the
broadcast message.
0 1
Flag Format:
❑ Client IP address. This is a 4-byte field that contains the client IP address. If the client does not
have this information, this field has a value of 0.
❑ Your IP address. This is a 4-byte field that contains the client IP address. It is filled by the
server (in the reply message) at the request of the client.
❑ Server IP address. This is a 4-byte field containing the server IP address. It is filled by the
server in a reply message.
❑ Gateway IP address. This is a 4-byte field containing the IP address of a router. It is filled by the
server in a reply message.
❑ Client hardware address. This is the physical address of the client. Although the server can
retrieve this address from the frame sent by the client, it is more efficient if the address is
supplied explicitly by the client in the request message.
❑ Server name. This is a 64-byte field that is optionally filled by the server in a reply packet. It
contains a null-terminated string consisting of the domain name of th server. If the server does
not want to fill this field with data, the server must fill it with all 0s.
❑ Boot filename. This is a 128-byte field that can be optionally filled by the server in a reply
packet. It contains a null-terminated string consisting of the full pathname of the boot file. The
client can use this path to retrieve other booting information. If the server does not want to fill this
field with data, the server must fill it with all 0s.
❑ Options. This is a 64-byte field with a dual purpose. It can carry either additional information (
such as the network mask or default router address) or some specific vendor information. The
field is used only in a reply message. The server uses a number, called a magic cookie, in the
format of an IP address with the value of 99.130.83.99. When the client finishes reading the
message, it looks for this magic cookie. If present, the next 60 bytes are options. An option is
composed of three fields: a 1-byte tag field, a 1-byte length field, and a variable-length value
field. The length field defines the length of the value field, not the whole option.
0 1
DHCP client transition:
INIT State :
When the DHCP client first starts, it is in the INIT state (initializing state). The client
broadcasts a DHCPDISCOVER message (a request message with the DHCPDISCOVER
option), using port 67.
SELECTING State:
After sending the DHCPDISCOVER message, the client goes to the selecting state.
Those servers that can provide this type of service respond with a DHCPOFFER
message. In these messages, the servers offer an IP address. They can also offer the lease
duration. The default is 1 hour. The server that sends a DHCPOFFER locks the offered
IP address so that it is not available to any other clients. The client chooses one of the offers and
sends a DHCP REQUEST message to the selected server. It then goes to the requesting state.
However, if the client receives no DHCPOFFER message, it tries four more times, each with a
span of 2 seconds. If there is no reply to any of these DHCP DISCOVER s, the client sleeps for 5
minutes before trying again.
REQUESTING State:
The client remains in the requesting state until it receives a DHCPACK message from the server
that creates the binding between the client physical address and its IP address. After receipt of
the DHCPACK, the client goes to the bound state.
BOUND State:
In this state, the client can use the IP address until the lease expires. When 50 percent of the
lease period is reached, the client sends another DHCPREQUEST to ask for renewal. It then goes
to the renewing state. When in the bound state, the client can also cancel the lease and go to the
initializing state.
0 1
Figure 4: DHCP client transition
RENEWING State:
The client remains in the renewing state until one of two events happens. It can receive a
DHCPACK, which renews the lease agreement. In this case, the client resets its timer and goes
back to the bound state. Or, if a DHCPACK is not received, and 87.5 percent of the lease time
expires, the client goes to the rebinding state.
REBINDING State
The client remains in the rebinding state until one of three events happens. If the client receives a
DHCPNACK or the lease expires, it goes back to the initializing state and tries to get another IP
address. If the client receives a DHCPACK, it goes to the bound state and resets the timer.
• DHCP also uses the file /var/lib/dhcp/dhcpd.leases to store the client leasedatabase.
0 1
• This file should not be modified by hand. DHCP lease information for each recently assigned
IP address is automatically stored in the lease database. The information includes the length of
the lease, to whom the IP address has been assigned, the start and end dates for the lease, and
the
MAC address of the network interface card that was used to retrieve the lease
• Many RPM packages don't automatically install a /etc/dhcpd.conf file, but you can find a
sample copy of dhcpd.conf in the following directory which you can always use as a guide:
• /usr/share/doc/dhcp-<version-number>/dhcpd.conf.sample
• # cp /usr/share/doc/dhcp-3.0pl1/dhcpd.conf.sample \ /etc/dhcpd.conf
/etc/dhcpd.conf
• There are two types of statements in the configuration file:
– Parameters—statehowtoperformatask,whethertoperformatask,orwhatnetwork
configuration options to send to the client.
– Declarations—describethetopologyofthenetwork,describetheclients,provide
addresses for the clients, or apply a group of parameters to a group of declarations.
• Some parameters must start with the option keyword and are referred to as options.
/etc/dhcpd.conf
• The routers, subnet-mask, domain-name, domain-name- servers, and time-offset options are
used for any host statements declared below it
• You must include a subnet declaration for every subnet in your network. If you do not, the
DHCP server will fail tostart
• Clients are assigned an IP address within the range
• To assign an IP address to a client based on the MAC address of the network interface card,
use the hardware ethernet parameter within a host declaration.
/etc/dhcpd.conf
subnet 192.168.1.0 netmask 255.255.255.0 { # The
range of IP addresses the server will issue to #DHCP
enabled PC clients booting up on the network range
192.168.1.10 192.168.1.100; range 192.168.1.201
0 1
192.168.1.220; # Set the amount of time in seconds
that
# a client may keep the IP address
default-lease-time 86400; max-lease-
time 86400;
# Set the default gateway to be used by
# the PC clients
option routers 192.168.1.1;
# Don't forward DHCP requests from this #
NIC interface to any other NIC interfaces
optionip-forwarding off;
/etc/dhcpd.conf
# Set the broadcast address and subnet mask
# to be used by the DHCP clients option
broadcast-address 192.168.1.255; option
subnet-mask 255.255.255.0;
# Set the DNS server to be used by the DHCP clients
option domain-name-servers 192.168.1.100;
# If you specify a WINS server for your Windows clients,
# you need to include the following option in the dhcpd.conf file: optionnetbios-name-
servers 192.168.1.100;
0 1
• # /etc/init.d/dhcpd
start # /etc/init.d/dhcpd
stop
# /etc/init.d/dhcpd
restart
Configuration Steps:
• 1 . To install DHCP server on ubuntu, Type following command on terminal.
– sudo apt-get install isc-dhcp-server
•2 . Now we should configure DHCP server. Configuration file is stored at location
/etc/dhcp/dhcpd.conf .
• Use gedit to edit dhcpd.conf
# A slightly different configuration for an internal subnet.
subnet 172.16.5.0 netmask 255.255.255.0
{ range 172.16.5.2 172.16.5.5; option
domain-name-servers 8.8.8.8; option
routers 172.16.1.1; option broadcast-
address 172.16.5.255;
Title Write a Program For DNS lookup. Given an IP address input, it should
return URL and vice versa.
Roll No
Date
Signature
Assignment No: 12
Problem Definition:
Write a program for DNS lookup. Given an IP address input, it should return URL and vice
versa.
1.1 Prerequisite:
1. IP Address and OSI & TCP/IP Model.
2. Role of different servers.
3. Working of internet.
1.2 Learning Objectives:
1. Understand what is Domain Name System and DNS lookup working. 2.
Understand what is DNS Structure and Hierarchy.
1.3 New Concepts:
1. Name Server and Domain Name System.
2. DNS lookup, Zone
1.4 Theory
1.4.1 Introduction
The Domain Name System (DNS) is a hierarchical decentralized naming system for
computers, services, or other resources connected to the Internet or a private network. It
associates various information with domain names assigned to each of the participating
entities.
it translates more readily memorized domain names to the numerical IP addresses needed
for locating and identifying computer services and devices with the underlying network
protocols. By providing a worldwide, distributed directory service, the Domain Name
System is an essential component of the functionality on the Internet that has been in use
since 1985.
HOST.TXT files:
The ARPANET, the predecessor of the Internet, had no distributed host name database.
Each network node maintained its own map of the network nodes as needed and
assigned those names that were memorable to the users of the system.
The hosts file contains lines of text consisting of an IP address in the first text field
followed by one or more host names. Each field is separated by white space – tabs are
often preferred for historical reasons, but spaces are also used. Comment lines may be
included; they are indicated by an octothorpe (#) in the first position of such lines.
Entirely blank lines in the file are ignored. For example, a typical hosts file may contain
the following:
127.0.0.1 localhost loopback
::1 localhost
1.4.2 Domain Name Space
The domain name space refers a hierarchy in the internet naming structure. This
hierarchy has multiple levels (from 0 to 127), with a root at the top. The following
diagram shows the domain name space hierarchy:
1.4.3 Name Server
Name server contains the DNS database. This database comprises of various names and
their corresponding IP addresses. Since it is not possible for a single server to maintain
entire DNS database, therefore, the information is distributed among many DNS servers.
∙ Hierarchy of server is same as hierarchy of names.
∙ The entire name space is divided into the zones
1.4.4 Zones
Zone is collection of nodes (sub domains) under the main domain. The server maintains a
database called zone file for every zone.
If the domain is not further divided into sub domains then domain and zone refers to the
same thing.
The information about the nodes in the sub domain is stored in the servers at the lower
levels however; the original server keeps reference to these lower levels of servers.
1.4.5 Types of Name Servers
Following are the three categories of Name Servers that manages the entire Domain
Name System:
1. Root Server
2. Primary Server
3. Secondary Server
1.4.5.1 Root Server
Root Server is the top level server which consists of the entire DNS tree. It does not
contain the information about domains but delegates the authority to the other server
1.4.5.2 Primary Servers
Primary Server stores a file about its zone. It has authority to create, maintain, and update
the zonefile.
1.4.5.3 Secondary Server
Secondary Server transfers complete information about a zone from another server which
may be primary or secondary server. The secondary server does not have authority to
create or update a zone file.
2.1 How does DNS work?
DNS servers answer questions from both inside and outside their own domains. When a
server receives a request from outside the domain for information about a name or
address insidethedomain,itprovidestheauthoritativeanswer.Whenaserverreceivesa
request from inside its own domain for information about a name or address outside that
domain, it passes the request out to another server -- usually one managed by its internet
service provider. If that server does not know the answer or the authoritative source for
the answer, it will reach out to the DNS servers for the top-level domain -- e.g., for all
of .com or .edu. Then, it will pass the request down to the authoritative server for the
specific domain -- e.g., techtarget.com or stkate.edu; the answer flows back along the
same path.
2.2 How DNS Lookup Works
By now, you know that there are different servers hosting databases that contain the IP
addresses of different domains and their sub-domains. You also know that there are Root
Servers that hold the IP address of servers hosting Top Level Domains. These Root
Servers help in reaching the servers containing databases that hold IP address of the
main domain name. If there are sub-domains, their address can be on the same servers as
of the main domain name or on a different server. All these servers are accessible for
finding out the IP address of the exact URL that you need to use.
∙ Forward Lookup: When a name query is send to the DNS server against to IP
address, it is generally said a forward lookup.
∙ Reverse Lookup: DNS also provides a reverse lookup process, enabling clients to
use a known IP address during a name query and look up a computer name based
on its address.
The process of finding out the IP address of any URL on the Internet is known as
DNS lookup.
To find out how DNS Lookup works, take the following example.
Example: Consider a network of ten computers. Each computer has its own address so
that data packets travelling in the network know where to go. There is a 11th computer
that hosts a database containing the alias names of each of these ten computers and their
IP addresses. While the computer users can refer to the computers using their names, the
data packets need the IP addresses of the computers so that they can reach the intended
recipient. If computer A needs to use the printer attached to computer B, A will check
the database on 11th computer to know the IP address of B and then find out the address
of printer attached to B. Only after obtaining the address of the printer, A will route the
print command to printer attached to B.
In this case, the following iterations happen:
A contacts Computer 11
A contacts B
A contacts printer attached to B
A similar method is used to lookup DNS records. For example, when you click on
http://snjb.org, your router will contact your default DNS Service for DNS resolution.
The DNS service will contact Root Servers and ask for the IP address of server
containing .org records. This address is sent back to your DNS service. The DNS service
again reaches the Name Server containing addresses of .org domains and asks it for the
address of http://snjb.org. Upon obtaining the IP address of the servers that host snjb.org,
your DNS service will return the IP address to your computer which then fires up your
browser to download the main webpage. This means your DNS service is sending at
least two requests to receive the IP address of a simple domain name.
Following is an image that explains how DNS lookup works:
4
In the above case, if you were to look for http:// http://snjb.academiaerp.com/snjb/Login , your
DNS service had to run a request extra to know its IP address.
Since resolving DNS from scratch every time takes up time, many ISPs and DNS Service
Providers create local caches that contain already resolved addresses. These are primarily
the addresses they already fetched from Root Servers and other Name Servers at some
point of time. In this case, when you send a request for a URL, instead of contacting the
Root server directly, the DNS service would look up for the resolved address of the URL
in its local DNS cache. If found, it would send the resolution back to your computer
instantly else would go ahead and resolve the DNS using the above method of contacting
Root Servers and other Name Servers.
Some operating systems too contain a local cached copy of addresses that you commonly
use on your computer. This too, helps in saving time while using the Internet. We will
talk about DNS caches in a different article at some later point of time.
Assignment Question:
1. Explain the need of DNS system in internet word.
2. What is the website’s IP address ?
3. What are a Forward and Reverse Lookup?
4. What is primary, Secondary, stub & AD Integrated Zone?
5. Explain the DNS hierarchy.
6. What is the host.txt?
Conclusion:
Hence we conclude that we have lookup the URL which we want to visit the request is travels to
local router to DNS server and it resolve the query as possible otherwise it forwards the query to
next DNS hop.