0% found this document useful (0 votes)
44 views81 pages

CN Lab Manual

Uploaded by

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

CN Lab Manual

Uploaded by

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

G.M.

Vedak Institute of Technology, Tala – 402411

Department of Computer Engineering


Vision
The vision of the Computer Department is to produce versatile computer engineers, capable
of adapting to the changing needs of industry and society.

Mission
 To nurture good infrastructure and innovative teaching learning environment.
 To facilitate the development of academia-industry collaboration programs to meet the
changing needs of industry and society.
 To involve students as well as faculties in research and development to meet the
requirements of software industry.
 To boost students to succeed in industry, government and academia.
 To identify real life problems and provide solutions which are economically feasible as
well as socially acceptable.

LAB
MANUAL
Computer Network Lab
G.M.Vedak Institute of Technology, Tala – 402411
CSL 502
Computer Network Lab

Description:

Design and implementation of any case study/ applications /experiments /


mini project based on departmental level courses using modern tools.

Term work:

The distribution of marks for term work shall be as follows: Lab/


Experimental Work: 15 Marks

Attendance (Theory & Practical): 05 Marks

Assignments: 05- Marks

Practical & Oral:

Examination is to be conducted based on respective departmental


level courses by pair of internal and external examiners appointed
by the University of Mumbai.
G.M.Vedak Institute of Technology, Tala – 402411
Lab Objectives and Outcome

Lab Objectives:
1 To practically explore OSI layers and understand the usage of simulation tools.
2 To analyze, specify and design the topological and routing strategies for an
IP based networking infrastructure.
3 To identify the various issues of a packet transfer from source to destination,
and how they are resolved by the various existing protocols.

Lab Outcomes: On successful completion of lab, learner will be able to

1 Design and setup networking environment in Linux.


2 Use Network tools and simulators such as NS2, Wireshark etc. to explore
networking algorithms and protocols.
3 Implement programs using core programming APIs for understanding networking
concepts.
List of Experiment
Subject: - Computer Network Laboratory (CSL 502)

Semester: - V

SR.
TITLE OF EXPERIMENT PAGE NO.
NO.
1 Use of Crimping Tool for RJ45 01 – 03
2 Use basic networking commands in Linux (ping, tracert, nslookup, 04 – 08
netstat, ARP, RARP, ip, ifconfig, dig, route ).
3 Build a simple network topology and configure it for static routing 09
protocol using packet tracer. Setup a network and configure IP
addressing, subnetting, masking.
4 Perform network discovery using discovery tools (eg. Nmap, mrtg) 10 – 12
5 Use Wire shark to understand the operation of TCP/IP layers: 13 – 18
● Ethernet Layer: Frame header, Frame size etc.
● Data Link Layer: MAC address, ARP (IP and MAC
address binding)
● Network Layer: IP Packet (header, fragmentation), ICMP
(Query and Echo)
● Transport Layer: TCP Ports, TCP handshake segments etc.
● Application Layer: DHCP, FTP, HTTP header formats
6 Use simulator (Eg. NS2) to understand functioning of ALOHA, 19 – 23
CSMA/CD
7 a. Set up multiple IP addresses on a single LAN. 24 – 27
b. Using nestat and route commands of Linux, do the following:
● View current routing table
● Add and delete routes
● Change default gateway
Perform packet filtering by enabling IP forwarding using IP tables
in Linux.
8 Study and Installation of Network Simulator (NS3) 28 – 31
9 Design VPN and Configure RIP/OSPF using Packet tracer. 32 – 50

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2021-22)
List of Experiment
Subject: - Computer Network Laboratory (CSL 502)

Semester: - V

SR.
TITLE OF EXPERIMENT PAGE NO.
NO.
10 Java program for Socket Programming 51 – 53
11 Perform File Transfer and Access using FTP 54 – 61
12 Perform Remote login using Telnet server 62 – 69
13 Some questions and answers. 70 – 75

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2021-22)
List of Experiment
Subject: - Computer Network Laboratory (CSL 502)

Semester: - V

SR.
TITLE OF EXPERIMENT PAGE NO. SOFTWARE
NO.
1 Use of Crimping Tool for RJ45 01 – 03 --
2 Use basic networking commands in Linux (ping, 04 – 08 --
tracert, nslookup, netstat, ARP, RARP, ip,
ifconfig, dig, route ).
3 Build a simple network topology and configure 09 Packet Tracer
it for static routing protocol using packet tracer.
4 Perform network discovery using discovery 10 – 12 Nmap
tools (eg. Nmap, mrtg
5 Use Wireshark to understand the operation of 13 – 18 Wireshark
TCP/IP layers:
6 Use simulator (Eg. NS2) to understand 19 – 23 NS2
functioning of ALOHA, CSMA/CD.
7 Set up multiple IP addresses on a single LAN. 24 – 27 --
Using nestat and route commands of Linux.
8 Study and Installation of Network Simulator 28 – 31 NS3
(NS3)
9 Design VPN and Configure RIP/OSPF using 32 – 50 Packet Tracer
Packet tracer.
10 Java program for Socket Programming 51 – 53 Java
11 54 – 61 Auto FTP
Perform File Transfer and Access using FTP
Manager
12 Perform Remote login using Telnet server 62 – 69 RHEL 6

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2021-22)
CSL 502: COMPUTER NETWORK LABORATORY

EXPERIMENT NO. 1

AIM:- Use of Crimping Tool for RJ45.


THEORY:- Crimping an RJ45 Connector
Correctly Proper Wiring for
Ethernet Cat5/Cat5e/Cat 6 Cables.
Your cable run needs to terminate
into a connector, and that connector
needs a jack to plug into.
Registered Jack 45 (RJ45) is a
standard type of physical connector
for network cables. RJ45 connectors
are commonly seen with Ethernet
cables and networks.
Modern Ethernet cables feature a
small plastic plug on each end of the
cable. That plug is inserted into RJ45
jacks of Ethernet devices. The term
“plug” refers to the cable or “male”
end of the connection while the term
“jack” refers to the port or “female”
end.
T568A and T568B are the two colour
codes used for wiring eight-position
modular plugs. Both are allowed
under the ANSI/TIA/EIA wiring
standards. The only difference
between the two color codes is that
the orange and green pairs are
interchanged.
There is no transmission difference
between T568A and T568B cabling
schemes. North America’s preference
is for T568B. Both ends must use the
same standard. It makes no difference
to the transmission characteristics of
data.
T568B wiring pattern is recognized
as the preferred wiring pattern.
STEP 1: Using a Crimping Tool, trim the end
of the cable you're terminating, to
ensure that the ends of the conducting
wires are even.

STEP 2: Being careful not to damage the inner


conducting wires, strip off
approximately 1 inch of the cable's
jacket, using a modular crimping tool
or a UTP cable stripper.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 1/75
CSL 502: COMPUTER NETWORK LABORATORY

STEP 3: Separate the 4 twisted wire pairs from


each other, and then unwind each
pair, so that you end up with 8
individual wires. Flatten the wires out
as much as possible, since they'll
need to be very straight for proper
insertion into the connector.
STEP 4: Holding the cable with the wire ends
facing away from you. Moving from
left to right, arrange the wires in a
flat, side-by-side ribbon formation,
placing them in the following order:
white/orange, solid orange,
white/green, solid blue, white/blue,
solid green, white/brown, solid
brown.
STEP 5: Holding the RJ45 connector so that
its pins are facing away from you and
the plug-clip side is facing down,
carefully insert the flattened, arranged
wires into the connector, pushing
through until the wire ends emerge
from the pins. For strength of
connection, also push as much of the
cable jacket as possible into the
connector.
STEP 6: Check to make sure that the wire ends
coming out of the connector's pin side
are in the correct order; if not, remove
them from the connector, rearrange
into proper formation, and re-insert.
Remember, once the connector is
crimped onto the cable, it's
permanent. If you realize that a
mistake has been made in wire order
after termination, you'll have to cut
the connector off and start all over
again!
STEP 7: Insert the prepared connector/cable
assembly into the RJ45 slot in your
crimping tool. Firmly squeeze the
crimper's handles together until you
can't go any further. Release the
handles and repeat this step to ensure
a proper crimp.
STEP 8: If your crimper doesn't automatically
trim the wire ends upon termination,
carefully cut wire ends to make them
as flush with the connector's surface
as possible. The closer the wire ends
are trimmed, the better your final
plug-in connection will be.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 2/75
CSL 502: COMPUTER NETWORK LABORATORY

STEP 9: After the first termination is


complete, repeat process on the
opposite end of your cable.

CONCLUSION:- Use of Crimping Tool for RJ45.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 3/75
CSL 502: COMPUTER NETWORK LABORATORY

EXPERIMENT NO. 2

AIM:- Use basic networking commands in Linux (ping, tracert, nslookup, netstat,
ARP, RARP, ip, ifconfig, dig, route ).
THEORY:- ifconfig
ifconfig(interface configuration) command is used to configure the kernel-resident network
interfaces. It is used at the boot time to set up the interfaces as necessary. After that, it is
usually used when needed during debugging or when you need system tuning. Also, this
command is used to assign the IP address and netmask to an interface or to enable or disable a
given interface.

nslookup
nslookup (stands for “Name Server Lookup”) is a useful command for getting information
from DNS server. It is a network administration tool for querying the Domain Name System
(DNS) to obtain domain name or IP address mapping or any other specific DNS record. It is
also used to troubleshoot DNS related problems.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 4/75
CSL 502: COMPUTER NETWORK LABORATORY

ping
(Packet Internet Groper) command is used to check the network connectivity
between host and server/host. This command takes as input the IP address or the URL and sends
a data packet to the specified address with the message “PING” and get a response from the
server/host this time is recorded which is called latency. Fast ping low latency means faster
connection. Ping uses ICMP(Internet Control Message Protocol) to send an ICMP echo
message to the specified host if that host is available then it sends ICMP reply message. Ping
is generally measured in millisecond every modern operating system has this ping pre-installed.

traceroute
Traceroute command in Linux prints the route that a packet takes to reach the host. This
command is useful when you want to know about the route and about all the hops that a
packet takes. Below image depicts how traceroute command is used to reach the
Google(172.217.26.206) host from the local machine and it also prints detail about all the
hops that it visits in between.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 5/75
CSL 502: COMPUTER NETWORK LABORATORY

netstat
netstat command in Linux prints the route that a packet takes to reach the host. This
command is useful when you want to know about the route and about all the hops that a
packet takes. Below image depicts how traceroute command is used to reach the
Google(172.217.26.206) host from the local machine and it also prints detail about all the
hops that it visits in between.

arp
arp command manipulates the System’s ARP cache. It also allows a complete dump of the
ARP cache. ARP stands for Address Resolution Protocol. The primary function of this
protocol is to resolve the IP address of a system to its mac address, and hence it works
between level 2(Data link layer) and level 3(Network layer).

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 6/75
CSL 502: COMPUTER NETWORK LABORATORY

ip
ip command in Linux is present in the net-tools which is used for performing several
network administration tasks. IP stands for Internet Protocol. This command is used to show
or manipulate routing, devices, and tunnels. It is similar to ifconfig command but it is much
more powerful with more functions and facilities attached to it. ifconfig is one of the
deprecated commands in the net-tools of Linux that has not been maintained for many years.
ip command is used to perform several tasks like assigning an address to a network interface
or configuring network interface parameters.
It can perform several other tasks like configuring and modifying the default and static
routing, setting up tunnel over IP, listing IP addresses and property information, modifying
the status of the interface, assigning, deleting and setting up IP addresses and routes

dig
dig command for Domain Information Groper. It is used for retrieving information about
DNS name servers. It is basically used by network administrators. It is used for verifying and
troubleshooting DNS problems and to perform DNS lookups. Dig command replaces older
tools such as nslookup and the host.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 7/75
CSL 502: COMPUTER NETWORK LABORATORY

CONCLUSION:- Hence, in this experiment, we have successfully studied some


important networking command and also implemented them in Linux.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 8/75
CSL 502: COMPUTER NETWORK LABORATORY

EXPERIMENT NO. 3

AIM:- Build a simple network topology and configure it for static routing protocol
using packet tracer. Setup a network and configure IP addressing, subnetting,
masking.
THEORY:- Cisco 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.
STEPS:- 1. Pick a total of 4 pcs in the packet tracer application.
2. We need 2 routers.
3. We need a single router.
4. Give the appropriate IP addresses to the pcs accordingly.
5. Test the network with the help of packets.

CONCLUSION:- Hence we have successfully created simple network using CISCO


PACKET TRACER.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 9/75
CSL 502: COMPUTER NETWORK LABORATORY

EXPERIMENT NO. 4

AIM:- Perform network discovery using discovery tools (eg. nmap, mrtg)
THEORY:- nmap (Network Mapper) is a security scanner originally written by Gordon Lyon (also known
by his pseudonym Fyodor Vaskovich) used to discover hosts and services on a computer
network, thus creating a "map" of the network. To accomplish its goal, Nmap sends specially
crafted packets to the target host and then analyzes the responses. Unlike many simple port
scanners that just send packets at some predefined constant rate, Nmap accounts for the network
conditions (latency fluctuations, network congestion, the target interference with the scan)
during the run. Also, owing to the large and active user community providing feedback and
contributing to its features, Nmap has been able to extend its discovery capabilities beyond
simply figuring out whether a host is up or down and which ports are open and closed; it can
determine the operating system of the target, names and versions of the listening services,
estimated uptime, type of device, and presence of a firewall.

nmap features include:


• Host Discovery – Identifying hosts on a network. For example, listing the hosts which
respond to pings or have a particular port open.

• Port Scanning – Enumerating the open ports on one or more target hosts.
• Version Detection – Interrogating listening network services listening on remote
devices to determine the application name and version number.

• OS Detection – Remotely determining the operating system and some hardware


characteristics of network devices.

Basic commands working in nmap:


 For target specifications: nmap <target‘s URL or IP with spaces between them>
 For OS detection: nmap -O <target-host's URL or IP>
 For version detection: nmap -sV <target-host's URL or IP>
SYN scan is the default and most popular scan option for good reasons. It can be performed
quickly, scanning thousands of ports per second on a fast network not hampered by restrictive
firewalls. It is also relatively unobtrusive and stealthy since it never completes TCP
connections.
Algorithm\Implementation Steps\Installation Steps:
1. Download Nmap from www.nmap.org and install the Nmap Software with WinPcap
Driver utility.
2. Execute the Nmap-Zenmap GUI tool from Program Menu or Desktop Icon
3. Type the Target Machine IP Address(ie.Guest OS or any website Address)
4. Perform the profiles shown in the utility.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 10/75
CSL 502: COMPUTER NETWORK LABORATORY

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 11/75
CSL 502: COMPUTER NETWORK LABORATORY

CONCLUSION:- Thus, we have studied different options to scan ports in nmap.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 12/75
CSL 502: COMPUTER NETWORK LABORATORY

EXPERIMENT NO. 5

AIM:-
Use Wire shark to understand the operation of TCP/IP layers:
● Ethernet Layer: Frame header, Frame size etc.
● Data Link Layer: MAC address, ARP (IP and MAC address binding)
● Network Layer: IP Packet (header, fragmentation), ICMP (Query and
Echo)
● Transport Layer: TCP Ports, TCP handshake segments etc.
Application Layer: DHCP, FTP, HTTP header formats.
THEORY:- Wireshark, a network analysis tool formerly known as Ethereal, captures packets in real time
and display them in human-readable format. Wireshark includes filters, color coding, and other
features that let you dig deep into network traffic and inspect individual packets.

Capturing Packets
After downloading and installing Wireshark, you can launch it and double-click the name of a
network interface under Capture to start capturing packets on that interface. For example, if you
want to capture traffic on your wireless network, click your wireless interface. You can
configure advanced features by clicking Capture > Options, but this isn’t necessary for now.
As soon as you click the interface’s name, you’ll see the packets start to appear in real time.
Wireshark captures each packet sent to or from your system.
If you have promiscuous mode enabled—it’s enabled by default—you’ll also see all the other
packets on the network instead of only packets addressed to your network adapter. To check if
promiscuous mode is enabled, click Capture > Options and verify the “Enable promiscuous
mode on all interfaces” checkbox is activated at the bottom of this window.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 13/75
CSL 502: COMPUTER NETWORK LABORATORY

Click the red “Stop” button near the top left corner of the window when you want to stop
capturing traffic.

Color Coding
You’ll probably see packets highlighted in a variety of different colors. Wireshark uses colors to
help you identify the types of traffic at a glance. By default, light purple is TCP traffic, light
blue is UDP traffic, and black identifies packets with errors—for example, they could have been
delivered out of order.
To view exactly what the color codes mean, click View > Coloring Rules. You can also
customize and modify the coloring rules from here, if you like,

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 14/75
CSL 502: COMPUTER NETWORK LABORATORY

Sample Captures
If there’s nothing interesting on your own network to inspect, Wireshark’s wiki has you
covered. The wiki contains a page of sample capture files that you can load and inspect. Click
File > Open in Wireshark and browse for your downloaded file to open one.
You can also save your own captures in Wireshark and open them later. Click File > Save to
save your captured packets.

Filtering Packets
If you’re trying to inspect something specific, such as the traffic a program sends when phoning
home, it helps to close down all other applications using the network so you can narrow down
the traffic. Still, you’ll likely have a large amount of packets to sift through. That’s where
Wireshark’s filters come in.
The most basic way to apply a filter is by typing it into the filter box at the top of the window
and clicking Apply (or pressing Enter). For example, type “dns” and you’ll see only DNS
packets. When you start typing, Wireshark will help you auto complete your filter.

You can also click Analyze > Display Filters to choose a filter from among the default filters
included in Wireshark. From here, you can add your own custom filters and save them to easily
access them in the future.
For more information on Wireshark’s display filtering language, read the Building display filter
expressions page in the official Wireshark documentation.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 15/75
CSL 502: COMPUTER NETWORK LABORATORY

Another interesting thing you can do is right-click a packet and select Follow > TCP Stream.
You’ll see the full TCP conversation between the client and the server. You can also click other
protocols in the Follow menu to see the full conversations for other protocols, if applicable.

Close the window and you’ll find a filter has been applied automatically. Wireshark is showing
you the packets that make up the conversation.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 16/75
CSL 502: COMPUTER NETWORK LABORATORY

Inspecting Packets
Click a packet to select it and you can dig down to view its details.

You can also create filters from here — just right-click one of the details and use the Apply as
Filter submenu to create a filter based on it.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 17/75
CSL 502: COMPUTER NETWORK LABORATORY

Wireshark is an extremely powerful tool, and this tutorial is just scratching the surface of what
you can do with it. Professionals use it to debug network protocol implementations, examine
security problems and inspect network protocol internals.

CONCLUSION:- Thus, we have studied the working of Wire Shark.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 18/75
CSL 502: COMPUTER NETWORK LABORATORY

EXPERIMENT NO. 6

AIM:- Use simulator (Eg. NS2) to understand functioning of ALOHA, CSMA/CD.


THEORY:- I. Install Linux
II. Install NS2
III. Set Environmental variables
IV. Validation
V. Run the First nam

I. INSTALL LINUX (UBUNTU 8.10)


First of all, get the Linux OS image or CD. You can get it for free from Linux website 2. If you
are a windows user, then you have to download Linux in a separate partition, or use a virtual
machine. My advice to you is to use a virtual machine. One of the best virtual machine SW is
Vmware. There are bunch of alternative Free SW to create Virtual machines, one of them is
Virtual Box.
II. INSTALL NS2
1. Download the NS2 files from the Internet http://sourceforge.net/projects/nsnam/files/ns-
2/2.34/
2. Extract the files
3. Put the files in the Home folder.

4. Set the appropriate permissions for the ns-allinone-2.34 to allow executing the files
inside it. To do that: Right click the folder -> Properties -> Permissions , and choose the
appropriate group with the appropriate file access, then click "Allow executing file as
program" and then click "Apply permissions to enclosed files".

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 19/75
CSL 502: COMPUTER NETWORK LABORATORY

5. From the Accessories -> Terminal


6. Type the following command to know in which directory you are: ~$ pwd

7. You need to be in the directory where you placed the ns-allinone-2.34 folder
8. If you are not in the /home/e , then move to it by using the command cd
9. Now, supposing you are in the directory /home/e (e can be any other user) type the
following command to move inside the ns-allinone-2.34 using the command cd $ cd ns-
allinone-2.34
10. Then, type the following command (you will be asked to enter the system password to
process. Also, you will be asked if you want to continue, type: y to continue): $ sudo
apt-get install build-essential autoconf automake libxmu-dev.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 20/75
CSL 502: COMPUTER NETWORK LABORATORY

11. Type the following command to install NS2 $ ./install.


III. SET ENVIRONMENTAL VARIABLES
1. Write the following line: gedit ~/.bashrc.
2. After the previous command, a file will open to you. Add the following lines to the end of
the file. Replace "/your/path" by the folder where you placed the extracted ns-allinone-
2.34 (For example, if your Linux user name is e, and you placed the ns-allinone-2.34 in
the home directory, you have to change /your/path to /home/e)
# LD_LIBRARY_PATH OTCL_LIB=/your/path/ns-allinone-2.34/otcl-1.13
NS2_LIB=/your/path/ns-allinone-2.34/lib X11_LIB=/usr/X11R6/lib
USR_LOCAL_LIB=/usr/local/lib export
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OTCL_LIB:$NS2_LIB:$X11_LIB:$U
SR_LOCAL_LIB
# TCL_LIBRARY TCL_LIB=/your/path/ns-allinone-2.34/tcl8.4.18/library
USR_LIB=/usr/lib export TCL_LIBRARY=$TCL_LIB:$USR_LIB
# PATH XGRAPH=/your/path/ns-allinone-2.34/bin:/your/path/ns-
allinone2.34/tcl8.4.18/unix:/your/path/ns-allinone-2.34/tk8.4.18/unix NS=/your/path/ns-
allinone-2.34/ns-2.34/ NAM=/your/path/ns-allinone-2.34/nam-1.14/
PATH=$PATH:$XGRAPH:$NS:$NAM.
3. Save the file changes after your edit.
4. Ensure that it immediately takes effect: $ source ~/.bashrc
Note: the previous step is important; else you cannot successfully run ns-2.
5. Now, the installation has been completed. Try: $ ns 6. The "%" symbol appears on the
screen. Type "exit" to quit.
IV. VALIDATION
1. To run the ns validation suite: $ cd ns-2.34 $ ./validate.
2. The validation will take long time, wait until it finish.
V. RUN YOUR FIRST NAM EXAMPLE
1. From the terminal type the following: $ cd ns-allinone-2.34 $ cd nam-1.14 $ cd edu $ exec
nam A2-stop-n-wait-loss.nam.
2. The following window appears, click the Play button to see the protocol animation.
Input for Sample 1: Node 1 transmits data to Node.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 21/75
CSL 502: COMPUTER NETWORK LABORATORY

Simulation Time - 10 Seconds


(Note: The Simulation Time can be selected only after doing the following two tasks: Set the
properties of Nodes and then click on the Simulate button).
Input for Sample 2: Node 1 transmits data to Node 2, Node 2 transmits data to
Node 1.

Simulation Time - 10 Seconds


(Note: The Simulation Time can be selected only after doing the following two tasks: Set the
properties of Nodes and Then click on the Simulate button).
Experiment 1: Node 1 transmits data to Node 2. Experiment 1: Node 1 transmits data to Node 2.
Experiment 2: Node 1 transmits data to Node 2, and Node 2 transmits data to Node 1.
Experiment 3: Node 1 transmits data to Node 2, and Node 2 transmits data to Node 3, and Node
3 transmits data to Node 1.
And so on do the experiment by increasing the number of nodes generating traffic as 4, 5, 7, 9,
10, 15, 20 22 and 24 nodes.
Simulation Time - 10 Seconds
(Note: The Simulation Time can be selected only after doing the following two tasks: Set the
properties of Nodes and then click on the Simulate button).

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 22/75
CSL 502: COMPUTER NETWORK LABORATORY

We have obtained the following characteristic plot for the Slotted ALOHA, which matches the
theoretical result.

CONCLUSION:- Thus, we have studied and successfully understand functioning of


ALOHA.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 23/75
CSL 502: COMPUTER NETWORK LABORATORY

EXPERIMENT NO. 7

AIM:- a. Set up multiple IP addresses on a single LAN.


b. Using nestat and route commands of Linux, do the following:
● View current routing table
● Add and delete routes
● Change default gateway
Perform packet filtering by enabling IP forwarding using IP tables in
Linux.
THEORY:- a. First, let us find the IP address of the network card. In my Ubuntu 15.10 server, I use
only one network card.
Run the following command to find out the IP address:
sudo ip addr

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN


group default

link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

inet 127.0.0.1/8 scope host lo

valid_lft forever preferred_lft forever

inet6 ::1/128 scope host

valid_lft forever preferred_lft forever

2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast


state UP group default qlen 1000

link/ether 08:00:27:2a:03:4b brd ff:ff:ff:ff:ff:ff

inet 192.168.1.103/24 brd 192.168.1.255 scope global enp0s3

valid_lft forever preferred_lft forever

inet6 fe80::a00:27ff:fe2a:34e/64 scope link

valid_lft forever preferred_lft forever


Or

sudo ifconfig

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 24/75
CSL 502: COMPUTER NETWORK LABORATORY

Sample output:

enp0s3 Link encap:Ethernet HWaddr 08:00:27:2a:03:4b

inet addr:192.168.1.103 Bcast:192.168.1.255 Mask:255.255.255.0

inet6 addr: fe80::a00:27ff:fe2a:34e/64 Scope:Link

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:186 errors:0 dropped:0 overruns:0 frame:0

TX packets:70 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:21872 (21.8 KB) TX bytes:9666 (9.6 KB)

lo Link encap:Local Loopback

inet addr:127.0.0.1 Mask:255.0.0.0

inet6 addr: ::1/128 Scope:Host

UP LOOPBACK RUNNING MTU:65536 Metric:1

RX packets:217 errors:0 dropped:0 overruns:0 frame:0

TX packets:217 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0

RX bytes:38793 (38.7 KB) TX bytes:38793 (38.7 KB)


As you see in the above output, my network card name is enp0s3, and its IP address
is 192.168.1.103.

Now let us add an additional IP address, for example 192.168.1.104, to the Interface

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 25/75
CSL 502: COMPUTER NETWORK LABORATORY

card.

Open your Terminal and run the following command to add additional IP.

sudo ip addr add 192.168.1.104/24 dev enp0s3


Now, let us check if the IP is added using command:

sudo ip address show enp0s3


Sample output:

2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast


state UP group default qlen 1000

link/ether 08:00:27:2a:03:4e brd ff:ff:ff:ff:ff:ff

inet 192.168.1.103/24 brd 192.168.1.255 scope global enp0s3

valid_lft forever preferred_lft forever

inet 192.168.1.104/24 scope global secondary enp0s3

valid_lft forever preferred_lft forever

inet6 fe80::a00:27ff:fe2a:34e/64 scope link

valid_lft forever preferred_lft forever


Similarly, you can add as many IP addresses as you want.

Let us ping the IP address to verify it.

sudo ping 192.168.1.104

Sample output:

PING 192.168.1.104 (192.168.1.104) 56(84) bytes of data.

64 bytes from 192.168.1.104: icmp_seq=1 ttl=64 time=0.901 ms

64 bytes from 192.168.1.104: icmp_seq=2 ttl=64 time=0.571 ms

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 26/75
CSL 502: COMPUTER NETWORK LABORATORY

64 bytes from 192.168.1.104: icmp_seq=3 ttl=64 time=0.521 ms

64 ytes from 192.168.1.104: icmp_seq=4 ttl=64 time=0.524 ms

b. To check the routing table

Command: nestat -rn

$ netstat -rn

Kernel IP routing table

Destination Gateway Genmask Flags MSS Window irtt Iface

0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 wlan0

192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 wlan0

Adding route

sudo route add -net 192.168.3.0 gw 192.168.1.1 netmask 255.255.255.0 dev eth0

Deleting route

sudo route del -net 192.168.3.0 gw 192.168.1.1 netmask 255.255.255.0 dev eth0

A quick way to add default route

route add default gw 192.168.1.1

A quick way to delete defualt route

route del default gw 192.168.1.1

CONCLUSION:- Thus, we have studied and successfully add the multiple IP address and
also perform actions in Linux.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 27/75
CSL 502: COMPUTER NETWORK LABORATORY

EXPERIMENT NO. 8

AIM:- Study and Installation of Network Simulator (NS3).


THEORY:- The ns-3 simulator is a discrete-event network simulator targeted primarily for research and
educational use. The ns-3 project, started in 2006, is an open-source project developing ns-3.

The purpose of this tutorial is to introduce new ns-3 users to the system in a structured way. It is
sometimes difficult for new users to glean essential information from detailed manuals and to
convert this information into working simulations. In this tutorial, we will build several example
simulations, introducing and explaining key concepts and features as we go.

As the tutorial unfolds, we will introduce the full ns-3 documentation and provide pointers to
source code for those interested in delving deeper into the workings of the system.
A few key points are worth noting at the onset

 ns-3 is open-source, and the project strives to maintain an open environment for
researchers to contribute and share their software.
 ns-3 is not a backwards-compatible extension of ns-2; it is a new simulator. The two
simulators are both written in C++ but ns-3 is a new simulator that does not support
the ns-2 APIs.

For the installation of NS3, VMware workstation is required to be installed, along with an
Ubuntu system.
1. Download VMWare workstation from the website:
https://my.vmware.com/en/web/vmware/downloads/info/slug/desktop_end_user_compu
ting/vmware_workstation_player/15_0
2. Download Ubuntu 20.04.01 Desktop AMD 64 from the website:
https://ubuntu.com/download/desktop
3. Install VMWare workstation onto the computer system and open it.
4. Set up the VMware workstation.
a. Create a new virtual machine by selecting “Create New Virtual Machine.”

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 28/75
CSL 502: COMPUTER NETWORK LABORATORY

4. b. In the installer wizard, select installer disc image file(iso) and select the downloaded
Ubuntu 20.04.01 AMD 64 iso file by browsing through the computer download files.

c. Name the machine and set the password.


d. Configure the Hardware:
i. For memory: set the value to 4600 MB or above.
ii. For faster VMware, set processors to 2.
5. Power on the virtual machine and let the machine update.
6. Within the Virtual machine, download NS3 on the VM by opening Mozilla firefox and
downloading from the NS3 website.
7. Install prereq packages on Ubuntu using terminal:
a. Open the terminal by right clicking the desktop and select “open in terminal.”
b. Paste in this code and then press enter: sudo apt-get install g++ python3 python3-dev
pkg-config sqlite3 python3- setuptools git qt5-default mercurial gir1.2-goocanvas-2.0
python-gi python-gi-cairo python3-gi python3-gi-cairo python3-pygraphviz gir1.2-
gtk-3.0 ipython3 openmpi-bin openmpi-common openmpi-doc libopenmpi-dev
autoconf cvs bzr unrar gdb valgrind uncrustify doxygen graphviz imagemagick
texlive texlive-extra-utils texlive-latex-extra texlivefont-utils dvipng latexmk
python3-sphinx dia gsl-bin libgsl-dev libgsl23 libgslcblas0 tcpdump sqlite sqlite3
libsqlite3-dev libxml2 libxml2-dev cmake libc6-dev libc6-dev-i386 libclang-6.0-dev
llvm-6.0-dev automake python3-pip libgtk-3-dev synaptic vtun lxc uml-utilities.
c. After the packages have finished downloading, paste in this code and press
enter: sudo pip3 install cxxfilt.
8. After installing the required packages, create a folder named workspace in the home
directory and then put the NS3 tar package into the workspace. See example figure below.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 29/75
CSL 502: COMPUTER NETWORK LABORATORY

9. Go to terminal and input these commands consecutively after each command


finishes executing:
cd
cd workspace
tar xjf <Name of Ns3 downloaded file name>
cd <Name of extracted Ns3> ./build.py --enable-examples --enable-tests
10. Test the NS3 build and installation success by running test.py in the ns directory
using the following commands: cd ns- ./test.py

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 30/75
CSL 502: COMPUTER NETWORK LABORATORY

11. If all of the tests were passed, Congratulations! NS3 has now been installed
successfully.

CONCLUSION:- Thus, we have studied and successfully install NS3.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 31/75
CSL 502: COMPUTER NETWORK LABORATORY

EXPERIMENT NO. 9

AIM:- Design VPN and Configure RIP/OSPF using Packet tracer.


THEORY:- Routing Information Protocol (RIP) is a dynamic routing protocol which uses hop count as a
routing metric to find the best path between the source and the destination network. It is a
distance vector routing protocol which has AD value 120 and works on the application layer
of OSI model. RIP uses port number 520.

Hop Count:
Hop count is the number of routers occurring in between the source and destination
network. The path with the lowest hop count is considered as the best route to reach a
network and therefore placed in the routing table. RIP prevents routing loops by limiting
the number of hopes allowed in a path from source and destination. The maximum hop
count allowed for RIP is 15 and hop count of 16 is considered as network unreachable.
Features of RIP:
1. Updates of the network are exchanged periodically.
2. Updates (routing information) are always broadcast.
3. Full routing tables are sent in updates.
Routers always trust on routing information received from neighbour routers. This is also known
as Routing on rumours.
Steps for implementing RIP:
Step1:
Select Router – select 1841 router and drag it to the screen (Router0).
Select another Router – select 1841 and drag it to right of the outer0 (Router1).
Select Switches – select 2950-24 and drag it below the Router0 (Switch0).
Select Switches – select 2950-24 and drag it below the Router1 (Switch1).
Select End Device – select Generic and drag it below Switch0 (PC-PT PC0).
Select End Device – select Generic and drag it below Switch1 (PC-PT PC1).
Select End Device – select Generic and drag it below Switch1 (PC-PT PC2).
Select Connections – Connect routers, switches and PCs to each other.

Step2:

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 32/75
CSL 502: COMPUTER NETWORK LABORATORY

Click on PC0 and go to Desktop > IP Configuration


Add IP Address, as you will add the IP Address, Subnet Mask will be automatically added and
displayed.
Add Default Gateway and close the window.

Step3:
Click on PC1 and go to Desktop > IP Configuration
Add IP Address, as you will add the IP Address, Subnet Mask will be automatically added
and displayed.
Add Default Gateway and close the window.

Step4:

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 33/75
CSL 502: COMPUTER NETWORK LABORATORY

Click on PC2 and go to Desktop > IP Configuration


Add IP Address, as you will add the IP Address, Subnet Mask will be automatically
added and displayed.
Add Default Gateway and close the window.

Step5:
Click on Router0. Go to Config > FastEthernet0/0.
Here, add IP Address and On the Port Status.

Step6:
Click on Router1. Go to Config > FastEthernet0/1.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 34/75
CSL 502: COMPUTER NETWORK LABORATORY

Here, add IP Address and On the Port Status.

As you will see above, there is green dots which means connections are done
successfully between Router, Switches and PCs.
Step7:
Click on Router0. Go to Config > FastEthernet0/1.
Here, add IP Address and On the Port Status

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 35/75
CSL 502: COMPUTER NETWORK LABORATORY

Step8:
Click on Router1. Go to Config > FastEthernet0/0.
Here, add IP Address and On the Port Status

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 36/75
CSL 502: COMPUTER NETWORK LABORATORY

As you can see above, connection is done between both the Routers successfully.

Step9:
Click on Router1. Go to Config > RIP.
Here, add the network address to connect router1 with switch1, PC1, PC2 and router0.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 37/75
CSL 502: COMPUTER NETWORK LABORATORY

Step10:
Click on Router0. Go to Config > RIP.
Here, add the network address to connect router0 with switch0, PC0 and router1.

Now, all the connections are done successfully, you can check it by clicking on this symbol.

And then, click on any two PCs, you will get the status as successful.
Final Output:

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 38/75
CSL 502: COMPUTER NETWORK LABORATORY

So, Routing Information Protocol is done.

Steps for implementing VLAN:


Step1:
Select Router – select 1841 router and drag it to the screen (Router0).
Select another Router – select 1841 and drag it to right of the Router0 (Router1).
Select Switches – select 2950-24 and drag it below the Router0 (Switch0).
Select Switches – select 2950-24 and drag it below the Router1 (Switch1).
Select End Device – select Generic and drag it below Switch0 (PC-PT PC0).
Select End Device – select Generic and drag it below Switch1 (PC-PT PC1).
Select End Device – select Generic and drag it below Switch1 (PC-PT PC2).
Select Connections – Connect routers, switches and PCs to each other.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 39/75
CSL 502: COMPUTER NETWORK LABORATORY

Step2:
Click on PC0 and go to Desktop > IP Configuration
Add IP Address, as you will add the IP Address, Subnet Mask will be automatically added
and displayed.
Add Default Gateway and close the window.

Step3:
Click on PC1 and go to Desktop > IP Configuration
Add IP Address, as you will add the IP Address, Subnet Mask will be automatically added
and displayed.
Add Default Gateway and close the window.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 40/75
CSL 502: COMPUTER NETWORK LABORATORY

Step4:
Click on PC2 and go to Desktop > IP Configuration
Add IP Address, as you will add the IP Address, Subnet Mask will be automatically added
and displayed.
Add Default Gateway and close the window.

Step5:
Click on Router0. Go to Config > FastEthernet0/0.
Here, add IP Address and On the Port Status.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 41/75
CSL 502: COMPUTER NETWORK LABORATORY

Step6:
Click on Router1. Go to Config > FastEthernet0/1.
Here, add IP Address and On the Port Status.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 42/75
CSL 502: COMPUTER NETWORK LABORATORY

As you will see above, there is green dots which means connections are done successfully
between Router, Switches and PCs.
Step7:
Click on Router0. Go to Config > FastEthernet0/1.
Here, add IP Address and On the Port Status.

Step8:
Click on Router1. Go to Config > FastEthernet0/0.
Here, add IP Address and On the Port Status.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 43/75
CSL 502: COMPUTER NETWORK LABORATORY

As you can see above, connection is done between both the Routers successfully.

Step9:
Click on Router1. Go to Config > RIP.
Here, add the network address to connect router1 with switch1, PC1, PC2 and router0.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 44/75
CSL 502: COMPUTER NETWORK LABORATORY

Step10:
Click on Router0. Go to Config > RIP.
Here, add the network address to connect router0 with switch0, PC0 and router1.

Now, all the connections are done successfully, you can check it by clicking on this symbol.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 45/75
CSL 502: COMPUTER NETWORK LABORATORY

And then, click on any two PCs , you will get the status as successful.

So till now, Routing Information Protocol is done.


Now, we will start with implementing VLAN.
Step11:
Add two PC (PC 3 and PC4) and connect it with switch.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 46/75
CSL 502: COMPUTER NETWORK LABORATORY

Step12:
Click on PC3 and go to Desktop > IP Configuration
Add IP Address, as you will add the IP Address, Subnet Mask will be automatically added
and displayed.
Add Default Gateway and close the window.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 47/75
CSL 502: COMPUTER NETWORK LABORATORY

Step13:
Click on PC3 and go to Desktop > IP Configuration
Add IP Address, as you will add the IP Address, Subnet Mask will be automatically added
and displayed.
Add Default Gateway and close the window.

Step14:
Click on Switch1 and go to CLI
Add type the VLAN code – VLAN CODE:
VLAN
enable
config t
vlan 20
name purchase
exit
vlan 30
name sales
exit

int fa0/2
switchport access vlan 20
exit

int fa0/3
switchport access vlan 20
exit

int fa0/4
switchport access vlan 20

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 48/75
CSL 502: COMPUTER NETWORK LABORATORY

exit

int fa0/5
switchport access vlan 20
exit

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 49/75
CSL 502: COMPUTER NETWORK LABORATORY

Final Output:
Now, PC1, PC2 are not connected to PC3 and PC4.

CONCLUSION:- Thus, we have successfully implemented VLAN and RIP protocol.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 50/75
CSL 502: COMPUTER NETWORK LABORATORY

EXPERIMENT NO. 10

AIM:- Java program for Socket Programming.


THEORY:- Java Socket Programming:
 Java Socket programming is used for communication between the applications
running on different JRE.
 Java Socket programming can be connection-oriented or connection-less.
 Socket and ServerSocket classes are used for connection-oriented socket programming
and DatagramSocket and DatagramPacket classes are used for connection-less socket
programming.
The client in socket programming must know two information:
a. IP Address of Server, and
b. Port number
Here, we are going to make one-way client and server communication. In this application, client
sends a message to the server, server reads the message and prints it. Here, two classes are being
used: Socket and ServerSocket.
The Socket class is used to communicate client and server. Through this class, we can read
and write message. The ServerSocket class is used at server-side. The accept() method of
ServerSocket class blocks the console until the client is connected. After the successful
connection of client, it returns the instance of Socket at server-side.
#Socket class
A socket is simply an endpoint for communications between the machines. The Socket class can
be used to create a socket.
#ServerSocket class
The ServerSocket class can be used to create a server socket. This object is used to establish
communication with the clients.
Creating Server:
To create the server application, we need to create the instance of ServerSocket class. Here,
we are using 6666 port number for the communication between the client and server. You
may also choose any other port number. The accept() method waits for the client. If clients
connects with the given port number, it returns an instance of Socket.
ServerSocket ss=new ServerSocket(6666);
Socket s=ss.accept();//establishes connection and waits for the client
Creating Client:
To create the client application, we need to create the instance of Socket class. Here, we need
to pass the IP address or hostname of the Server and a port number. Here, we are using
"localhost" because our server is running on same system.
Socket s=new Socket("localhost",6666);
Code:
MyServer.java file
import
java.io.*;
import
java.net.*;
public class
MyServer
public static void

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 51/75
CSL 502: COMPUTER NETWORK LABORATORY

main(String[]
args){ try
{
ServerSocket ss=new
ServerSocket(6666);
Socket
s=ss.accept();//establishes
connection
DataInputStream dis=new
DataInputStream(s.getInputStream()); String
str=(String)dis.readUTF();
System.out.printl
n("message=
"+str); ss.close();
}
catch(Exception e){System.out.println(e);}
}
}
MyClient.java file
import java.io.*; import
java.net.*; public class
MyClient
{
public static void main(String[] args)
{
try
{
Socket s=new Socket("localhost",6666);
DataOutputStream dout=new
DataOutputStream(s.getOutputStream());
dout.writeUTF("Hello Server");
dout.flush();
dout.close();
s.close();
}catch(Exception e){System.out.println(e);}
}
}
Output:
To execute this program open two command prompts and execute each program at
each command prompt as displayed in the below figures.
First run Myserver.java file in terminal/cmd,

Running MyServer.java
Then in new terminal/cmd run MyClient.java file

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 52/75
CSL 502: COMPUTER NETWORK LABORATORY

Running MyServer.java
As soon as you run MyClient program a message is sent to server and displayed in
MyServer Terminal/CMD as shown below,

Message displayed in MyServer after running MyClient.

CONCLUSION:- So, in this experiment we have successfully understood the concept of


Socket Programming and implemented it using Java Programming.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 53/75
CSL 502: COMPUTER NETWORK LABORATORY

EXPERIMENT NO. 11

AIM:- Perform File Transfer and Access using FTP.


THEORY:- Transferring files from a client computer to a server computer is called "uploading" and
transferring from a server to a client is "downloading".
Requirements for using FTP
1. An FTP client like Auto FTP Manager installed on your computer.
2. Certain information about the FTP server you want to connect to:
a.The FTP server address. This looks a lot like the addresses you type to browse web
sites.
Example: Server address is "ftp.videodesk.net".
Sometimes the server address will be given as a numeric address, like
"64.185.225.87".
b. A user name and password. Some FTP servers let you connect to them anonymously.
For anonymous connections, you do not need a user name and password. To transfer
files, provide your client software (Auto FTP Manager) with the server address, user
name, and password. After connecting to the FTP server, you can use Auto FTP
Manager's File Manager to upload, download and delete files. Using the File
Manager is a lot like working with Windows Explorer.
FTP and Internet Connections
FTP uses one connection for commands and the other for sending and receiving data. FTP has a
standard port number on which the FTP server "listens" for connections. A port is a "logical
connection point" for communicating using the Internet Protocol (IP). The standard port number
used by FTP servers is 21 and is used only for sending commands. Since port 21 is used
exclusively for sending commands, this port is referred to as a command port. For example, to
get a list of folders and files present on the FTP server, the FTP Client issues a "LIST"
command. The FTP server then sends a list of all folders and files back to the FTP Client. So
what about the internet connection used to send and receive data? The port that is used for
transferring data is referred to as a data port. The number of the data port will vary depending
on the "mode" of the connection. (See below for Active and Passive modes.).
Active and Passive Connection Mode
The FTP server may support Active or Passive connections or both. In an Active FTP
connection, the client opens a port and listens and the server actively connects to it. In a Passive
FTP connection, the server opens a port and listens (passively) and the client connects to it. You
must grant Auto FTP Manager access to the Internet and to choose the right type of FTP
Connection Mode.
Most FTP client programs select passive connection mode by default because server
administrators prefer it as a safety measure. Firewalls generally block connections that are
"initiated" from the outside. Using passive mode, the FTP client (like Auto FTP Manager) is
"reaching out" to the server to make the connection. The firewall will allow these outgoing
connections, meaning that no special adjustments to firewall settings are required.
If you are connecting to the FTP server using Active mode of connection you must set your
firewall to accept connections to the port that your FTP client will open. However, many
Internet service providers block incoming connections to all ports above 1024. Active FTP
servers generally use port 20 as their data port.
IMPLEMENTATION:
Step 1: Installation of the Package
i. # rpm –ivh vsftpd-

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 54/75
CSL 502: COMPUTER NETWORK LABORATORY

Step 2: Editing Configuration files


i. Open ftp configuration file /etc/vsftpd/vsftpd.conf
ii. Set up anonymous access of FTP server.
vsftpd.conf is the main configuration file of FTP server and it contains lot of
directives. Configuration of an anonymous-only download is relatively
simple. Default configuration of vsftpd.conf already supports anonymous-
only download. But it also supports access from local users. All you need to
do is disable the directive which allows locally configured users to login
with their accounts.

Step 3: Restart the vsftpd service

Step 4: Check connectivity with FTP Server.


# Ping ip address of the ftp server (192.168.10.10)
Step 5: Test the FTP server and transfer files using command prompt

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 55/75
CSL 502: COMPUTER NETWORK LABORATORY

We can download the file using anonymous user but cannot upload the file. Also the default
data location (or pwd ) of FTP server will be pub directory during anonymous access.
Step 5: b. Access the FTP server and transfer files using command prompt.
First go to browser then and type FTP://192.168.10.10. It will show default
location of pub directory.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 56/75
CSL 502: COMPUTER NETWORK LABORATORY

2: User Specific Authentication


i. Create local user and provide password to it.

ii. Edit VSFTPD configuration file

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 57/75
CSL 502: COMPUTER NETWORK LABORATORY

iii. Restart VSFTPD service

Access FTP server through command prompt.


Login from local user abc and create a testfiles and testdir

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 58/75
CSL 502: COMPUTER NETWORK LABORATORY

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 59/75
CSL 502: COMPUTER NETWORK LABORATORY

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 60/75
CSL 502: COMPUTER NETWORK LABORATORY

CONCLUSION:- The File Transfer Protocol (FTP) is a standard network protocol used
to transfer computer files from one host to another host over a TCP-
based network, such as the Internet. FTP is built on a client-server
architecture and uses separate control and data connections between
the client and the server.
During the Anonymous access of FTP server default location of FTP
data will be pub directory. However during user specific access default
location of ftp data will be user directory in /home on server.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 61/75
CSL 502: COMPUTER NETWORK LABORATORY

EXPERIMENT NO. 12

AIM:- Perform Remote login using Telnet server.


THEORY:- Telnet protocol allows you to connect to remote hosts over TCP/IP network. Telnet was
developed in 1969. Telnet was initially developed for private use where security was not
primary concern. Telnet protocol has serious security issue. Security expert recommend that the
use of Telnet for remote login should be discontinued under all normal circumstances.
 Telnet Server
 Telnet Client
Telnet Server
Telnet server software is installed on remote host. You need to configure it before client can
connect with it.
Telnet Client
Telnet client software allows you to connect telnet server. Once telnet client establishes a
connection to the remote host, client becomes a virtual terminal, allowing you to communicate
with the remote host from your computer.
Security issue with Telnet
 Telnet by default does not encrypt any data sent over the connection.
 Anyone who has access to network device located on the network between the two
hosts like router, switch, hub or gateway where Telnet is being used can intercept the
packets passing by and obtain login, password and whatever else is typed with a packet
sniffer software.
 Telnet protocol have no implementations that would ensure that communication is
carried out between the two hosts is not intercepted in the middle.
 In RHEL Telnet is part of the xinetd daemon.
 Telnet use plain text to transmit password.
 root user is not allowed to connect using Telnet.
 Command-line telnet clients are built into all major operating systems.
IMPLEMENTATION:
Configure Telnet in RHEL 6
Three RPM are required to configure telnet server in linux.

-server
-client
Step 1: Installation of Packages
1. Login using root account. Necessary rpm for telnet server is xinetd, telnet-
server and telnet.
# rpm –ivh xinetd-2.3.14-31.e16.X86_64
# rpm –ivh telnet-server-
# rpm –ivh telnet-
2, To check whether the package is installed on the system.

The version numbers of the package should not matter, Red Hat Network
(RHN) will always provide you with the latest version of the package.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 62/75
CSL 502: COMPUTER NETWORK LABORATORY

Step 2: Check Configuration files


Once you have the packages installed, check the /etc/xinetd.d/telnet file.

ensure that disable = yes is changed to read disable = no

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 63/75
CSL 502: COMPUTER NETWORK LABORATORY

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 64/75
CSL 502: COMPUTER NETWORK LABORATORY

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 65/75
CSL 502: COMPUTER NETWORK LABORATORY

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 66/75
CSL 502: COMPUTER NETWORK LABORATORY

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 67/75
CSL 502: COMPUTER NETWORK LABORATORY

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 68/75
CSL 502: COMPUTER NETWORK LABORATORY

CONCLUSION:- Telnet is an application protocol used on the Internet or local area


networks to provide a bidirectional interactive text-oriented
communication facility using a virtual terminal connection. However,
telnet by default does not encrypt any data sent over the connection
(including passwords), and so it is often feasible to eavesdrop on the
communications and use the password later for malicious purposes.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 69/75
CSL 502: COMPUTER NETWORK LABORATORY

SOME QUESTIONS AND ANSWERS

01 Digital Data
Digital data take on discrete values; examples are text and integers.
02 Analog Signal
An analog signal is a continuously varying electromagnetic wave that may be propagated over a
variety of media, depending on frequency; examples are copper wire media, such as twisted pair
and coaxial cable.
03 Digital Signal
A digital signal is a sequence of voltage pulses that may be transmitted over a copper wire
medium; for example, a constant positive voltage level may represent binary 0 and a constant
negative voltage level may represent binary 1.
04 channel capacity
The maximum rate at which data can be transmitted over a given communication path, or
channel, under given conditions is referred to as the channel capacity.
05 Transmission medium and its type
The transmission medium is the physical path between transmitter and receiver. Transmission
media can be classified as guided or unguided.
06 Infrared
Infrared (IR) light is electromagnetic radiation with longer wavelengths than those of visible
light, extending from the nominal red edge of the visible spectrum at 0.74 micro meters (µm)to
300 µm.
07 Multiplexing
Is a method by which multiple analog message signals or digital data streams are combined into
one signal over a shared medium.
08 Demultiplexing
Demultiplexer (or demux) is a device taking a single input signal and selecting one of many
data-output-lines, which is connected to the single input.
09 frequency division multiplexing (FDM)
FDM is a technique by which the total bandwidth available in a communication medium is
divided into a series of non-overlapping frequency sub-bands, each of which is used to carry a
separate signal.
10 Time division multiplexing (TDM).
TDM is a type of digital (or rarely analog) multiplexing in which two or more bit streams or
signals are transferred appearing simultaneously as sub-channels in one communication channel,
but are physically taking turns on the channel.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 70/75
CSL 502: COMPUTER NETWORK LABORATORY

11 guard bands
A guard band is an unused part of the radio spectrum between radio bands, for the purpose of
preventing interference.
12 What techniques are used for multiplexing?
Two techniques for multiplexing in telecommunications networks are in common use: frequency
division multiplexing (FDM) and time division multiplexing (TDM).
13 LAN,MAN,WAN
LAN: (local area network as listed in our computer terms page) A group of computers that
share a common connection and are usually in a small area or even in the same building.
MAN: (metropolitan area network) This is a larger network that connects computer users in a
particular geographic area or region. For example a large university may have a network so large
that it may be classified as a MAN. The MAN networks usually exist to provide connectivity to
local ISPs, cable tv, or large corporations.
WAN: (wide area network) This is the largest network and can interconnect networks
throughout the world and is not restricted to a geographical location. The Internet is an example
of a worldwide public WAN.
14 Switching Techniques
A. Circuit switching: Communication via circuit switching implies that there is a dedicated
communication path between two stations.
B. Packet switching: Packet switching is a digital networking communications method that
groups all transmitted data – regardless of content, type, or structure – into suitably sized
blocks, called packets.
15 Asynchronous transfer mode
Asynchronous transfer mode (ATM), also known as cell relay, is in some ways similar to packet
switching. Like packet switching, ATM involves the transfer of data in discrete chunks. Also,
like packet switching, ATM allows multiple logical connections to be multiplexed over a single
physical interface.
16 TCP IP Protocol
Is the basic communication language or protocol of the Internet. It can also be used as a
communications protocol in a private network.
17 OSI Model
The Open Systems Interconnection (OSI) model (ISO/IEC 7498-1) is a product of the Open
Systems Interconnection effort at the International Organization for Standardization. It is a
prescription of characterizing and standardizing the functions of a communications system in
terms of abstraction layers.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 71/75
CSL 502: COMPUTER NETWORK LABORATORY

18 Internetworking
Internetworking (a combination of the words inter (“between”) and networking; it is not internet-
working or international-network) is the practice of connecting a computer network with other
networks through the use of gateways that provide a common method of routing information
packets between the networks. The resulting system of interconnected networks is called an
internetwork, or simply an internet
19 Routers
A router is a device that forwards data packets between computer networks, creating an overlay
internetwork. A router is connected to two or more data lines from different networks. When a
data packet comes in one of the lines, the router reads the address information in the packet to
determine its ultimate destination. Then, using information in its routing table or routing policy,
it directs the packet to the next network on its journey.
20 IPv4 & IPv6
IPv4 IPv6
Addresses are 32 bits (4 bytes) in length. Addresses are 128 bits (16 bytes) in length.
Header includes a checksum. Header does not include a checksum.
Must support a 576-byte packet size (possibly Must support a 1280-byte packet size
fragmented). (without fragmentation).

21 What is antenna, what are their types?


An antenna can be defined as an electrical conductor or system of conductors’ used either for
radiating electromagnetic energy or for collecting electromagnetic energy.
Antenna Types are Dipoles, Parabolic Reflective Antenna.
22 What are different propagation modes?
Ground Wave Propagation,
Sky Wave Propagation,
Line-of-Sight Propagation
23 Attenuation
It is the loss of energy as the signal propagates outward. The amount of energy depends on the
frequency. If the attenuation is too much, the receiver may not be able to detect the signal at all,
or the signal may fall below the noise level. For reliable communication, the attenuation and
delay over the range of frequencies of transmission should be constant.
24 Noise
Noise is a third impairment. It can be define as unwanted energy from sources other than the
transmitter. Thermal noise is caused by the random motion of the electrons in a wire and is

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 72/75
CSL 502: COMPUTER NETWORK LABORATORY

unavoidable.
25 Crosstalk
Cross talk is a noise that is caused by the inductive coupling between two wires that are closed to
each other. Sometime when talking on the telephone, you can hear another conversation in the
background. That is cross talk.
26 Distortion
Communication line has distributed inductance and capacitance which distort the amplitude
of signals and also delay the signals at different frequencies by different amounts. It is caused by
the fact that different Fourier components travel at different speed.
27 What is fading? What are their types?
The term fading refers to the time variation of received signal power caused by changes in the
transmission medium or path(s).
Fast fading: Fast fading occurs when the coherence time of the channel is small relative to the
delay constraint of the channel. In this regime, the amplitude and phase change imposed by the
channel varies considerably over the period of use.
Slow Fading: slow-fading channel, it is not possible to use time diversity because the
transmitters see only a single realization of the channel within its delay constraint. A deep fade
therefore lasts the entire duration of transmission and cannot be mitigated using coding.
28 What is error correction? What are its type?
a) Forward error correction (FEC) or channel coding is a technique used for controlling
errors in data transmission over unreliable or noisy communication channels.
b) Backward error correction: in which the receiver merely detects the presence of errors
and then sends a request back to the transmitter to retransmit the data in error. Backward
error correction is not practical in many wireless applications.
29 What is ASK, FSK, PSK
ASK refers to a type of amplitude modulation that assigns bit values to discrete amplitude levels.
The carrier signal is then modulated among the members of a set of discrete values to transmit
information.
FSK refers to a type of frequency modulation that assigns bit values to discrete frequency levels.
FSK is divided into non coherent and coherent forms. In non-coherent forms of FSK, the
instantaneous frequency shifts between two discrete values termed the “mark” and “space”
frequencies. In coherent forms of FSK, there is no phase discontinuity in the output signal. FSK
modulation formats generate modulated waveforms that are strictly real values, and thus tend
not to share common features with quadrature modulation schemes.
PSK in a digital transmission refers to a type of angle modulation in which the phase of the

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 73/75
CSL 502: COMPUTER NETWORK LABORATORY

carrier is discretely varied—either in relation to a reference phase or to the phase of the


immediately preceding signal element—to represent data being transmitted. For example, when
encoding bits, the phase shift could be 0 degree for encoding a “0,” and 180 degrees for
encoding a “1,” or the phase shift could be –90 degrees for “0” and +90 degrees for a “1,”thus
making the representations for “0” and “1” a total of 180 degrees apart.
30 Parity Check
Parity checking: A technique used to detect memory or data communication errors. The
computer adds up the number of bits in a one-byte data item, and if the parity bit setting
disagrees with the sum of the other bits, the computer reports an error. Parity-checking schemes
work by storing a one-bit digit (0 or 1) that indicates whether the sum of the bits in a data item is
odd or even. When the data item is read from memory or received by another computer, a panty
check occurs. If the parity check reveals that the parity bit is incorrect, the computer displays an
error message.
31 Cyclic Redundancy Check
A cyclic redundancy check (CRC) is an error-detecting code commonly used in digital networks
and storage devices to detect accidental changes to raw data. Blocks of data entering these
systems get a short check value attached, based on the remainder of a polynomial division of
their contents; on retrieval the calculation is repeated, and corrective action can be taken against
presumed data corruption if the check values do not match.
32 Hamming Code
Hamming codes are a family of linear error-correcting codes that generalize the Hamming (7, 4)-
code invented by Richard Hamming in 1950. Hamming codes can detect up to two and correct
up to one bit errors. By contrast, the simple parity code cannot correct errors, and can detect only
an odd number of errors. Hamming codes are special in that they are perfect code, that is, they
achieve the highest possible rate for codes with their block length and minimum distance 3.
33 Linux
Linux® is an open source operating system (OS). An operating system is the software that
directly manages a system's hardware and resources, like CPU, memory, and storage. The OS
sits between applications and hardware and makes the connections between all of your software
and the physical resources that do the work.
34 Packet
A packet is a small amount of data sent over a network, such as a LAN or the Internet.
Similar to a real-life package, each packet includes a source and destination as well as the
content (or data) being transferred.
35 Packet tracer

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 74/75
CSL 502: COMPUTER NETWORK LABORATORY

Cisco® Packet Tracer is a powerful network simulation program that allows students to
experiment with network behavior and ask “what if” questions. ... Students can build, configure,
and troubleshoot networks using virtual equipment and simulated connections, alone or in
collaboration with other students.
36 Nmap
Nmap (Network Mapper) is a free and open-source network scanner created by Gordon
Lyon (also known by his pseudonym Fyodor Vaskovich). Nmap is used to
discover hosts and services on a computer network by sending packets and analyzing the
responses.
It is used by network administrator to map their networks.
37 Wireshark
Wireshark is a packet sniffer and analysis tool. It captures network traffic on the local network
and stores that data for offline analysis. Wireshark captures network traffic from Ethernet,
Bluetooth, Wireless.
Wireshark is a network protocol analyzer, or an application that captures packets from a
network connection, such as from your computer to your home office or the internet.
38 CSMA/CD
Carrier Sense Multiple Access/Collision Detection, CSMA/CD is a MAC (Media Access
Control) protocol used in LAN. It defines how network devices respond when two devices
attempt to use a data channel simultaneously and encounter a data collision.
39 RHEL
Red Hat Enterprise Linux (RHEL) is a distribution of the Linux operating system developed for
the business market. RHEL was formerly known as Red Hat Linux Advanced Server. RHEL is
based on free, open source code. The RHEL operating system (OS) supports diverse workloads
in physical, virtualized and cloud environments.

LAB MANUAL (T.E. Computer Engineering, Sem-V, Rev.-2019, ‘C’ Scheme.


2020-21) 75/75

You might also like