Professional Documents
Culture Documents
Lab Journal
COMPUTER NETWORK LABORATORY
INDEX
PAGE
SR.NO NAME OF EXPERIMENT
NO.
Setup a network and configure IP addressing, subnetting, masking. (E.g. CISCO Packet
1
Tracer, Student Ed.)
Use basic networking commands in Linux (ping, tracert, nslookup, netstat, ARP, RARP, ip,
2
ifconfig, dig, route )
Build a simple network topology and configure it for static routing protocol using packet
3
tracer.
6 Study of Stop and wait protocol/ sliding window (selective repeat / Go back N )
EVALUATION SHEET
Date of Date of
Sr.No. List of experiments performance checking Grade/marks Remarks
Total marks
Average marks
Roll No.: 04
Class: TE
Aim: Setup a network and configure IP addressing, subnetting, masking. (E.g. CISCO Packet
Tracer, Student Ed.)
THEORY:
Computer Network
A network, in computing, is a group of two or more devices that can communicate. In practice, a
network is comprised of a number of different computer systems connected by physical and/or
wireless connections. The scale can range from a single PC sharing out basic peripherals to
massive data centers located around the World, to the Internet itself.
IP address
The Internet Protocol Address (or IP Address) is a unique address that computing devices such
as personal computers, tablets, and smartphones use to identify itself and communicate with
other devices in the IP network. Any device connected to the IP network must have a unique IP
address within the network. An IP address is analogous to a street address or telephone number
in that it is used to uniquely identify an entity.
Subnetting
Subnetting enables the network administrator to further divide the host part of the address into
two or more subnets. In this case, a part of the host address is reserved to identify the particular
subnet. This is easier to see if we show the IP address in binary format.
If this network is divided into 14 subnets, however, then the first 4 bits of the host address (0001)
are reserved for identifying the subnet.
The subnet mask is the network address plus the bits reserved for identifying the
subnetwork -- by convention, the bits for the network address are all set to 1, though it would
also work if the bits were set exactly as in the network address.
In this case, therefore, the subnet mask would be
11111111.11111111.11110000.00000000.
It's called a mask because it can be used to identify the subnet to which an IP address
belongs by performing a bitwise AND operation on the mask and the IP address. The result is the
subnetwork address:
Subnet mask
A Subnet mask is a 32-bit number that masks an IP address, and divides the IP address into
network address and host address. Subnet Mask is made by setting network bits to all "1"s and
setting host bits to all "0"s. Within a given network, two host addresses are reserved for special
purpose, and cannot be assigned to hosts.
Default gateway
A default gateway serves as an access point or IP router that a networked computer uses to send
information to a computer in another network or the internet. Default simply means that this
gateway is used by default, unless an application specifies another gateway.
Packet tracer
Packet Tracer is a cross-platform visual simulation tool designed by Cisco Systems that allows
users to create network topologies and imitate modern computer networks. The software allows
users to simulate the configuration of Cisco routers and switches using a simulated command
line interface. Packet Tracer makes use of a drag and drop user interface, allowing users to add
and remove simulated network devices as they see fit. The software is mainly focused towards
Certified Cisco Network Associate Academy students as an educational tool for helping them
learn fundamental CCNA concepts.
Result:
Conclusion:
Successfully set up a network and configure IP addressing, subnetting, masking. Using CISCO Packet
Tracer.
Viva Questions:
1. What is computer network?
A computer network is a set of devices connected through links. A node can be computer,
printer, or any other device capable of sending or receiving the data. The links connecting the
nodes are known as communication channels.
2. What is subnetting?
Subnetting is the procedure to divide the network into sub-networks or small networks.
3. What is supernetting?
Supernetting is the procedure to combine the small networks into larger space.
Subnetting Supernetting
Subnetting is the procedure to divide While supernetting is the
the network into sub-networks. procedure of combine the small
networks.
In subnetting, Network addressee’s While in supernetting, Host
bits are increased. addressee’s bits are increased.
In subnetting, The mask bits are While In supernetting, The mask
moved towards right. bits are moved towards left.
Subnetting is implemented via While supernetting is
Variable-length subnet masking. implemented via Classless
interdomain routing.
In subnetting, Address depletion is While It is used for simplify
reduced or removed. routing process.
Aim: Use basic networking commands in Linux (ping, tracert, nslookup, netstat, ARP, RARP,
ip, ifconfig, dig, route )
THEORY:
Ping command?
Ping uses the ICMP protocol’s mandatory ECHO_REQUEST datagram to elicit an ICMP
ECHO_RESPONSE from a host or gateway. ECHO_REQUEST datagrams (‘‘pings’’) have an
IP and ICMP header, followed by a struct timeval and then an arbitrary number of ‘‘pad’’ bytes
used to fill out the packet.
Following table mentions syntax or format of the ping command and extended ping command.
#ping w.x.y.z The command checks for layer-3 connectivity with IP device with
address w.x.y.z
#ping 172.168.20.1 Performs basic layer-3 to test device with ip address 172.168.20.1
#ping Guru Same as above but it pings the system with its IP host name rather
than IP address
tracert command
Traceroute is a utility that records the route (the specific gateway computers at each hop)
through the Internet between your computer and a specified destination computer. It also
calculates and displays the amount of time each hop took. Traceroute is a handy tool both for
understanding where problems are in the Internet network and for getting a detailed sense of the
Internet itself. Another utility, PING, is often used prior to using traceroute to see whether a host
is present on the network.
Nslookup command
nslookup is the name of a program that lets an Internet server administrator or any computer user
enter a host name (for example, "whatis.com") and find out the corresponding IP address. It will
also do reverse name lookup and find the host name for an IP address you specify.
netstat command
Netstat is a command line utility that can be used to list out all the network (socket) connections
on a system. It lists out all the tcp, udp socket connections and the unix socket connections.
netstat - Print network connections, routing tables, interface statistics, masquerade connections,
and multicast memberships.
Ex. netstat -a
netstat -at
netstat -au
Netstat -ant
Ip command
The ip command is used to assign an address to a network interface and/or configure network
interface parameters on Linux operating systems. This command replaces old good and now
deprecated ifconfig command on modern Linux distributions.
Setting and Deleting an Ip Address
$ sudo ip addr add 192.168.0.193/24 dev wlan0
$ ip addr show wlan0
Ifconfig command
Ifconfig command is used to configure network interfaces. ifconfig stands for interface
configurator. Ifconfig is widely used to initialize the network interface and to enable or disable
the interfaces.
1. View Network Settings of an Ethernet Adapter
# ifconfig eth0
2. Display Details of All interfaces Including Disabled Interfaces
# ifconfig -a
3. Disable an Interface
# ifconfig eth0 down
4. Enable an Interface
# ifconfig eth0 up
5. Assign ip-address to an Interface
# ifconfig eth0 192.168.2.2
Dig command
dig (command) dig (domain information groper) is a network administration command-line tool
for querying Domain Name System (DNS) servers. dig is useful for network troubleshooting and
for educational purposes.
The dig command fundamentally used for the following purposes:
1. Performs DNS lookups.
2. Find host addresses, IP address, mail exchanges (MX), CNAMEs, name servers, and more.
3. Verify ISP DNS server and Internet connectivity.
4. Verify spam and blacklisting records.
Syntax
The basic syntax:
dig Hostname
dig DomaiNameHere
dig @DNS-server-name Hostname
dig @DNS-server-name IPAddress
dig @DNS-server-name Hostname|IPAddress type
Route Command:
route is a command used to view and manipulate the IP routing table in both
Unix-like and Microsoft Windows[1] operating systems. Manual
manipulation of the routing table is characteristic of static routing.
Display Existing Routes
$ route
$ route -n
Adding a Default Gateway
$ route add default gw 192.168.1.10
Result:
Conclusion:
Successfully executed basic networking commands on the Linux OS.
Viva Questions:
1) What are the different networking commands? Explain with their usage.
Ping. Ping is used to testing a network host capacity to interact with another host.
Aim: Build a simple network topology and configure it for static routing protocol using
packet tracer.
THEORY:
Routing
Routing is the process of selecting a path for traffic in a
network, or between or across multiple networks.
Broadly, routing is performed in many types of networks,
including circuit-switched networks, such as the public
switched telephone network (PSTN), and computer networks, such as the Internet.
Routing is the process of selecting paths in a network along which to send network traffic and
route is the path to send the network traffic.
The routing process usually directs forwarding on the basis of routing tables, which maintain a
record of the routes to various network destinations. Routing tables may be specified by an
administrator, learned by observing network traffic or built with the assistance of routing
protocols.
Destination
Types of routing
Two main types of routing:
ü Static routing
ü Dynamic routing
The router learns about remote networks from neighbor routers or from an administrator. The
router then builds a routing table. If the network is directly connected then the router already
knows how to get to the network. If the networks are not attached, the router must learn how to
get to the remote network with either static routing (administrator manually enters the routes in
the router's table) or dynamic routing (happens automatically using routing protocols like
EIGRP,OSPF,etc.).
The routers then update each other about all the networks they know. If a change occurs
e.g a router goes down, the dynamic routing protocols automatically inform all routers about
the change. If static routing is used, then the administrator has to update all changes into all
routers and therefore no routing protocol is used.
Static routing
Static routing is a type of network routing technique. Static routing is not a routing protocol;
instead, it is the manual configuration and selection of a network route, usually managed by the
network administrator. It is employed in scenarios where the network parameters and
environment are expected to remain constant.
Static routing is only optimal in a few situations. Network degradation, latency and congestion
are inevitable consequences of the non-flexible nature of static routing because there is no
adjustment when the primary route is unavailable
Result:
Conclusion:
Build a simple network topology and configure it for static routing protocol using packet tracer.
Viva questions:
1. What is routing?
Routing is the process of selecting a path for traffic in a network or between or across
multiple networks.
THEORY:
When enabled, the Network Discovery method gathers information about devices on your
network, like the other discovery methods that are available in SMS do. However, the Network
Discovery method is unique because, besides computers, it also finds network devices such as
printers, routers, and bridges. Basically, the Network Discovery method finds any device on the
network that has an IP address.
You can configure Network Discovery to discover resources in subnets, domains, and
Simple Network Management Protocol (SNMP) devices. If the site is configured with standard
security, you can also configure Network Discovery to discover resources in Microsoft Dynamic
Host Configuration Protocol (DHCP) servers. You can configure Network Discovery to find
routers in an ordered list of community names and specify the maximum number of hops within
which to find routers.
The Network Discovery method can be used to:
Discover potential SMS clients.
Collect resource discovery data so that the Client Push Installation method can later install
client components on those resources.
Gather data so that Network Trace can display a detailed map that includes SMS sites and
the connections between SMS primary site servers and other site systems.
Collect resource information that you can later use for collections, reports, and queries.
MRTG
The Multi Router Traffic Grapher (MRTG) is an open source tool used to monitor the traffic load
on network links. James Kretchmar tells us how MRTG produces Web pages containing PNG
images, which provide a live visual representation of this traffic.
MRTG produces Web pages that display graphs of bandwidth use on network links on
daily, weekly, monthly, and yearly scales. This can be an invaluable tool for diagnosing network
problems because it not only indicates the current status of the network but also lets you visually
compare this with the history of network utilization.
Result:
Conclusion:
Successfully performed network discovery using mrtg tool.
Viva questions:
2. What is mrtg?
The Multi Router Traffic Grapher (MRTG) is a tool to monitor the traffic load on network-links.
MRTG generates HTML pages containing GIF images which provide a LIVE visual representation
of this traffic.
Gets its data via an SNMP agent, or through the output of a command line.
Typically collects data every five minutes (it can be configured to collect data less frequently).
Creates an HTML page per target that features four graphs (GIF or PNG images).
Results are plotted vs time into day, week, month and year graphs, with the I plotted as a full green area,
and the O as a blue line.
Automatically scales the Y axis of the graphs to show the most detail.
Can also send warning emails if targets have values above a certain threshold.
THEORY:
Wireshark :
Wireshark is a free and open source packet analyzer. It is used for network troubleshooting,
analysis, software and communications protocol development, and education. Originally named
Ethereal, the project was renamed Wireshark in May 2006 due to trademark issues.
Ethernet layer:
The Ethernet physical layer is the physical layer component of the Ethernet family of computer
network standards. The Ethernet physical layer evolved over a considerable time span and
encompasses quite a few physical media interfaces and several magnitudes of speed.
Network layer:
The network layer provides the means of transferring variable-length network packets from a
source to a destination host via one or more networks. Within the service layering semantics of
the OSI network architecture, the network layer responds to service requests from the transport
layer and issues service requests to the data link layer.
Transport layer:
The transport layer is a conceptual division of methods in the layered architecture of protocols in
the network stack in the Internet Protocol Suite and the Open Systems Interconnection (OSI)
reference model. The protocols of this layer provide host-to-host communication services for
applications. It provides services such as connection-oriented communication, reliability, flow
control, and multiplexing.
The details of implementation and semantics of the transport layer of the TCP/IP model,
which is the foundation of the Internet, and the OSI model of general networking are different.
The protocols in use today in this layer for the Internet all originated in the development of
TCP/IP. In the OSI model the transport layer is often referred to as Layer 4, or L4, while
numbered layers are not used in TCP/IP.
Application layer:
Application layer is the top most layer in OSI and TCP/IP layered model. This layer exists in
both layered Models because of its significance, of interacting with user and user applications.
This layer is for applications which are involved in communication system.
Result:
Frame
IP Status
Conclusion:
Understanded operation if TCP/IP using wireshark.
Viva Questions:
1. Write different protocols of Physical layer.
Digital Subscriber Line.
Integrated Services Digital Network.
Infrared Data Association.
Universal Serial Bus (USB.)
Bluetooth.
Controller Area Network.
Ethernet.
Aim: Study of Stop and wait protocol/ sliding window (selective repeat / Go back N )
THEORY:
Stop-n-Wait Protocol:
"Stop-n-wait" (sometimes known as "positive acknowledgement with retransmission") is the
fundamental technique to provide reliable transfer under unreliable packet delivery system.
In this method of flow control, the sender sends a single frame to receiver & waits for an
acknowledgment.
• The next frame is sent by sender only when acknowledgment of previous frame is received.
• This process of sending a frame & waiting for an acknowledgment continues as long as the
sender has data to send.
• To end up the transmission sender transmits end of transmission (EOT) frame.
Go-Back-n protocol:
Go-Back-N protocol is a sliding window protocol. It is a mechanism to detect and control the
error in datalink layer. During transmission of frames between sender and receiver, if a frame is
damaged, lost, or an acknowledgement is lost then the action performed by sender and receiver is
explained in the following content.
Result:
Go-Back-n protocol:
Conclusion:
Studied of Stop and wait protocol/ sliding window (selective repeat / Go back N )
Viva Questions:
1. What is the difference between go-back-n and selective repeat protocol?
The main difference between these two protocols is that after finding the suspect or damage in
sent frames go-back-n protocol re-transmits all the frames whereas selective repeat protocol
re-transmits only that frame which is damaged
Disadvantages :
data blocks may be received out of order, such that some reordering is required at the receiver side,
before the blocks can be delivered to their destination.
Aim:
a. Set up multiple IP addresses on a single LAN.
b. Using nestat and route commands of Linux
View current routing table
Add and delete routes
Change default gateway
c. Perform packet filtering by enabling IP forwarding using IPtables in Linux
THEORY:
4. If you use DHCP, you should disable it: click Use the following IP address and enter IP
address, Subnet mask and Default gateway.
5. Click Advanced... at the bottom.
5. Enter additional IP addresses: click the Add... button and enter a new IP address and
Subnet mask.
If you use Windows XP, the whole procedure will be the same, except for the first steps:
Right-click on My Network Places, choose Properties.
Right-click on the Local Area Connection, choose Properties.
Other steps are the same as for Windows Vista.
Packet filtering
packet filtering is the process of passing or blocking packets at a network interface based on
source and destination addresses, ports, or protocols. The process is used in conjunction with
packet mangling and Network Address Translation (NAT). Packet filtering is often part of a
firewall program for protecting a local network from unwanted intrusion.
Result:
Conclusion:
Successfully performed packet filtering by enabling IP forwarding using IP tables in Linux
Viva Questions:
1. What is NAT?
NAT stands for network address translation. It's a way to map multiple local private addresses to a public
one before transferring the information.
To remove static route type this command: route delete 0.0.0.0 mask 0.0.0.0 192.168.95.1
The route command allows you to make manual entries into the network routing tables. The route
command distinguishes between routes to hosts and routes to networks by interpreting the network
address of the Destination variable, which can be specified either by symbolic name or numeric address.
Ex. No. 8.
Socket programming using TCP or UDP
Date:
Server side
#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>
int main(){
int welcomeSocket, newSocket;
char buffer[1024];
struct sockaddr_in serverAddr;
struct sockaddr_storage serverStorage;
socklen_t addr_size;
/*---- Create the socket. The three arguments are-----*/
/* 1) Internet domain 2) Stream socket 3) Default protocol (TCP in this case) */
welcomeSocket = socket(PF_INET, SOCK_STREAM, 0);
/*---- Configure settings of the server address struct----*/
/* Address family = Internet */
serverAddr.sin_family = AF_INET;
/* Set port number, using htons function to use proper byte order */
serverAddr.sin_port = htons(7891);
GVAIET/NBA-2013/CRITERIA 7.2/T-LP/COMP/TE/SEM-V/LAB MANUAL/CN/2018/REV.1/1.7.2018 Page 49
\ G.V.ACHARYA INSTITUTE OF ENGINEERING AND TECHNOLOGY, SHELU
serverAddr.sin_addr.s_addr = inet_addr("127.0.0.1");
/* Set all bits of the padding field to 0 */
memset(serverAddr.sin_zero, '\0', sizeof serverAddr.sin_zero);
/*---- Bind the address struct to the socket----*/
bind(welcomeSocket, (struct sockaddr *) &serverAddr, sizeof(serverAddr));
/*---- Listen on the socket, with 5 max connection requests queued ----
*/ if(listen(welcomeSocket,5)==0)
printf("Listening\n");
else
printf("Error\n");
/*---- Accept call creates a new socket for the incoming connection----*/
addr_size = sizeof serverStorage;
newSocket = accept(welcomeSocket, (struct sockaddr *) &serverStorage, &addr_size);
/*---- Send message to the socket of the incoming connection----*/
strcpy(buffer,"Hello World\n");
send(newSocket,buffer,13,0);
return 0;
}
Client Code
Result
Conclusion :
In this practical, learned socket programming using TCP and UDP.
Viva Questions
Server :- A server is a computer or system that provides resources, data, services, or programs to
other computers, known as clients, over a network. In theory, whenever computers share resources
with client machines they are considered servers.
Ex. No. 9.
Perform File Transfer and Access using FTP
Date:
THEORY:
Result:
Conclusion:
Successfully transfer the file and access it using FTP.
Viva Questions
1. What is FTP?
FTP stands for File transfer protocol. FTP is a standard internet protocol provided by TCP/IP used for
transmitting the files from one host to another.
THEORY:
Telnet Server:
Telnet is a protocol that allows you to connect to remote computers (called hosts) over
a TCP/IP network (such as the internet). Using telnet client software on your computer, you can
make a connection to a telnet server (i.e., the remote host). Once your telnet client establishes a
connection to the remote host, your client becomes a virtual terminal, allowing you to
communicate with the remote host from your computer. In most cases, you'll need to log into the
remote host, which requires that you have an account on that system. Occasionally, you can log
in as guest or public without having an account.
Telnet clients are available for all major operating systems.
Command-line telnet clients are built into most versions of macOS, Windows, Unix,
and Linux. To use these clients, go to their respective command lines (i.e., the Terminal
application in macOS, the shell in Unix or Linux, or the DOSprompt in Windows), and then
enter:
telnet host port
Result:
Conclusion:
Performed Remote login using Telnet server
Viva Questions:
1. What is telnet?
Telnet stands for terminal network. It is a type of protocol that enables one computer to connect
to local computer. It is a used as a standard TCP/IP protocol.
5. When starting a 5250 full-screen mode session, the following optional parameters are also
applicable: