SlideShare ist ein Scribd-Unternehmen logo
1 von 79
DEPARTMENT OF INFORMATION TECHNOLOGY
LABORATORY MANUAL
CS8581 NETWORKS LABORATORY
2019-2020 ODD SEMESTER
2017-2021 Batch
Staff in Charge HOD/IT
D.Kayathri Devi, AP/ IT Dr.P.SUBATHRA,Prof/IT
BONAFIDE GERTIFICATE
NAME : ________________________________________________________________________________
REGISTER NUMBER: ________________________________________________ ROLLNO: __________________
BRANCH : _________________________________________________________________________________
YEAR : _________________________________________________________________________________
Bonafide Record of work done in the __________________________________________________________
of Kamaraj College of Engineering and Technology, Madurai, during the year _____________________.
STAFF IN-CHARGE HEAD OF THE DEPARTMENT
Submitted for the Practical Examination held on ___________________________ at Kamaraj College of
Engineering and Technology, Madurai.
INTERNAL EXAMINER EXTERNAL EXAMINER
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
3
INDEX
Expt.
No
Date Title of the Exercise
Page
No
Mark
(100)
CO
Attained?
(Yes/No)
Signature
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
4
Expt.
No
Date Title of the Exercise
Page
No
Mark
(100)
CO
Attained?
(Yes/No)
Signature
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
5
DEPARTMENT OF INFORMATION TECHNOLOGY
VISION OF THE INSTITUTE
To make this institute the unique of its kind in the field of Research and Development
activities in this part of world
MISSION OF THE INSTITUTE
To impart highly innovative and technical knowledge to the urban and unreachable rural
student folks through Total Quality Education
VISION OF THE DEPARTMENT
To make the department of Information Technology the unique of its kind in the field of
Research and Development activities in this part of world
MISSION OF THE DEPARTMENT
To impart highly innovative and technical knowledge in the field of Information Technology
to the urban and unreachable rural student folks through Total Quality Education
PROGRAM EDUCATION OBJECTIVE [PEO]
PEO 1: Graduates of the programme will exhibit expertise in technical knowledge by
applying distinctive skills in various fields of Information Technology
PEO 2: Graduates will become pioneers in the field of Information Technology by working
collaboratively and providing solutions to meet societal needs through persistent learning
PEO 3: Graduates will be able to adopt innovative practices and contribute towards research
and technological development in the field of Information Technology through Total
Quality Education
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
6
PROGRAM OUTCOMES
Engineering Graduates will be able to:
1. Engineering knowledge: Apply the knowledge of mathematics, science, engineering
fundamentals, and an engineering specialization to the solution of complex engineering
problems.
2. Problem analysis: Identify, formulate, review research literature, and analyse complex
engineering problems reaching substantiated conclusions using first principles of
mathematics, natural sciences, and engineering sciences.
3. Design/development of solutions: Design solutions for complex engineering problems and
design system components or processes that meet the specified needs with appropriate
consideration for the public health and safety, and the cultural, societal, and environmental
considerations.
4. Conduct investigations of complex problems: Use research-based knowledge and research
methods including design of experiments, analysis and interpretation of data, and synthesis of
the information to provide valid conclusions.
5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern
engineering and IT tools including prediction and modeling to complex engineering activities
with an understanding of the limitations.
6. The engineer and society: Apply reasoning informed by the contextual knowledge to assess
societal, health, safety, legal and cultural issues and the consequent responsibilities relevant to
the professional engineering practice.
7. Environment and sustainability: Understand the impact of the professional engineering
solutions in societal and environmental contexts, and demonstrate the knowledge of, and need
for sustainable development.
8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and
norms of the engineering practice.
9. Individual and team work: Function effectively as an individual, and as a member or leader
in diverse teams, and in multidisciplinary settings.
10. Communication: Communicate effectively on complex engineering activities with the
engineering community and with society at large, such as, being able to comprehend and write
effective reports and design documentation, make effective presentations, and give and
receive clear instructions.
11. Project management and finance: Demonstrate knowledge and understanding of the
engineering and management principles and apply these to one’s own work, as a member and
leader in a team, to manage projects and in multidisciplinary environments.
12. Life-long learning: Recognize the need for, and have the preparation and ability to engage in
independent and life-long learning in the broadest context of technological change.
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
7
PROGRAM SPECIFIC OUTCOMES (PSOs)
Engineering Graduates will be able to:
1. Design and develop applications in the field of Information Technology by applying
the knowledge acquired from Computer Organization & Engineering, Networking,
Software Engineering & Programming, Data Analytics & other allied topics.
2. Demonstrate an ability to analyze, design, and develop software solutions to cater the
needs of diversified business sectors
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
8
SYLLABUS
CS8581- NETWORKS LABORATORY 0 0 4 2
OBJECTIVES:
To learn and use network commands.
To learn socket programming.
To implement and analyze various network protocols.
To learn and use simulation tools.
To use simulation tools to analyze the performance of various network protocols.
LIST OF EXPERIMENTS
1. Learn to use commands like tcpdump, netstat, ifconfig, nslookup and traceroute.
Capture ping and traceroute PDUs using a network protocol analyzer and
examine.
2. Write a HTTP web client program to download a web page using TCP sockets.
3. Applications using TCP sockets like:
 Echo client and echo server
 Chat
 File Transfer
4. Simulation of DNS using UDP sockets.
5. Write a code simulating ARP /RARP protocols.
6. Study of Network simulator (NS) and Simulation of Congestion Control
Algorithms using NS.
7. Study of TCP/UDP performance using Simulation tool.
8. Simulation of Distance Vector/ Link State Routing algorithm.
9. Performance evaluation of Routing protocols using Simulation tool.
10. Simulation of error correction code (like CRC).
Mini Project – Team of 3 Members – Network Project
OUTCOMES:
Upon Completion of the course, the students will be able to:
1. Implement various protocols using TCP and UDP.
2. Compare the performance of different transport layer protocols.
3. Use simulation tools to analyze the performance of various network protocols.
4. Analyze various routing algorithms.
5. Implement error correction codes.
TOTAL : 60 PERIODS
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
9
COURSE OUTCOMES AND ITS PO MAPPING
Name of the Subject : Networks Laboratory
Subject Code : CS 8581
Semester : V
Odd/Even : Odd
Students will be able to
Course No. Course Outcome (Student should be able to) Knowledge Level
R17C308.1 Use basic networking commands to realize packet transmission in live network
K3 - Apply
R17C308.2 Implement the protocols using TCP/UDP and Compare their performance
K3 - Apply
R17C308.3 Use simulation tools to analyze the performance of network protocols
K4 - Analyze
R17C308.4 Implement and analyze routing algorithms
K4 - Analyze
R17C308.5 Implement error correction codes
K3 - Apply
CO vs PO Mapping
Course
Outco
mes
Program outcomes
Program
Specifi
c
outcom
es
PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 PSO1 PSO2
R17C308.1(K3) M - - - L - - - - M - - M -
R17C308.2(K3) H H L - H - - - - M - - M -
R17C308.3(K4) H H M - H - - - - M - - M -
R17C308.4(K4) H H M - H - - - - M - - M -
R17C308.5(K3) H M L - L - - - - M - - M -
R17C308 H H M - M - - - - M - - H -
3 – Substantial (High) 2 – Moderate (Medium) 1 – Slight (Low)
Internal Assessment
S.No Assessment Tool
Percentage of
Contribution (%)
1 Laboratory Rubrics 75
2 Model Exam. 25
Target Value = 80 % of Marks
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
10
LIST OF EXERCISES AND ITS CO’S
Expt.
No
Experiment Name No.
of
Periods
Cumulative
No. of
periods
Course
Outcome
Mapping
Cycle – I
1 Introduction, Pre Assessment Test 4 4
2 Basic Networking Commands 4 5 C308.1
3 Web Scrapping Programming using HTTP Protocol 4 12 C308.2
4 Socket Programming using TCP
a. Chat Simulation
b. Echo Simulation
c Pink Simulation
4 16 C308.2
5 File Transfer Protocol using TCP 4 20 C308.3
6 Simulation of ARP and RARP using TCP 4 24 C308.3
Cycle II
7 Simulation of DNS using TCP 4 28 C308.3
8 Simulation of error correction code (like Parity Checker) 4 32 C308.4
9 Simulation of FTP Protocol using UDP 4 36 C308.4
10 Study of Network Topologies and, Congestion Control using
Network Simulator 2
4 40 C308.4
11 Simulation of Routing Protocol using NS2 Simulator 4 44 C308.5
12 Performance evaluation of Various Protocol using Simulator
Tool (Wireshark)
4 48 C308.5
13 Performance analysis of TCP& UDP 4 52 C308.5
13 Routing Configuration using Toggit Simulation Tool 4 56 C308.3
14 Model Examination and Post Assessment Test 4 60
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
11
Attainment of CO – Internal Assessment
Basedon Laboratory Rubric
CO
Expt.
No
Exercise Title
Lab
Mark
(100)
Average
CO
Attained?
(Y/N)
1 1 Basic Networking Commands
2
2 Web Scrapping Programming using HTTP Protocol
3
Socket Programming using TCP
a. Chat Simulation
b. Echo Simulation
c Pink Simulation
4 File Transfer Protocol using TCP
3
5 Simulation of ARP and RARP using TCP
6 Simulation of DNS using TCP
7 Simulation of error correction code (like Parity Checker)
8 Simulation of FTP Protocol using UDP
4
9 Study of Network Simulator 2
10
Simulation of Network Topologies, Congestion Control and
Routing Protocol using NS2 Simulator
5
11
Performance evaluation of Various Protocol using Simulator Tool
(Wiresherk)
12 Performance analysis of TCP& UDP
13
Content Beyond Syllabus: Routing Configuration using Toggit
Simulation Tool
(A) Total Marks (100) = [CO 1+CO 2+CO 3+CO 4+CO 5]
Basedon Model Exam
CO
Marks (B) Total Marks
(100)
CO Attained?
(Yes/No)
Allotted Obtained
Internal Assessment = 75 % of A + 25 % of B
=
Internal Assessment = %
Note:
If CO Attainment,
YES = Laboratory Mark (%) >= Target Value (%)
NO = Laboratory Mark (%) < Target Value (%)
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
12
Action Plan:
(If CO Not Attained)
For Regular Laboratory Session
CO
Reason for not
Attaining CO
Remedial Action Plan Remarks Signature
For Model Exam
CO
Reason for not
Attaining CO
Remedial Action Plan Remark Signature
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
13
Department of Information Technology
RUBRICS FOR LABORATORY ASSESMENT – Annexure I
Category
Design/ Logic
[40]
Understood the
basic concept and
logic/design [40]
Understood the
logic/design and
basic concept but
lacks in presenting
it [38]
Understood the basic
concept but lacks in
understanding the
logic/design [36]
Understood the basic
concept but fails to
give detail description
[32]
No knowledge in
basic concept but
implemented the
program [30]
Code Design
[40]
Code that
satisfies the entire
logic [40]
Code deigned with
some syntax errors
[38]
Code designed with
some logic mistakes
[36]
Code designed with
wrong logic [32]
Wrong logic &
no programming
structure but
finished the
program [30]
Record
Submission [10]
Submission on
date [10]
1 day delay [9] 2 days delay [8] 3 days delay [7] 4 days delay [6]
Viva [10] Oral Quiz / Online Quiz
Total Marks: 100 Marks
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
14
COURSE INTRODUCTION
Modern world scenario is ever changing. Data Communication and network have changed
the way business and other daily affair works. Now, they highly rely on computer networks
and internetwork.
A set of devices often mentioned as nodes connected by media link is called a Network.
A node can be a device which is capable of sending or receiving data generated by other
nodes on the network like a computer, printer etc. These links connecting the devices are
called Communication channels.
Computer network is a telecommunication channel using which we can share data with
other computers or devices, connected to the same network. It is also called Data Network.
The best example of computer network is Internet.
Computer network does not mean a system with one Control Unit connected to multiple
other systems as its slave. That is Distributed system, not Computer Network.
A network must be able to meet certain criterias, these are mentioned below:
1. Performance
2. Reliability
3. Scalability
It can be measured in the following ways:
 Transit time : It is the time taken to travel a message from one device to another.
 Response time : It is defined as the time elapsed between enquiry and response.
Other ways to measure performance are :
1. Efficiency of software
2. Number of users
3. Capability of connected hardware
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
15
CS 8581 -Networks Laboratory
Pre / Post Assessment Questions
1.Communication between a computer and a keyboard involves ______________
transmission
Ans: Simplex
2.A set of rules that governs data communication
Ans: Protocol
3.Three or more devices share a link in ________ connection
Ans: Multipoint
4.Communication channel is shared by all the machines on the network in
Ans: broadcast network
5.Bluetooth is an example of
Ans: personal area network
6.A __________ is a device that forwards packets between networks by processing the
routing information included in the packet.
Ans: router
7.Network congestion occurs.
Ans: In case of traffic overloading
8.The number of layers in Internet protocol stack
Ans: 5
9.The number of layers in ISO OSI reference model
Ans: 7
10.This layer is an addition to OSI model when compared with TCP IP model
Ans: Session and Presentation layer
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
16
Expt. No: 1 BASIC NETWORKING COMMANDS
Date:
Aim:
To learn about various Basic Networking commands
Procedure / Commands:
Network Commands
Ethtool is a Network Interface Cards (NICs) utility/configuration tool. Ethtool allows you to
query and change your NIC settings such as the Speed, Port, auto-negotiation and many
other parameters.
ifconfig -a
To show the Network Card information
Note down the IP address and MAC Address ( Understand MAC address – IP Address)
Ping ( Packet Internet Gropper)
Verifies IP-level connectivity to another TCP/IP computer by sending Internet Control
Message Protocol (ICMP) Echo Request messages. The receipt of corresponding Echo
Reply messages are displayed, along with round-trip times. Ping is the primary TCP/IP
command used to troubleshoot connectivity, reachability, and name resolution.
To check Local Ethernet Connection
At the command prompt, ping the loopback address by typing ping 127.0.0.1
ping near by system ping <171.16.6.111> ping -c 10 <ipaddress> write observation
ping www.google.com
Arp
Displays and modifies entries in the Address Resolution Protocol (ARP) cache, which
contains one or more tables that are used to store IP addresses and their resolved Ethernet
arp
*Find Machine Gateway Hardware Address-Why it is necessary
Tracert / traceroute - trace Path
Traceroute: Determines the path taken to a destination by sending Internet Control
Message Protocol (ICMP) Echo Request messages to the destination with incrementally
increasing Time to Live (TTL) field values- tracepath similar to traceroute command, but it
doesn't require root privileges
$ traceroute www.google.co.in
$tracepath www.ubidots.com
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
17
Netstat
Displays active TCP connections, ports on which the computer is listening, Ethernet
statistics, the IP routing table, IPv4 statistics (for the IP, ICMP, TCP, and UDP protocols),
and IPv6 statistics (for the IPv6, ICMPv6, TCP over IPv6, and UDP over IPv6 protocols).
Note Down The few TCP UDP ports
nslookup
Nslookup (Name Server lookup) is a UNIX shell command to query Internet domain name
servers.
$nslookup www.annauniv.edu
notedown the IP address Undestand Non-authoritative answer
dig (Domain Information Groper) is a flexible tool for interrogating DNS name servers.
It performs DNS lookups and displays the answers that are returned from the name servers.
$dig geekflare.com
What do you mean by DNS Server .
w prints a summary of the current activity on the system, including what each user is doing,
and their processes.
Also list the logged in users and system load average for the past 1, 5, and 15 minutes.
nmap
nmap is a one of the powerful commands, which checks the opened port on the server.
Usage example:
nmap $server_name
Interface Settings
You can enable or disable the network interface by using ifup/ifdown commands with
ethernet interface parameter.
To disable eth0
$ifdown <eth0> check neighbor connection with PING command what ?
To enable eth0
$ifup <eth0> This command displays domain name for given IP address and displays IP
address for given domain name. It also performs DNS lookups related to DNS query.
host www.thingspeak.com host <ipaddress>
find difference betewwn ipv4 and ipv6
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
18
mtr
The mtr command is a combinatiion of ping and traceroute command. It continuously sends
packet showing ping time for each hop. It also shows network problems.
Syntax: mtr<path> mtr facebook.com see the result & find
observation
The who is command displays information about a website's record. You may get all the
information about a website regarding its registration and owner's information.
Syntax: whois <websiteName>
whois www.gmail.com whois mail.office365.com
Linux curl & wget
These commands are used to download a file from the internet using CLI. With curl
commands option O will be used while wget command will be used without any option. The
file will be saved in the current directory.
Download useful materials
Other Useful command
pwd whoami hostname uname -r
Get some useful linux command -atleast five
tcpdump It allows the user to display TCP/IP and other packets being transmitted or
received over a network to which the computer is attached.
tcpdump -c 5 -i eth0
tcpdump -A S -i eth0
tcpdump -XX -i eth0
tcpdump -n -i eth0
tcpdump -i eth0 tcp/udp
tcpdump -i eth0 dst 172.16.7.186
As per Laboratory Rubrics in Annexure I
CATEGORY
MAX.
MARKS
ALLOTED
MARKS
AWARDED
Design & Logic 40
Code design 40
Record Submission 10
Viva 10
TOTAL 100
Result
The various network commands are executed and their results are recorded
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
19
Expt. No: 2 WEB SCRAPING PROGRAM USING TCP SOCKETS
Date:
Aim:
To write a Python Program to download web page from a server and use
BeautifulSoup package to parse and analyse the web page information.
Procedure
1. Import packages and module for web page download
2. 'Package required are requests and BeautifulSoup
3. The requests package is a more Pythonic replacement for Python’s own urllib.
download web content using requests and giving URL in parameter
syntax : requests.get(URL)
content = requests.get("http://www.google.com")
4. Using BeautifulSoup from bs4 pacakage read the content and display the Title and
content
5. Use the BeautifulSoup parse the web page using HTML parser and list the contents
Program
import requests
import bs4
url = input("Enter the URL:")
obj = requests.get(url)
soup = bs4.BeautifulSoup(obj.text,'lxml')
soup2 = soup.select('style')
print(soup2)
Sample Output:
As per Laboratory Rubrics in Annexure I
CATEGORY
MAX.
MARKS
ALLOTED
MARKS
AWARDED
Design & Logic 40
Code design 40
Record Submission 10
Viva 10
TOTAL 100
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
20
Result:
Thus to write a Python Program to download web page from a server and use
BeautifulSoup package to parse and analyse the web page information was executed
successfully.
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
21
Expt. No: 3 TCP PROGRAMS
Date:
Aim: To write Client Server TCP Programs to implement Chat and Echo
Procedure:
Server Side:
1. import socket # Create a TCP socket for Communication using socket library
2. Socket Creation IV4 /IV6 and TCP / UDP
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
The first parameter is AF_INET the address family ipv4.The SOCK_STREAM
means connection oriented TCP protocol. s is the socket object
3. Bind the Socket with hostname and port
s.bind(('localhost', port))
4. Put the socket into listening mode for client communication upto 5 dedicated links
s.listen(5)
5. Once the Client send a request to connect , accept and establish the connections with
acknowledgement
clientsock,address=s.accept()
6. Server receive client message using recv method and Reply with sendmethod to
client
s.recv(1024)
s.send(message)
7. The process until the client closes the connection
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
22
Client Side:
1. import socket # Create a TCP socket for Communication using socket library
s = socket.socket()
2. Connect the Socket with serverhostname and port
s.connect(('localhost',port))
3. Once the server accept and reply with the connection status.Request send to server
with s.send(message) method and Server message received using s.recv(bytes)
method
4. The process until the client closes the connection
Program
Chat Client:
import socket # Import socket module
s = socket.socket() # Create a socket object
host = socket.gethostname() # Get local machine name
port = 12000 # Reserve a port for your service.
s.connect(('localhost', port)) # Bind to the port
print s.recv(1024)
while True:
msg=raw_input('me:>')
s.send(msg)
rmsg=s.recv(1024)
print(rmsg)
if msg=='bye':
break
s.close()
Chat Server:
import socket # Import socket module
s = socket.socket() # Create a socket object
host = socket.gethostname() # Get local machine name
port = 12000 # Reserve a port for your service.
s.bind(('localhost', port)) # Bind to the port
s.listen(5) # Now wait for client connection.
print('Waiting for connection..')
c, addr = s.accept() # Establish connection with client.
print 'Got connection from', addr
c.send('Thank you for connecting')
while True:
rmsg=c.recv(1024)
print(rmsg)
msg=raw_input('server')
c.send(msg)
if msg=='bye':
break
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
23
c.close() # Close the connection
Sample Output:
SERVER:
student@a4it167:~$ python server.py
Waiting for connection...
Got connection from ('127.0.0.1', 46368)
hi
Server >hello
welcome
Server >
CLIENT:
Thank you for connecting
Client >hi
hello
Client >welcome
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
24
ECHO CLIENT:
import socket # Import socket module
s = socket.socket() # Create a socket object
host = socket.gethostname() # Get local machine name
port = 33334 # Reserve a port for your service.
s.connect(('172.16.7.193', port)) # Bind to the port
print s.recv(1024)
while True:
msg=raw_input('me:>')
s.send(msg)
rmsg=s.recv(1024)
print(rmsg)
if msg=='bye':
break
s.close()
ECHO SERVER:
import socket # Import socket module
s = socket.socket() # Create a socket object
host = socket.gethostname() # Get local machine name
port = 11001 # Reserve a port for your service.
s.bind(('localhost', port)) # Bind to the port
s.listen(5) # Now wait for client connection.
print('Waiting for connection..')
c, addr = s.accept() # Establish connection with client.
print 'Got connection from', addr
c.send('Thank you for connecting')
while True:
rmsg=c.recv(1024)
print(rmsg)
msg=raw_input('server')
c.send(msg)
if msg=='bye':
break
c.close() # Close the connection
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
25
Sample Output:
SERVER:
student@a4it167:~$ python server.py
Waiting for connection...
Got connection from ('127.0.0.1', 46368)
hi
hello
welcome
CLIENT:
Thank you for connecting
Client >hi
hello
Client >welcome
Result
Thus Client Server TCP Programs to implement Chat and Echo is executed and
verified successfully.
As per Laboratory Rubrics in Annexure I
CATEGORY
MAX.
MARKS
ALLOTED
MARKS
AWARDED
AIM & PREPARATION 20
CODING STANDARDS,
BEST PRACTICES &
RESULTS
20
VIVA VOCE 20
RECORD – GRAMMAR &
FORMATTING
20
TIMELY SUBMISSION 20
TOTAL 100
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
26
Aim:
To write a Python program for file transfer protocol
Procedure:
Server Side:
1.Start
2.Create a TCP socket for Communication using socket library
3.Bind the Socket with hostname and port with process
4.Put socket in listening mode for client communication
5.Once the Client send a request to connect , accept and establish the connections with
acknowledgement
6.Get filename
7.Open the file and read the content
8.Close the file.
Client Side:
1.Start
2.Create a TCP socket for Communication using a socket library
3.Bind the Socket with hostname and port with process
4.Connect with server accept and reply with the connection status
5.Request send to server with send() method
6.Open the received file and write
7.Display message as file opened
8.Close and display successfully got the file.
Expt. No: 4 FILE TRANSFER PROTOCOL
Date:
Expt. No: 4 FILE TRANSFER PROTOCOL
Date:
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
27
Program:
SERVER:
import socket
s=socket.socket()
port=8012
host="172.16.6.189"
s.bind((host,port))
s.listen(5)
print'Server listening...'
while True:
conn,addr=s.accept()
print'Got connection from ',addr
data = conn.recv(1024)
print('Server received', repr(data))
filename='serftp.py'
f=open(filename,'rb')
l=f.read(1024)
while (l):
conn.send(l)
print('sent',repr(l))
l=f.read(1024)
if l==''"
break
f.close()
CLIENT:
import socket
s=socket.socket()
host='172.16.6.189'
port=8018
s.connect((host,port))
s.send('Hello Server')
with open('kavi3.py','wb') as f:
print ('File opened')
while True:
print'Receiving data...'
data=s.recv(16)
print('Data=%s',(data))
if not data:
break
f.write(data)
f.close()
print'Seccessfully get the file'
s.close()
print'Connection closed'
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
28
Output
root@a4it167:~# python ex4.py
Server Listening...
Got connection from ('127.0.0.1', 34414)
('Server received', "'hello server..'")
('Sent', '"#!/usr/bin/python nimport
socketns=socket.socket()nhost=socket.gethostname()nport=7001ns.bind(('localhost',
port))ns.listen(5)nprint ('Waiting for connection...')nc, addr = s.accept()nprint 'Got
connection from', addrnc.send('Thank you for connecting')nwhile True:n
cmsg=c.recv(1024)n print(cmsg) n n smsg=raw_input('Server >')n
c.send(smsg)n nc.close()nn"')
root@a4it167:~#
As per Laboratory Rubrics in Annexure I
CATEGORY
MAX.
MARKS
ALLOTED
MARKS
AWARDED
Design & Logic 40
Code design 40
Record Submission 10
Viva 10
TOTAL 100
Result
Thus a Python program for simulating file transfer protocol is executed and verified
successfully.
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
29
Aim:
To write a Python program for simulating ARP/RARP protocols using TCP
Procedure:
Server
1. Start the program
2. create a list with macaddress and ipaddress
3. import pandas and store the csv file as dataframe
4. Create a socket using socket class bind with the 'ServerIPaddress' and PortNo.
5. Listen for client Request
6. Accept the socket which is created by the client.
7. Server maintains the table in which IP and corresponding MAC addresses are stored.
8. Read the IP address which is send by the client.
9. Map the IP address with its MAC address and return the MAC address to client.
10. Do the same for RARP - MAC ADDRESS to IPADDRESS
Client
1. Start the program
2. Create the Socket with server
3. Using socket connection is established between client and server.
4. Get the IP address to be converted into MAC address
5. Send this IP address to server.
6. Server returns the MAC address to client if is is available else Display unreachable.
7. Do the same for RARP - Send MAC ADDRESS and get IPADDRESS
8. Server returns the IP address to client if is is available else Display Not Found.
Expt. No: 5 SIMULATION OF ARP AND RARP USING TCP
Date:
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
30
Program:
Server
#!/usr/bin/python # This is server.py file
import socket # Import socket module
s = socket.socket() # Create a socket object
host = socket.gethostname() # Get local machine name
port = 4062 # Reserve a port for your service.
s.bind(('localhost', port)) # Bind to the port
s.listen(5)
print("waiting for client connection") # Now wait for client connection.
c, addr = s.accept() # Establish connection with client.
print 'Got connection from', addr
c.send('Thank you for connecting')
iplist=['172.16.7.167','172.16.7.168','172.16.7.166','172.16.7.170','172.16.7.165']
maclist=['f8:bc:12:86:31:c0','f8:bc:12:86:bd:c7','f8:bc:12:86:bd:c8','f8:bc:12:86:bf:c7','f8:bc:
12:86:bc:c8']
while True:
data=c.recv(1024)
if data in maclist:
i=maclist.index(data)
c.send(iplist[i])
print "Found"
else:
print "not found"
c.close() # Close the connection
Client
#!/usr/bin/python # This is server.py file
import socket # Import socket module
s = socket.socket() # Create a socket object
host = socket.gethostname() # Get local machine name
port = 4062 # Reserve a port for your service.
s.connect(('localhost',port))
while True:
cmsg=s.recv(1024)
print(cmsg)
msg=raw_input('CONNECTION REQUEST>')
s.send(msg)
if msg=='bye':
break
s.close() # Close the connection
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
31
Sample Output
student@a4it167:~$ python arpserver.py
waiting for client connection
Got connection from ('127.0.0.1', 38698)
Found
not found
student@a4it167:~$ python clientarp.py
Thank you for connecting
CONNECTION REQUEST>f8:bc:12:86:31:c0
172.16.7.167
CONNECTION REQUEST>f8:bc:12:86:31:c9
As per Laboratory Rubrics in Annexure I
CATEGORY
MAX.
MARKS
ALLOTED
MARKS
AWARDED
Design & Logic 40
Code design 40
Record Submission 10
Viva 10
TOTAL 100
Result
Thus python program for simulating ARP/RARP protocols using TCP is executed
and verified successfully
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
32
Aim:
To write a Python program for simulating DNS protocols using TCP
Procedure:
Server
1. Start the program
2. create a list with IPlist and weblist
3. import pandas and store the csv file as dataframe
4. Create a socket using socket class bind with the 'ServerIPaddress' and PortNo.
5. Listen for client Request
6. Accept the socket which is created by the client.
7. Server maintains the table in which IP and corresponding MAC addresses are stored.
8. Read the IP address which is send by the client.
9. Map the IP address with its MAC address and return the MAC address to client.
10. Do the same for RARP - MAC ADDRESS to IPADDRESS
Client
1. Start the program
2. Create the Socket with server
3. Using socket connection is established between client and server.
4. Get the IP address to be converted into MAC address
5. Send this IP address to server.
6. Server returns the MAC address to client if is is available else Display unreachable.
7. Do the same for RARP - Send MAC ADDRESS and get IPADDRESS
8. Server returns the IP address to client if is is available else Display Not Found.
Expt. No: 6 SIMULATION OF DNS USING TCP
Date:
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
33
Program:
server
#!/usr/bin/python # This is server.py file
import socket # Import socket module
s = socket.socket() # Create a socket object
host = socket.gethostname() # Get local machine name
port = 40841 # Reserve a port for your service.
s.bind(('localhost', port)) # Bind to the port
s.listen(5)
print("waiting for client connection") # Now wait for client connection.
c, addr = s.accept() # Establish connection with client.
print 'Got connection from', addr
c.send('Thank you for connecting')
iplist=['172.16.7.167','172.16.7.168','172.16.7.166','172.16.7.170','172.16.7.165']
weblist=['www.google.com','www.yahoo.com','www.gmail.com']
while True:
data=c.recv(1024)
if data in weblist:
i=weblist.index(data)
c.send(iplist[i])
print "Found"
else:
print "not found"
c.close() # Close the connection
Client
#!/usr/bin/python # This is server.py file
import socket # Import socket module
s = socket.socket() # Create a socket object
host = socket.gethostname() # Get local machine name
port = 40841 # Reserve a port for your service.
s.connect(('localhost',port))
while True:
cmsg=s.recv(1024)
print(cmsg)
msg=raw_input('CONNECTION REQUEST>')
s.send(msg)
if msg=='bye':
break
s.close() # Close the connection
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
34
Sample Output:
student@a4it167:~$ python arpserver.py
waiting for client connection
Got connection from ('127.0.0.1', 36631)
Found
Found
Found
not found
student@a4it167:~$ python clientarp.py
Thank you for connecting
CONNECTION REQUEST>www.google.com
172.16.7.167
CONNECTION REQUEST>www.yahoo.com
172.16.7.168
CONNECTION REQUEST>www.gmail.com
172.16.7.166
CONNECTION REQUEST>www.bing.com
As per Laboratory Rubrics in Annexure I
CATEGORY
MAX.
MARKS
ALLOTED
MARKS
AWARDED
Design & Logic 40
Code design 40
Record Submission 10
Viva 10
TOTAL 100
Result
Thus python program for simulating DNS protocols using TCP is executed and
verified successfully
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
35
Aim:
To write a python program for simulation of error correction code (parity checker)
Procedure:
1. Enter the decimal number
2. Convert the decimal number to binary.
3. Blocks of data from the source are subjected to a check bit or parity bit generator
form, where a parity of :
 1 is added to the block if it contains odd number of 1’s, and
 0 is added if it contains even number of 1’s
Program:
Server
import socket
s=socket.socket()
host=socket.gethostname()
port=6320
s.bind(('localhost',port))
s.listen(5)
print('waiting for client connection')
c, addr=s.accept()
print 'Got connection from', addr
c.send("Thank u for connecting...")
while True:
data=c.recv(1024)
if(data.count('1')%2!=0):
c.send('accepted')
else:
c.send('rejected')
c.close()
Expt. No: 7 SIMULATION OF ERROR CORRECTION CODE
(PARITY CHECKER)
Date:
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
36
Client
import socket
import random
s=socket.socket()
host=socket.gethostname()
port=6320
s.connect(('localhost',port))
print(s.recv(1024))
bin=bin(29)
while True:
bin=("Get a number")
n=bin.count('1')
if(n%2==0):
bin=bin+'1'
else:
bin=bin+'0'
c=random.randint(0,1)
if(c==1):
s.send(bin)
else:
s.send(bin+'1')
smsg=s.recv(1024)
print(smsg)
if're' in smsg:
smsg=s.recv(1024)
print(smsg)
s.close()
Sample Output:
student@a4it167:~$ python parity.py
waiting for client connection
Got connection from ('127.0.0.1', 48836)
student@a4it167:~$ python pclient.py
Thank u for connecting...
rejected
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
37
As per Laboratory Rubrics in Annexure I
CATEGORY
MAX.
MARKS
ALLOTED
MARKS
AWARDED
Design & Logic 40
Code design 40
Record Submission 10
Viva 10
TOTAL 100
Result
Thus a python program for simulation of error correction code (parity checker) is
executed and verified successfully
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
38
Aim:
To write a python program for FTP file transfer using UDP algorithm.
Procedure:
Server
1. Start the program.
2. Create a UDP socket for communication using socket library.
3. Bind the socket with UDP_IP and IN_PORT with process.
4. Put socket in waiting for input file upload.
5. Once a client send a request to connect, accept and establish connection
acknowledgment.
6. Get file name and read the content and send the content of file.
7. close the file.
Client
1. Start the program.
2. Create a UDP socket for communication using socket library.
3. Socket is send with filename UDP_IP and UDP_PORT.
4. Request is sent to server with send method.
5. Open the new file and write.
6. Display message as filename Finish!
Program:
server
import socket
import select
UDP_IP="127.0.0.1"
IN_PORT=5016
timeout=3
sock=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
sock.bind((UDP_IP,IN_PORT))
print("Waiting for client file upload")
while True:
data,addr=sock.recvfrom(1024)
if data:
print("file_name:",data)
file_name=data.strip()
file_name=file_name.decode()
file_name="17uit071"+file_name
print(file_name)
f=open(file_name,'wb')
Expt. No: 8 SIMULATION OF FTP PROTOCOL USING UDP
Date:
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
39
while True:
ready=select.select([sock],[],[],timeout)
if ready[0]:
data,addr=sock.recvfrom(1024)
print(data)
f.write(data)
else:
print("%s Finish!"%file_name)
f.close()
break
Client
import socket
import time
import sys
UDP_IP="127.0.0.1"
UDP_PORT=5016
buf=1024
file_name=sys.argv[0]
file_name=file_name.encode()
sock=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
sock.sendto(file_name,(UDP_IP,UDP_PORT))
print("sending %s...."%file_name)
f=open(file_name,"rb")
data=f.read(buf)
while(data):
if(sock.sendto(data,(UDP_IP,UDP_PORT))):
data=f.read(buf)
print(data)
time.sleep(0.02)#Give receiver a bit time to save
sock.close()
f.close()
Sample Output:
student@a4it166:~$ python ex8client.py
sending ex8client.py....
student@a4it166:~$
student@a4it166:~$ python ex8server.py
Waiting for client file upload
('file_name:', 'ex8client.py')
17uit001ex8client.py
import socket
import time
import sys
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
40
UDP_IP="127.0.0.1"
UDP_PORT=5016
buf=1024
file_name=sys.argv[0]
file_name=file_name.encode()
sock=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
sock.sendto(file_name,(UDP_IP,UDP_PORT))
print("sending %s...."%file_name)
f=open(file_name,"rb")
data=f.read(buf)
while(data):
if(sock.sendto(data,(UDP_IP,UDP_PORT))):
data=f.read(buf)
print(data)
time.sleep(0.02)#Give receiver a bit time to save
sock.close()
f.close()
17uit001ex8client.py Finish!
As per Laboratory Rubrics in Annexure I
CATEGORY
MAX.
MARKS
ALLOTED
MARKS
AWARDED
Design & Logic 40
Code design 40
Record Submission 10
Viva 10
TOTAL 100
Result
Thus a python program for FTP file transfer using UDP algorithm. is executed and
verified successfully.
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
41
Aim:
To study network simulator 2
Study of NS2:
Introduction:
The network simulator is discrete event packet level simulator. The network
simulator covers a very large number of application of different kind of protocols of
different network types consisting of different network elements and traffic models.
Network simulator is a package oftools that simulates behaviour of networks such as
creating network topologies, log events that happen under any load, analyse the eventsand
understand the network
Platform required to run the network simulator
• Unix and Unix like systems
• Linux(Use Fedora or Ubuntu version)
• Windows 95/98/NT/2000/XP
Backend Environment of network simulator
Network simulator is mainly based on two languages. They are C++ and OTcl. OTcl is the
object oriented version of Tool Command language. The network simulator is a bank of
different network and protocol objects. C++ helps in the following way:
• It helps to increase the efficiency of simulation
• It is used to provide details of the protocols and their operation
• It is used to reduce packet and event processing time OTcl helps in the following
way:
• With the help of OTcl we can describe different network topologies
• it helps us to specify the protocols and their applications
• It allows fast development
• Tcl is compatible with many platforms and it is flexible for integration
• Tcl is very easy to use and it is available for free
Basics of Tcl Programming (w.r.t NS2)
Before we get into the program we should consider the following things:
1. Initialisation and termination aspects of network simulator
2. Defining the network nodes, links, queues and topology as well
3. Defining the agents and their applications
4. Network adminiatrator(NAM)
5. Tracing
Expt. No: 9 STUDY OF NETWORK SIMULATOR 2, NETWORK
TOPOLOGIES AND CONGESTION CONTROL
Date:
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
42
Initialisation:
To start a new simulator we write
set ns[new simulator]
From the above we get that a variable ns is being initialised by using a set command.
Here the code [new simulator] is a instantiation of the class Simulator which uses the
reserved word ‘new’. So we can call all the methods present inside the class simulator by
using the variable ns
Creating the output files
# To create the trace files we write
set tracefile1[open out.tr w]
$ns trace-all $tracefile1
#To create the nam files we write
set namfile1[open out.nam w]
$ns namtrace-all $namfile1
In the above we create a output trace file out.tr and a NAM visualisation file out.nam. But
in the Tcl script they are not called by their names declared, while they are called by the
pointers initialised for them such as tracefile1 and namfile1 respectively. The line which
starts with ‘#’ are commented. The next line opens the file ‘out.tr’ which is used for writing
is declared ‘w’. The next line uses a simulator method trace-all by which we will trace all
the events in a particular format. The termination program is done by using a ‘finish’
procedure.
#Defining the ‘finish’ procedure
proc finish { }
{
global ns tracefile1 namfile1
$ns flush-trace
close $tracefile
close $namfile
exec nam out.nam &
exit 0
}
In the above the word ‘proc’ is used to declare a procedure called ‘finish’. The word
‘global’ is used to tell what variables are being used outside the procedure. ‘flush-trace’ is a
simulator method that dumps the traces on the respective files. The command ‘close’ is used
to close the trace files and the command ‘exec’ is used to execute the nam visualisation. The
command ‘exit’ closes the application and returns 0 as zero(0) is default for clean exit.
In ns we end the program by calling the ‘finish’ procedure
#end the program
$ns at 125.0 “finish”
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
43
Thus the entire operation ends at 125 seconds. To begin the simulation we will use the
command
#start the simulation process
$ns run
Defining nodes, links, queues and topology
Create a node:
set n0[ns node]
In the above we created a node that is pointed by a variable n0. While referring the
node in the script we use $n0. Similarly we create another node n2.
Now we will set a link between the two nodes.
$ns duplex-link $n0 $n2 10Mb 10ms DropTail
Here, a bi-directional link is created between n0 and n2 with a capacity of 10Mb.sec
and a propagation delay of 10ms.In NS an output queue of a node is implemented as a part
of a link whose input is that node to handle the overflow at the queue. But if the buffer
capacity of the output queue is exceeded then the last packet arrived is dropped and here the
‘DropTail’ option is used. Many other options such as RED(Random Early Discard)
mechanism, FQ(Fair Queuing), DRR(Deficit Round Robin), SFQ(Stochastic Fair
Queuing)are available.
Now we will define the buffer capacity of the queue related to the above link
#Set queue size of the link
$ns queue-link $n0 $n2 20
Summarizing the above three things we get
#create nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
set n5 [$ns node]
#create links between the nodes
$ns duplex-link $n0 $n2 10Mb 10ms DropTail
$ns duplex-link $n1 $n2 10Mb 10ms DropTail
$ns duplex-link $n2 $n3 0.3Mb 100ms DropTail
$ns duplex-link $n3 $n2 0.3Mb 100ms DropTail
$ns duplex-link $n0 $n2 0.5Mb 40ms DropTail
$ns duplex-link $n0 $n2 0.5Mb 40ms DropTail
#set queue-size of the link (n2-n3) to 20
$ns queue-limit $n2 $n3 20
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
44
Agents and application
TCP
TCP is a dynamic reliable congestion protocol which is used to provide reliable transport of
packets from one host to another host by sending acknowledgements on proper transfer or
loss of packets. Thus TCP requires bi-directional links in order for acknowledgements to
return to the source.
Now we will show how to set up tcp connection between two nodes
#setting a tcp connection
set tcp [new Agent/TCP]
$ns attach-agent $n0 $tcp
set sink [new Agent/TCPSink]
$ns attach-agent $n4 $sink
$ns connect $tcp $sink
$tcp set fid_1
$tcp set packetSize_552
The command ‘set tcp [new Agent/TCP]’ gives a pointer called ‘tcp’ which indicates the tcp
agent which is a object of ns. Then the command ‘$ns attach-agent $n0 $tcp’ defines the
source node of tcp connection. Next the command ‘set sink[new Agent/TCPSink]’ defines
the destination of tcp by a pointer called sink. The next command ‘$ns attach-agent $n4
$sink’ defines the destination node as n4. Next the command ‘$ns connect $tcp $sink’
makes the TCP connection between the source and the destination. i.e n0 and n4. When we
have several flows such as TCP, UDP etc in a network. So,to identify these flows we
ark these flows by using the command ‘$tcp set fid_1’. In the last line we set the
packet size of tcp as 552 while the default packet size of tcp is 1000.
FTP over TCP
File Transfer Protocol(FTP) is a standard mechanism provided by the Internet for
transferring files from one host to another. Well, This is the most common task expected
from a networking or a internetworking. FTP differs from other client server applications in
that it establishes between the client and the server. One connection is used for data
transfer and other one is used for providing control information. FTP uses the services of the
TCP. It needs two connections. The well known port 21 is used for control connections and
the other port 20 is used for data transfer.
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
45
Well here we will learn in how to run a FTP connection over a TCP
#Initiating FTP over TCP
set ftp [new Application/FTP]
$ftp attach-agent $tcp
In above, the command ‘set ftp [new Application/FTP]’ gives a pointer called ftp
which indicates the FTP application. Next we attach the ftp application with tcp agent as
FTP uses the services of TCP
UDP
The User data protocol is one of the main protocols of the internet protocol suite.
UDP helps the host to send messages in the form of datagrams to another host which is
present in a Internet protocol network without any kind of requirement for channel
transmission setup. UDP provides a unreliable service and the datagrams may arrive out of
order, appear duplicated or go missing without notice. UDP asumes that error checking and
correction is either not necessary or performed in the application avoiding the overhead of
such processing at the network interface level. Time sensitive applications often use UDP
because dropping packets is preferable to waiting for delayed packets, which may not
be an option in a real-time system .
Now we will learn how to create a UDP connection in network simulator
#setup a UDP connection
set udp [new Agemt/UDP]
$ns attach-agent $n1 $udp
$set null [new Agent/Null]
$ns attach-agent $n5 $null
$ns connect $udp $null
$udp set fid_2
Similarly, the command ‘set udp [new Agent/UDP]’ gives a pointer called ‘udp’
which indicates the udp agent which is an object of ns. Then the command ‘$ns attach-agent
$n1 $udp’ defines the source node of udp connection. Next the command ‘set null [new
Agent/Null]’ defines the destination of udp by a pointer called null. The next command ‘$ns
attach-agent $n5 $null’ defines the destination node as n5. Next, the command ‘$ns
connect $udp $null’ makes the UDP connection between the source and the destination. i.e
n1 and n5. When we have several flows such as TCP,UDP etc in a network. So, to identify
these flows we mark these flows by using the command ‘$udp set fid_2’
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
46
Constant Bit Rate(CBR)
Constant Bit rate(CBR) is a term used in telecommunications, relating to the quality
of service. When referring to codecs, constant bit rate encoding means that the rate at which
a codec’s output data should be consumed is constant. CBR is useful for streaming
multimedia content on limited capacity channels since it is the maximum bit rate that
matters, not the average, so CBR would be used to take advantage of all of the capacity.
CBR would not be the optimal choice for storage as it would not allocate enough data for
complex sections (resulting in degraded quality) while wasting data on simple sections.
CBR over UDP connection
#setup cbr over udp
set cbr [new Application/Traffic/CBR]
$cbr attach-agent $udp
$cbr set packetSize_1000
$cbr set rate_0.01Mb
$cbr set random_false
In the above we define CBR connection over a UDP one. Well we have already defined
the UDP source and UDP agent as same as TCP. Instead of defining the rate we define the
time interval between the transmission of packets in the command ‘$cbr set
rate_0.01Mb’. Next, with the help of the command ‘$cbr set random_false’ we can set
random noise in cbr traffic, we can keep the noise by setting it to false or we can set the
noise on by the command ‘$cbr set random_1’. We an set by packet size by using the
command ‘$cbr set packetSize_(packet size). We can set the packet size up to sum value in
bytes.
Scheduling events
In ns the tcl script defines how to schedule events or in other words at what time which
event will occur and stop. This can be done using the commands
‘$ns at’
So here in our program we will schedule the ftp and cbr.
1 #scheduling the events
2 $ns at 0.1 “cbr start”
3 $ns at 1.0 “ftp start”
4 $ns at 124.0 “ftp stop”
5 $ns at 124.5 “cbr stop”
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
47
Network Animator (NAM)
When we will run the above program in ns then we can visualise the network in the NAM.
But instead of giving random positions to the nodes we can give suitable initial positions to
the nodes and can form a suitable topology. So, in our program we can give positions to the
nodes in NAM in the following way
#Give position to the nodes in NAM
$ns duplex_link_op $n0 $n2 orient-right-down
$ns duplex_link_op $n1 $n2 orient-right-up
$ns duplex_link_op $n2 $n3 orient-right
$ns duplex_link_op $n3 $n2 orient-left
$ns duplex_link_op $n3 $n4 orient-right-up
$ns duplex_link_op $n3 $n5 orient-right-down
We can also define the colour of cbr and tcp packets for identification in
NAM. For this we use the following command.
#Marking the flows
$ns color1 Blue
$ns color2 Red
To view the network animator we need to type the command: nam
Tracing
Tracing Objects
NS simulation can produce visualization trace as well as ASCII file corresponding to the
events that are registered at the network. While tracing ns inserts the objects: EnqT, DeqT,
RecvT & DrpT. EnqT registers information regarding the arrival of packet and is queued at
the input queue of the link. When the overflow of a packet occurs, then the information of
the dropped packet is registered n DrpT. DeqT holds the information about the packet that
is dequeued instantly. RecvT hold the information about the packet that has been received
instanty.
Event Time From
node
To
node
Pkt
type
Pkt
size
Flags Fid Src
addr
Dst
addr
Seq
num
Pkt id
Structure of Trace files
1. The first field is event. It gives you tfour possible symbols ‘+’,’-‘,’r’,’d’.
These four symbols correspond respectively to enqueued, dequeued, received
and dropped.
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
48
2. The second field gives the time at which the event occurs.
3. The third gives you the input node of the link at which the event occurs
4. The fourth gives you the output node at which the event occurs
5. The fifth shows the information about the packet .i.e whether the packet is
UDP or TCP
6. The sixth gives the packet size
7. The seventh field gives information about some flags
8. The eighth field is the flow id(fid) for IPv6 that a user can set for each flow in
tcl script. It is also used for specifying the color of flow in NAM display
9. The ninth field is the source address
10.The tenth field is the destination address
11.The eleventh field is the network layer protocol’s packet sequence number
12.The last field shows the unique id of the packet
Following are trace of two events:
r 1.84471 2 1 cbr 210 ------- 1 3 .0 1.0 195 600
r 1.84566 2 0 ack 40 ------- 2 3.2 0.1 82 602
The trace file can be viewed with the cat command:
cat out.tr
The Network Animator (NAM) tool:
• The Network Animator(nam) is a completely separate program that is distributed with
NS simulator
• This program is named nam and it shows the progression of the packets through the
network.
.NAM FILE:
• The nam program reads an input file(containing the packet transmission events) and
draw the network events graphically.
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
49
Make NS output network event information for NAM:
The steps to create a nam file are given below:
Create an output file
Activate the NAM trace failure in NS before running the simulation (this will
tell NS to write NAM events output to the output file). Close the output file at
the end of the simulation run. Then the nam file is run with the output file (as
input file for nam)
Here is an example of code in Tcl to achieve this:
#(1) Create the trace file
set namfile [open out.nam w]
#(2) Tell NS to write NAM network events to this trace file
$ns namtrace-all $namfile
#(3) Close output file at the end of the simulation run
proc finish {} {
global ns namfile
$ns flush-trace ;# flush trace files
close $namfile ;#close trace file
exec nam out.nam & ;
# run NAM from inside the NS simulation
exit 0
}
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
50
XGRAPH
The xgraph program draws a graph on an X display given data read from either data
files or from standard input if no files are specified. It can display up to 64 independent data
sets using different colors and/or line styles for each set. It annotates the graph with a title,
axis labels, grid lines or tick arks, grid labels and a legend.There are options to control the
appearance of most components of the graph. A data set consists of an ordered list of points
of the form “directive X Y”. For directive “draw”, a line will be drawn between the previous
point and the current point. Specifying a “ move” directive tells xgraph not to draw a line
between the points. “draw” is the default directive. The name of a data set can be specified
by enclosing the name in double quotes. Overall graphing options for the graph can be
specified in data files by writing lines of the form “¡option¿: ¡ value¿”. The interface used to
specify the size and location of this window depends on the window manager currently in
use. Once the window has been opened, all of the data sets will be displayed graphically
with a legend in the upper right corner of the screen.Xgraph also presents three control
buttons in the upper left corner of each window: Hardcopy, Close and About Xgraph
accepts a large number of options most of which can be specified either on the command
line, in the user’s .Xdefaults or .Xresources file, or in the data files themselves.
Suppose we have three output files as follows:
Now we have to open three output files. The following lines have to appear ‘early’ in
the Tcl script.
set f0 [open out0.tr w]
set f1 [open out1.tr w]
set f2 [open out2.tr w]
These files have to be closed at some point. We use a modified ‘finish’
procedure to do that.
proc finish{} {
global f0 f1 f2
#close the output files
close $f0
close $f1
close $f2
#Call xgraph to display the results
exec xgraph out0.tr out1.tr out2.tr –geometry 800x400 &
exit 0
}
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
51
Procedure:
 Open vi editor and type program. Program name should have the extension “ .tcl”
[root@localhost ~]# vi lab1.tcl
 Save the program by pressing “ESC key” first, followed by “Shift and :” keys
simultaneously and type “wq” and press Enter key.
 Open vi editor and type awk program. Program name should have the extension
“.awk ”
[root@localhost ~]# vi lab1.awk
 Save the program by pressing “ESC key” first, followed by “Shift and :” keys
simultaneously and type “wq” and press Enter key.
 Run the simulation program
[root@localhost~]# ns lab1.tcl
 Here “ns” indicates network simulator. We get the topology shown in the snapshot.
 Now press the play button in the simulation window and the simulation will begins.
 After simulation is completed run awk file to see the output ,
[root@localhost~]# awk –f lab1.awk lab1.tr
[root@localhost~]# vi lab1.tr
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
52
Program:
set ns [new Simulator]
set nf [open PA1.nam w]
$ns namtrace-all $nf
set tf [open PA1.tr w]
$ns trace-all $tf
proc finish { } {
global ns nf tf
$ns flush-trace
close $nf
close $tf
exec nam PA1.nam &
exit 0
}
set n0 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
$ns duplex-link $n0 $n2 200Mb 10ms DropTail
$ns duplex-link $n2 $n3 1Mb 1000ms DropTail
$ns queue-limit $n0 $n2 10
set udp0 [new Agent/UDP]
$ns attach-agent $n0 $udp0
set cbr0 [new Application/Traffic/CBR]
$cbr0 set packetSize_ 500
$cbr0 set interval_ 0.005
$cbr0 attach-agent $udp0
set null0 [new Agent/Null]
$ns attach-agent $n3 $null0
$ns connect $udp0 $null0
$ns at 0.1 "$cbr0 start"
$ns at 1.0 "finish"
$ns run
Output:
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
53
As per Laboratory Rubrics in Annexure I
CATEGORY
MAX.
MARKS
ALLOTED
MARKS
AWARDED
Design & Logic 40
Code design 40
Record Submission 10
Viva 10
TOTAL 100
Result
Thus NS2 simulator is executed and verified successfully.
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
54
Aim:
To write program to implement routing protocol.
 Distance vector
 OSPF
RIP ROUTING PROTOCOL
1. Distance vector routing is distributed, i.e., algorithm is run on all nodes.
2. Each node knows the distance (cost) to each of its directly connected neighbors.
3. Nodes construct a vector (Destination, Cost,NextHop) and distributes to its
neighbors.
4. Nodes compute routing table of minimum distance to every other node via NextHop
using information obtained from its neighbors.
Initial State
4. In given network, cost of each link is 1 hop.
5. Each node sets a distance of 1 (hop) to its immediate neighbor and cost to itself as 0.
6. Distance for non-neighbors is marked as unreachable with value ∞ (infinity).
7. For node A, nodes B, C, E and F are reachable, whereas nodes D and G are
unreachable.
Destination Cost NextHop Destination Cost NextHop Destination Cost NextHop
A 0 A A 1 A A 1 A
B 1 B B 1 B B ∞ ―
C 1 C C 0 C C ∞ ―
D ∞ — D 1 D D ∞ ―
E 1 E E ∞ ― E ∞ ―
F 1 F F ∞ ― F 0 F
G ∞ ― G ∞ ― G 1 G
Node A's initial table Node C's initial table Node F's initial table
Expt. No: 11 SIMULATION OF ROUTING PROTOCOL USING NS2
Date:
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
55
Sharing & Updation
Each node sends its initial table (distance vector) to neighbors and receives their estimate.
Node A sends its table to nodes B, C, E & F and receives tables from nodes B, C, E & F.
Each node updates its routing table by comparing with each of its neighbor's table
For each destination, Total Cost is computed as:
TotalCost = Cost (Node to Neighbor) + Cost (Neighbor to Destination)
If TotalCost<Cost then
Cost = TotalCost and NextHop = Neighbor
Node A learns from C's table to reach node D and from F's table to reach node G.
Total Cost to reach node D via C = Cost (A to C) + Cost(C to D) = 1 + 1 = 2. Since 2
< ∞, entry for destination D in A's table is changed to (D, 2, C)
Total Cost to reach node G via F = Cost(A to F) + Cost(F to G) = 1 + 1 = 2
Since 2 < ∞, entry for destination G in A's table is changed to (G, 2, F)
Each node builds complete routing table after few exchanges amongst its neighbors.
Open shortest path first (OSPF)
An area is a group of contiguous network and routers. Routers belonging to same
area shares a common topology table and area I’d. The area I’d is associated with router’s
interface as a router can belong to more than one area. There are some roles of router in
OSPF:
1. Backbone router – The area 0 is known as backbone area and the routers in area 0
are known as backbone routers. If the routers exists partially in the area 0then also it
is a backbone router.
2. Internal router – An internal router is a router which have all of its interfaces in a
single area.
3. Area Boundary Router (ABR) – The router which connects backbone area with
another area is called Area Boundary Router. It belongs to more than one area. The
ABRs therefore maintain multiple link-state databases that describe both the
backbone topology and the topology of the other areas.
4. 4.Area Summary Border Router (ASBR) – When an OSPF router is connected to
a different protocol like EIGRP, or Border Gateway Protocol, or any other routing
protocol then it is known as AS. The router which connects two different AS (in
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
56
which one of the interface is operating OSPF) is known as Area Summary Border
Router. These routers perform redistribution. ASBRs run both OSPF and another
routing protocol, such as RIP or BGP. ASBRs advertise the exchanged external
routing information throughout their
Link State Routing and construct the least cost tree for the following graph and
explain the working of OSPF.
 Each node knows state of link to its neighbors and cost.
 Nodes create an update packet called link-state packet (LSP) that
contains: IDof the node
o List of neighbors for that node and associated
cost o 64-bit Sequence number
o Time to live
 Link-state routing protocols rely on two mechanisms:
o Reliable dissemination of link-state information to all other
nodes o Route calculation from the accumulated link-state
knowledge
Apply Link State Routing and construct the least cost tree for the following graph and
explain the working of OSPF.
 Each node knows state of link to its neighbors and cost.
 Nodes create an update packet called link-state packet (LSP) that
contains: o ID of the node
o List of neighbors for that node and associated
cost o 64-bit Sequence number
o Time to live
 Link-state routing protocols rely on two mechanisms:
o Reliable dissemination of link-state information to all other
nodes o Route calculation from the accumulated link-state
knowledge
Reliable Flooding
 Each node sends its LSP out on each of its directly connected links.
 When a node receives LSP of another node, checks if it has an LSP already for that
node. o If not, it stores and forwards the LSP on all other links except the
incoming one. o Else if the received LSP has a bigger sequence number, then it
is stored and
forwarded. Older LSP for that node is discarded.
o Otherwise discard the received LSP, since it is not latest for that node.
Thus recent LSP of a node eventually reaches all nodes, i.e., reliable flooding.
(a) (b) (c) (d)
Flooding of LSP in a small network is as follows:
o When node X receives Y’s LSP (fig a), it floods onto its neighbors A and C
(fig o Nodes A and C forward it to B, but does not sends it back to X (fig c).
o Node B receives two copies of LSP with same sequence number.
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
57
 Accepts one LSP and forwards it to D (fig d). Flooding is complete.
LSP is generated either periodically or when there is a change in the topology.
Route Calculation
Each node knows the entire topology, once it has LSP from every other node.
Forward search algorithm is used to compute routing table from the received LSPs.
Each node maintains two lists, namely Tentative and Confirmed with entries of the form
(Destination, Cost, NextHop).
Forward Search algorithm (Djkstra’s Shortest Path)
 Initialize the Confirmed list with an entry for the Node (Cost = 0).
 Node just added to Confirmed list is called Next. Its LSP is examined.
 For each neighbor of Next, calculate cost to reach each neighbor as Cost (Node to
Next) +
Cost (NexttoNeighbor).
 If Neighbor is neither in Confirmed nor in Tentative list, then add (Neighbor,
Cost, NextHop) to Tentative list.
 If Neighbor is in Tentative list, and Cost is less than existing cost, then
replace the entry with (Neighbor, Cost, NextHop).
 If Tentative list is empty then Stop, otherwise move least cost entry from Tentative
list to Confirmed list. Go to Step 2.
Procedure:
 Open vi editor and type program. Program name should have the extension “ .tcl”
[root@localhost ~]# vi lab1.tcl
 Save the program by pressing “ESC key” first, followed by “Shift and :” keys
simultaneously and type “wq” and press Enter key.
 Open vi editor and type awk program. Program name should have the extension
“.awk ”
[root@localhost ~]# vi lab1.awk
 Save the program by pressing “ESC key” first, followed by “Shift and :” keys
simultaneously and type “wq” and press Enter key.
 Run the simulation program
[root@localhost~]# ns lab1.tcl
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
58
 Here “ns” indicates network simulator. We get the topology shown in the snapshot.
 Now press the play button in the simulation window and the simulation will begins.
 After simulation is completed run awk file to see the output ,
[root@localhost~]# awk –f lab1.awk lab1.tr
[root@localhost~]# vi lab1.tr
Program:
Distance vector
set ns [new Simulator]
set nf [open out.nam w]
$ns namtrace-all $nf
set tr [open out.tr w]
$ns trace-all $tr
proc finish { } {
global nf ns tr
$ns flush-trace
close $tr
exec nam out.nam &
exit 0
}
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
set n5 [$ns node]
$ns duplex-link $n0 $n1 10Mb 10ms DropTail
$ns duplex-link $n1 $n3 10Mb 10ms DropTail
$ns duplex-link $n2 $n1 10Mb 10ms DropTail
$ns duplex-link $n2 $n4 10Mb 10ms DropTail
$ns duplex-link $n4 $n5 10Mb 10ms DropTail
$ns duplex-link $n5 $n3 10Mb 10ms DropTail
$ns duplex-link-op $n0 $n1 orient right-down
$ns duplex-link-op $n1 $n3 orient right
$ns duplex-link-op $n2 $n1 orient right-up
set tcp [new Agent/TCP]
$ns attach-agent $n0 $tcp
set ftp [new Application/FTP]
$ftp attach-agent $tcp
set sink [new Agent/TCPSink]
$ns attach-agent $n3 $sink
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
59
set udp [new Agent/UDP]
$ns attach-agent $n2 $udp
set cbr [new Application/Traffic/CBR]
$cbr attach-agent $udp
set null [new Agent/Null]
$ns attach-agent $n3 $null
$ns connect $tcp $sink
$ns connect $udp $null
$ns rtmodel-at 1.0 down $n1 $n3
$ns rtmodel-at 2.0 up $n1 $n3
$ns rtmodel-at 4.0 down $n1 $n3
$ns rtproto DV
$ns at 0.5 "$ftp start"
$ns at 0.0 "$cbr start"
$ns at 5.0 "finish"
$ns run
Output:
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
60
OSPF
Program
set ns [new Simulator]
set nr [open thro.tr w]
$ns trace-all $nr
set nf [open thro.nam w]
$ns namtrace-all $nf
proc finish { } {
global ns nr nf
$ns flush-trace
close $nf
close $nr
exec nam thro.nam &
exit 0
}
for { set i 0 } { $i < 12} { incr i 1 } {
set n($i) [$ns node]}
for {set i 0} {$i < 8} {incr i} {
$ns duplex-link $n($i) $n([expr $i+1]) 1Mb 10ms DropTail }
$ns duplex-link $n(0) $n(8) 1Mb 10ms DropTail
$ns duplex-link $n(1) $n(10) 1Mb 10ms DropTail
$ns duplex-link $n(0) $n(9) 1Mb 10ms DropTail
$ns duplex-link $n(9) $n(11) 1Mb 10ms DropTail
$ns duplex-link $n(10) $n(11) 1Mb 10ms DropTail
$ns duplex-link $n(11) $n(5) 1Mb 10ms DropTail
set udp0 [new Agent/UDP]
$ns attach-agent $n(0) $udp0
set cbr0 [new Application/Traffic/CBR]
$cbr0 set packetSize_ 500
$cbr0 set interval_ 0.005
$cbr0 attach-agent $udp0
set null0 [new Agent/Null]
$ns attach-agent $n(5) $null0
$ns connect $udp0 $null0
set udp1 [new Agent/UDP]
$ns attach-agent $n(1) $udp1
set cbr1 [new Application/Traffic/CBR]
$cbr1 set packetSize_ 500
$cbr1 set interval_ 0.005
$cbr1 attach-agent $udp1
set null0 [new Agent/Null]
$ns attach-agent $n(5) $null0
$ns connect $udp1 $null0
$ns rtproto LS
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
61
$ns rtmodel-at 10.0 down $n(11) $n(5)
$ns rtmodel-at 15.0 down $n(7) $n(6)
$ns rtmodel-at 30.0 up $n(11) $n(5)
$ns rtmodel-at 20.0 up $n(7) $n(6)
$udp0 set fid_ 1
$udp1 set fid_ 2
$ns color 1 Red
$ns color 2 Green
$ns at 1.0 "$cbr0 start"
$ns at 2.0 "$cbr1 start"
$ns at 45 "finish"
$ns run
Output
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
62
As per Laboratory Rubrics in Annexure I
CATEGORY
MAX.
MARKS
ALLOTED
MARKS
AWARDED
Design & Logic 40
Code design 40
Record Submission 10
Viva 10
TOTAL 100
Result
Thus program to implement routing protocol such as Distance Vector and OSPF are
executed and verified successfully.
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
63
Aim:
To analyze various Protocols using Ethernet Protocol Analyzer.(WireShark)
ETHEREAL ANALYSER:
The basic tool for observing the messages exchanged between executing protocol
entities is called a packet sniffer. As the name suggests, a packet sniffer captures
(“sniffs”) messages being sent/received from/by your computer; it will also typically store
and/or display the contents of the various protocol fields in these captured messages. A
packet sniffer itself is passive. It observes messages being sent and received by
applications and protocols running on your computer, but never sends packets itself.
Similarly, received packets are never explicitly addressed to the packet sniffer. Instead, a
packet sniffer receives a copy of packets that are sent/received from/by application and
protocols executing on your machine.
Figure 1 shows the structure of a packet sniffer. At the right of Figure 1 are the protocols
(in this case, Internet protocols) and applications (such as a web browser or ftp client) that
normally run on your computer. The packet sniffer, shown within the dashed rectangle in
Figure 1 is an addition to the usual software in your computer, and consists of two parts.
The packet capture library receives a copy of every link-layer frame that is sent from or
received by your computer. That messages exchanged by higher layer protocols such as
HTTP, FTP, TCP, UDP, DNS, or IP all are eventually encapsulated in link-layer frames
that are transmitted over physical media such as an Ethernet cable. In Figure, the assumed
physical media is an Ethernet, and so all upper layer protocols are eventually encapsulated
within an Ethernet frame. Capturing all link-layer frames thus gives you all messages
sent/received from/by all protocols and applications executing in it.
The second component of a packet sniffer is the packet analyzer, which displays the
contents of all fields within a protocol message. In order to do so, the packet analyzer must
“understand” the structure of all messages exchanged by protocols. For example, suppose
we are interested in displaying the various fields in messages exchanged by the HTTP
protocol. The packet analyzer understands the format of Ethernet frames, and so can
identify the IP datagram within an Ethernet frame. It also understands the IP datagram
format, so that it can extract the TCP segment within the IP datagram. Finally, it
Expt. No: 11 PERFORMANCE EVALUATION OF VARIOUS PROTOCOL
USING SIMULATOR TOOL (WIRE SHARK)
Date:
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
64
understands the TCP segment structure, so it can extract the HTTP message contained in
the TCP segment. Finally, it understands the HTTP protocol
Procedure:
Step1: Open wireshark Ethernet Protocol analyzer from terminal by typing wireshark
Step 2: Click the capture tab and select capture devices
Step 3: Choose your LAN interface card
Step 4: Click the Capture tab and select Capture Filters and delete the default Protocols
Step 5: Click the expressions and select Ethernet protocol.
Step 6: Apply the Filter Ethernet – eth-src (Source Mac Address)
Step 7: Click Start to capture live packets .
Step 8: Ping the next Pc in terminal (ARP/ICMP)
Step9. Browse Web pages (HTTP) , Access Mail server (TCP / UDP)
Step 10: Stop the capture and analyse various protocol frame format and note it down:
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
65
As per Laboratory Rubrics in Annexure I
CATEGORY
MAX.
MARKS
ALLOTED
MARKS
AWARDED
Design & Logic 40
Code design 40
Record Submission 10
Viva 10
TOTAL 100
Result
Thus the various protocol frame format are analyzed using Ethernet Protocol
Analyzer.
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
66
Aim:
To analyze the performance of UDP & TCP protocol using file Transfer programs
Procedure
1. Create UDP FTP file transfer and measure the Time taken using Date time package
datetime.now() method as well as file size using os.path.getsize(<file name>)
method
2. Code snippet Time Calculation and file size
# Time Calculation
from datetime import datetime
start=datetime.now()
UDP/TCP File Program
etime = datetime.now()
print('Time taken for file transfer',estart-stime)
# To find the file size
import os
filesizebytes= os.path.getsize('genericpath.py')
3. Code Snippet Through put Calculation:
Throughput =DataTransfer in Bytes / Time
Protocol TCP UDP
Time Taken for file transfer
Through Put
As per Laboratory Rubrics in Annexure I
CATEGORY
MAX.
MARKS
ALLOTED
MARKS
AWARDED
Design & Logic 40
Code design 40
Record Submission 10
Viva 10
TOTAL 100
Result:
The file transferred using UDP & TCP protocol and performance were analyzed.
Expt. No: 12 PERFORMACE ANALYSIS UDP & TCP
Date:
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
67
1. DateTime Client
2. Image Scrapping
3. Chat Room Creation with multiple clients
Expt. No: ADDITIONAL EXERCISES
Date:
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
68
CONTENT BEYOND SYLLABUS
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
69
Aim:
To study router basic configuration command using simulator software.
Required : Simulator software TOGGIT
The Toggit Router Simulator is designed to simulate the input and output of a generic router
using the Cisco® IOS
Expt. No:13 Study of Router Configuration using Toggit
Date:
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
70
Basic Router Commands & Configuration of Router
Start the router simulator.
You will see the prompt "Router>". This is the user mode prompt.
Type "enable" to take you into privileged mode.
You will see the prompt "Router#"
Type "config terminal" to go directly into configuration mode.
Click on the "Show Network Plan" button. Note that the router that you are configuring
should be named Router1.
Type "hostname Router1" to change the name of the router to Router1
Ctrl + Z to move to Previlege mode
Type "show interface ethernet 0". Note that there is no protocol listed and line protocol is
down.
Type "show interface serial 0". Note that there is no protocol listed and line protocol is
down.
Type "show running-config". Again, no protocols are listed.
Type "config terminal" to go directly into configuration mode.
Type "interface ethernet 0" to enter interface configuration mode for the Ethernet
interface.
Click the Show Network Plan button on the simulator. Note that the network interface of the
router has an IP address of 172.10.0.1. We will assign this IP address and a default subnet
mask to this interface:
Type "ip address 172.10.0.1 255.255.0.0" to assign the IP configuration.
Type "no shutdown" to enable the interface.
Type "exit" to leave the Ethernet interface configuration.
connection will be 210.16.54.1. Here's how you configure the serial interface:
Type "interface serial 0" to enter interface configuration mode for the serial interface.
Type "ip address 210.16.54.1 255.255.255.0" to assign the IP address and subnet mask.
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
71
Type "bandwidth 56" to set the bandwidth. This setting is measured in Kbps.
Note: The bandwidth command is usually only used in the testing lab environment.
Type "clock rate 56000" to set the DCE rate. This setting is measured in Bps. Also note that
clock rate is two words.
Note: The clock rate only needs to be set on the router that handles DCE.
Type "no shutdown" to enable the interface.
Type "exit" to leave the serial interface configuration.
Type "ctrl-z" to leave config mode.
Now we can check our configurations:
Make sure you are in privileged mode.
Type "show interface ethernet 0". Note that line protocol is up. If it is not up, repeat this
lab.
Type "show interface serial 0". Note that line protocol is up. If it is not up, repeat this lab.
Type "show running-config". Note the IP addresses of Ethernet0 and Serial0 entries.
Note: To use dynamic routing, the other routers in your network must use the same routing
protocol. For this simulation, the other router will work with either RIP or IGRP.
Start the router simulator. Go into privileged mode.
Type "show ip route". Note that two directly connected routes are shown.
Enter config mode. (Type "configure terminal" or "config t")
Type "router rip" to enable RIP on your router
Once RIP is enabled on a router, you must specify each network in which the router will
advertise routing.
Type "network 210.16.54.0"
Type "network 172.10.0.0"
Dynamic routing is now configured through RIP.
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
72
Type Ctrl-z to exit config mode.
Type "show ip route". Note that routes to all four networks are shown.
The same steps would be used to establish IGRP routing:
Enter config mode. (Type "configure terminal" or "config t")
First remove RIP by typing "no router rip"
Type "router igrp" to enable IGRP on your router.
Once IGRP is enabled on a router, you must specify each network in which the router will
advertise routing.
Type "network 210.16.54.0"
Type "network 172.10.0.0"
Dynamic routing is now configured through IGRP.
Type Ctrl-z to exit config mode.
Type "show ip route". Note that routes to all four networks are shown.
Note: To use dynamic routing in a network, all routers must use the same route
advertisement method (IGRP or RIP).
Make sure you are in privileged mode.
Type = "ping 172.10.0.1" to verify the configuration of the Ethernet port.
Type = "ping 172.10.0.10" to verify the connectivity with ServerA.
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
73
Sample Output:
As per Laboratory Rubrics in Annexure I
CATEGORY
MAX.
MARKS
ALLOTED
MARKS
AWARDED
Design & Logic 40
Code design 40
Record Submission 10
Viva 10
TOTAL 100
Result
Thus various basic commands for router configuration studied and successfully
configure the simulator router.
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
74
REFERENCES
Video Reference:
https://www.youtube.com/playlist?list=PLEbnTDJUr_IegfoqO4iPnPYQui46QqT0j
https://www.youtube.com/watch?v=QKfk7YFILws
Web Reference:
http://enggedu.com/network_lab_exercise_programs/index.php
https://www.nsnam.org/
https://www.wireshark.org
https://wps.pearsoned.com/ecs_kurose_compnetw_6/216/55463/14198702.cw/index.html
Book Reference:
T1: Behrouz A.Forouzan, “Data Communication and Networking”, Fifth Edition, TMH, 2013.
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
75
ROUGH WORK:
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
76
ROUGH WORK:
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
77
ROUGH WORK:
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
78
ROUGH WORK:
CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai
79
ROUGH WORK:

Weitere ähnliche Inhalte

Was ist angesagt?

Security services and mechanisms
Security services and mechanismsSecurity services and mechanisms
Security services and mechanismsRajapriya82
 
User datagram protocol (udp)
User datagram protocol (udp)User datagram protocol (udp)
User datagram protocol (udp)Ramola Dhande
 
NETWORK LAYER - Logical Addressing
NETWORK LAYER - Logical AddressingNETWORK LAYER - Logical Addressing
NETWORK LAYER - Logical AddressingPankaj Debbarma
 
Dag representation of basic blocks
Dag representation of basic blocksDag representation of basic blocks
Dag representation of basic blocksJothi Lakshmi
 
19 Network Layer Protocols
19 Network Layer Protocols19 Network Layer Protocols
19 Network Layer ProtocolsMeenakshi Paul
 
Data link layer
Data link layerData link layer
Data link layersbkbca
 
DBMS Assignments Questions
DBMS Assignments QuestionsDBMS Assignments Questions
DBMS Assignments QuestionsSara Sahu
 
Chapter 4 data link layer
Chapter 4 data link layerChapter 4 data link layer
Chapter 4 data link layerNaiyan Noor
 
wireless network IEEE 802.11
 wireless network IEEE 802.11 wireless network IEEE 802.11
wireless network IEEE 802.11Shreejan Acharya
 
IP addressing seminar ppt
IP addressing seminar pptIP addressing seminar ppt
IP addressing seminar pptSmriti Rastogi
 
Register allocation and assignment
Register allocation and assignmentRegister allocation and assignment
Register allocation and assignmentKarthi Keyan
 
Osi model vs TCP/IP
Osi model vs TCP/IPOsi model vs TCP/IP
Osi model vs TCP/IPMannu Khani
 

Was ist angesagt? (20)

Security services and mechanisms
Security services and mechanismsSecurity services and mechanisms
Security services and mechanisms
 
Subnetting
SubnettingSubnetting
Subnetting
 
User datagram protocol (udp)
User datagram protocol (udp)User datagram protocol (udp)
User datagram protocol (udp)
 
IPv4
IPv4IPv4
IPv4
 
Osi model
Osi modelOsi model
Osi model
 
NETWORK LAYER - Logical Addressing
NETWORK LAYER - Logical AddressingNETWORK LAYER - Logical Addressing
NETWORK LAYER - Logical Addressing
 
Dag representation of basic blocks
Dag representation of basic blocksDag representation of basic blocks
Dag representation of basic blocks
 
Cs8591 Computer Networks
Cs8591 Computer NetworksCs8591 Computer Networks
Cs8591 Computer Networks
 
19 Network Layer Protocols
19 Network Layer Protocols19 Network Layer Protocols
19 Network Layer Protocols
 
Data link layer
Data link layerData link layer
Data link layer
 
Transport layer
Transport layer Transport layer
Transport layer
 
DBMS Assignments Questions
DBMS Assignments QuestionsDBMS Assignments Questions
DBMS Assignments Questions
 
Multiplexing
MultiplexingMultiplexing
Multiplexing
 
Chapter 4 data link layer
Chapter 4 data link layerChapter 4 data link layer
Chapter 4 data link layer
 
Network layer tanenbaum
Network layer tanenbaumNetwork layer tanenbaum
Network layer tanenbaum
 
wireless network IEEE 802.11
 wireless network IEEE 802.11 wireless network IEEE 802.11
wireless network IEEE 802.11
 
IP addressing seminar ppt
IP addressing seminar pptIP addressing seminar ppt
IP addressing seminar ppt
 
Token bus
Token busToken bus
Token bus
 
Register allocation and assignment
Register allocation and assignmentRegister allocation and assignment
Register allocation and assignment
 
Osi model vs TCP/IP
Osi model vs TCP/IPOsi model vs TCP/IP
Osi model vs TCP/IP
 

Ähnlich wie Cs8581 networks lab manual 2017

Dbms lab manual
Dbms lab manualDbms lab manual
Dbms lab manualArthyR3
 
Dsp lab manual
Dsp lab manualDsp lab manual
Dsp lab manualamanabr
 
CS8383 Object Oriented Programming Laboratory Manual
CS8383 Object Oriented Programming Laboratory ManualCS8383 Object Oriented Programming Laboratory Manual
CS8383 Object Oriented Programming Laboratory ManualMuthu Vinayagam
 
Digital System Design with FPGAs Lab Manual.pdf
Digital System Design with FPGAs Lab Manual.pdfDigital System Design with FPGAs Lab Manual.pdf
Digital System Design with FPGAs Lab Manual.pdfAmairullahKhanLodhi1
 
Final teit syllabus_2012_course_04.06.2014
Final teit syllabus_2012_course_04.06.2014Final teit syllabus_2012_course_04.06.2014
Final teit syllabus_2012_course_04.06.2014deepti112233
 
Te computer-syllabus-2015-course-3-4-17
Te computer-syllabus-2015-course-3-4-17Te computer-syllabus-2015-course-3-4-17
Te computer-syllabus-2015-course-3-4-17abc19789
 
vtu data structures lab manual bcs304 pdf
vtu data structures lab manual bcs304 pdfvtu data structures lab manual bcs304 pdf
vtu data structures lab manual bcs304 pdfLPSChandana
 
COA RKGITM #sem education purpose ppt good for student
COA RKGITM #sem education purpose ppt good for studentCOA RKGITM #sem education purpose ppt good for student
COA RKGITM #sem education purpose ppt good for studentmohitmehra75
 
Control systems R18 course
Control systems R18 course Control systems R18 course
Control systems R18 course satyaSatyant234
 
CS8662 Mobile Application Development Lab Manual
CS8662 Mobile Application Development Lab ManualCS8662 Mobile Application Development Lab Manual
CS8662 Mobile Application Development Lab Manualpkaviya
 
Te computer syllabus 2015 course 3-4-17 3-5-17
Te computer syllabus 2015 course 3-4-17 3-5-17Te computer syllabus 2015 course 3-4-17 3-5-17
Te computer syllabus 2015 course 3-4-17 3-5-17VishalButkar2
 
Cs8383 oop lab manual-2019
Cs8383 oop lab manual-2019Cs8383 oop lab manual-2019
Cs8383 oop lab manual-2019Kayathri Devi D
 
Industrial trainingsoftware 2011
Industrial trainingsoftware 2011Industrial trainingsoftware 2011
Industrial trainingsoftware 2011dkhari
 
Report[Batch-08].pdf
Report[Batch-08].pdfReport[Batch-08].pdf
Report[Batch-08].pdf052Sugashk
 
OOAD & ST LAB MANUAL.pdfOose feasibility study in detail Oose feasibility stu...
OOAD & ST LAB MANUAL.pdfOose feasibility study in detail Oose feasibility stu...OOAD & ST LAB MANUAL.pdfOose feasibility study in detail Oose feasibility stu...
OOAD & ST LAB MANUAL.pdfOose feasibility study in detail Oose feasibility stu...shohi1
 

Ähnlich wie Cs8581 networks lab manual 2017 (20)

IT6511 Networks Laboratory
IT6511 Networks LaboratoryIT6511 Networks Laboratory
IT6511 Networks Laboratory
 
Cn lab manual sb 19_scsl56 (1)
Cn lab manual sb 19_scsl56 (1)Cn lab manual sb 19_scsl56 (1)
Cn lab manual sb 19_scsl56 (1)
 
Ade manual with co po-18scheme
Ade manual with co po-18schemeAde manual with co po-18scheme
Ade manual with co po-18scheme
 
Dbms lab manual
Dbms lab manualDbms lab manual
Dbms lab manual
 
Hdllab1
Hdllab1Hdllab1
Hdllab1
 
Dsp lab manual
Dsp lab manualDsp lab manual
Dsp lab manual
 
CS8383 Object Oriented Programming Laboratory Manual
CS8383 Object Oriented Programming Laboratory ManualCS8383 Object Oriented Programming Laboratory Manual
CS8383 Object Oriented Programming Laboratory Manual
 
Dc course file
Dc course fileDc course file
Dc course file
 
Digital System Design with FPGAs Lab Manual.pdf
Digital System Design with FPGAs Lab Manual.pdfDigital System Design with FPGAs Lab Manual.pdf
Digital System Design with FPGAs Lab Manual.pdf
 
Final teit syllabus_2012_course_04.06.2014
Final teit syllabus_2012_course_04.06.2014Final teit syllabus_2012_course_04.06.2014
Final teit syllabus_2012_course_04.06.2014
 
Te computer-syllabus-2015-course-3-4-17
Te computer-syllabus-2015-course-3-4-17Te computer-syllabus-2015-course-3-4-17
Te computer-syllabus-2015-course-3-4-17
 
vtu data structures lab manual bcs304 pdf
vtu data structures lab manual bcs304 pdfvtu data structures lab manual bcs304 pdf
vtu data structures lab manual bcs304 pdf
 
COA RKGITM #sem education purpose ppt good for student
COA RKGITM #sem education purpose ppt good for studentCOA RKGITM #sem education purpose ppt good for student
COA RKGITM #sem education purpose ppt good for student
 
Control systems R18 course
Control systems R18 course Control systems R18 course
Control systems R18 course
 
CS8662 Mobile Application Development Lab Manual
CS8662 Mobile Application Development Lab ManualCS8662 Mobile Application Development Lab Manual
CS8662 Mobile Application Development Lab Manual
 
Te computer syllabus 2015 course 3-4-17 3-5-17
Te computer syllabus 2015 course 3-4-17 3-5-17Te computer syllabus 2015 course 3-4-17 3-5-17
Te computer syllabus 2015 course 3-4-17 3-5-17
 
Cs8383 oop lab manual-2019
Cs8383 oop lab manual-2019Cs8383 oop lab manual-2019
Cs8383 oop lab manual-2019
 
Industrial trainingsoftware 2011
Industrial trainingsoftware 2011Industrial trainingsoftware 2011
Industrial trainingsoftware 2011
 
Report[Batch-08].pdf
Report[Batch-08].pdfReport[Batch-08].pdf
Report[Batch-08].pdf
 
OOAD & ST LAB MANUAL.pdfOose feasibility study in detail Oose feasibility stu...
OOAD & ST LAB MANUAL.pdfOose feasibility study in detail Oose feasibility stu...OOAD & ST LAB MANUAL.pdfOose feasibility study in detail Oose feasibility stu...
OOAD & ST LAB MANUAL.pdfOose feasibility study in detail Oose feasibility stu...
 

Kürzlich hochgeladen

Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 

Kürzlich hochgeladen (20)

Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 

Cs8581 networks lab manual 2017

  • 1. DEPARTMENT OF INFORMATION TECHNOLOGY LABORATORY MANUAL CS8581 NETWORKS LABORATORY 2019-2020 ODD SEMESTER 2017-2021 Batch Staff in Charge HOD/IT D.Kayathri Devi, AP/ IT Dr.P.SUBATHRA,Prof/IT
  • 2. BONAFIDE GERTIFICATE NAME : ________________________________________________________________________________ REGISTER NUMBER: ________________________________________________ ROLLNO: __________________ BRANCH : _________________________________________________________________________________ YEAR : _________________________________________________________________________________ Bonafide Record of work done in the __________________________________________________________ of Kamaraj College of Engineering and Technology, Madurai, during the year _____________________. STAFF IN-CHARGE HEAD OF THE DEPARTMENT Submitted for the Practical Examination held on ___________________________ at Kamaraj College of Engineering and Technology, Madurai. INTERNAL EXAMINER EXTERNAL EXAMINER
  • 3. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 3 INDEX Expt. No Date Title of the Exercise Page No Mark (100) CO Attained? (Yes/No) Signature
  • 4. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 4 Expt. No Date Title of the Exercise Page No Mark (100) CO Attained? (Yes/No) Signature
  • 5. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 5 DEPARTMENT OF INFORMATION TECHNOLOGY VISION OF THE INSTITUTE To make this institute the unique of its kind in the field of Research and Development activities in this part of world MISSION OF THE INSTITUTE To impart highly innovative and technical knowledge to the urban and unreachable rural student folks through Total Quality Education VISION OF THE DEPARTMENT To make the department of Information Technology the unique of its kind in the field of Research and Development activities in this part of world MISSION OF THE DEPARTMENT To impart highly innovative and technical knowledge in the field of Information Technology to the urban and unreachable rural student folks through Total Quality Education PROGRAM EDUCATION OBJECTIVE [PEO] PEO 1: Graduates of the programme will exhibit expertise in technical knowledge by applying distinctive skills in various fields of Information Technology PEO 2: Graduates will become pioneers in the field of Information Technology by working collaboratively and providing solutions to meet societal needs through persistent learning PEO 3: Graduates will be able to adopt innovative practices and contribute towards research and technological development in the field of Information Technology through Total Quality Education
  • 6. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 6 PROGRAM OUTCOMES Engineering Graduates will be able to: 1. Engineering knowledge: Apply the knowledge of mathematics, science, engineering fundamentals, and an engineering specialization to the solution of complex engineering problems. 2. Problem analysis: Identify, formulate, review research literature, and analyse complex engineering problems reaching substantiated conclusions using first principles of mathematics, natural sciences, and engineering sciences. 3. Design/development of solutions: Design solutions for complex engineering problems and design system components or processes that meet the specified needs with appropriate consideration for the public health and safety, and the cultural, societal, and environmental considerations. 4. Conduct investigations of complex problems: Use research-based knowledge and research methods including design of experiments, analysis and interpretation of data, and synthesis of the information to provide valid conclusions. 5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern engineering and IT tools including prediction and modeling to complex engineering activities with an understanding of the limitations. 6. The engineer and society: Apply reasoning informed by the contextual knowledge to assess societal, health, safety, legal and cultural issues and the consequent responsibilities relevant to the professional engineering practice. 7. Environment and sustainability: Understand the impact of the professional engineering solutions in societal and environmental contexts, and demonstrate the knowledge of, and need for sustainable development. 8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norms of the engineering practice. 9. Individual and team work: Function effectively as an individual, and as a member or leader in diverse teams, and in multidisciplinary settings. 10. Communication: Communicate effectively on complex engineering activities with the engineering community and with society at large, such as, being able to comprehend and write effective reports and design documentation, make effective presentations, and give and receive clear instructions. 11. Project management and finance: Demonstrate knowledge and understanding of the engineering and management principles and apply these to one’s own work, as a member and leader in a team, to manage projects and in multidisciplinary environments. 12. Life-long learning: Recognize the need for, and have the preparation and ability to engage in independent and life-long learning in the broadest context of technological change.
  • 7. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 7 PROGRAM SPECIFIC OUTCOMES (PSOs) Engineering Graduates will be able to: 1. Design and develop applications in the field of Information Technology by applying the knowledge acquired from Computer Organization & Engineering, Networking, Software Engineering & Programming, Data Analytics & other allied topics. 2. Demonstrate an ability to analyze, design, and develop software solutions to cater the needs of diversified business sectors
  • 8. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 8 SYLLABUS CS8581- NETWORKS LABORATORY 0 0 4 2 OBJECTIVES: To learn and use network commands. To learn socket programming. To implement and analyze various network protocols. To learn and use simulation tools. To use simulation tools to analyze the performance of various network protocols. LIST OF EXPERIMENTS 1. Learn to use commands like tcpdump, netstat, ifconfig, nslookup and traceroute. Capture ping and traceroute PDUs using a network protocol analyzer and examine. 2. Write a HTTP web client program to download a web page using TCP sockets. 3. Applications using TCP sockets like:  Echo client and echo server  Chat  File Transfer 4. Simulation of DNS using UDP sockets. 5. Write a code simulating ARP /RARP protocols. 6. Study of Network simulator (NS) and Simulation of Congestion Control Algorithms using NS. 7. Study of TCP/UDP performance using Simulation tool. 8. Simulation of Distance Vector/ Link State Routing algorithm. 9. Performance evaluation of Routing protocols using Simulation tool. 10. Simulation of error correction code (like CRC). Mini Project – Team of 3 Members – Network Project OUTCOMES: Upon Completion of the course, the students will be able to: 1. Implement various protocols using TCP and UDP. 2. Compare the performance of different transport layer protocols. 3. Use simulation tools to analyze the performance of various network protocols. 4. Analyze various routing algorithms. 5. Implement error correction codes. TOTAL : 60 PERIODS
  • 9. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 9 COURSE OUTCOMES AND ITS PO MAPPING Name of the Subject : Networks Laboratory Subject Code : CS 8581 Semester : V Odd/Even : Odd Students will be able to Course No. Course Outcome (Student should be able to) Knowledge Level R17C308.1 Use basic networking commands to realize packet transmission in live network K3 - Apply R17C308.2 Implement the protocols using TCP/UDP and Compare their performance K3 - Apply R17C308.3 Use simulation tools to analyze the performance of network protocols K4 - Analyze R17C308.4 Implement and analyze routing algorithms K4 - Analyze R17C308.5 Implement error correction codes K3 - Apply CO vs PO Mapping Course Outco mes Program outcomes Program Specifi c outcom es PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 PSO1 PSO2 R17C308.1(K3) M - - - L - - - - M - - M - R17C308.2(K3) H H L - H - - - - M - - M - R17C308.3(K4) H H M - H - - - - M - - M - R17C308.4(K4) H H M - H - - - - M - - M - R17C308.5(K3) H M L - L - - - - M - - M - R17C308 H H M - M - - - - M - - H - 3 – Substantial (High) 2 – Moderate (Medium) 1 – Slight (Low) Internal Assessment S.No Assessment Tool Percentage of Contribution (%) 1 Laboratory Rubrics 75 2 Model Exam. 25 Target Value = 80 % of Marks
  • 10. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 10 LIST OF EXERCISES AND ITS CO’S Expt. No Experiment Name No. of Periods Cumulative No. of periods Course Outcome Mapping Cycle – I 1 Introduction, Pre Assessment Test 4 4 2 Basic Networking Commands 4 5 C308.1 3 Web Scrapping Programming using HTTP Protocol 4 12 C308.2 4 Socket Programming using TCP a. Chat Simulation b. Echo Simulation c Pink Simulation 4 16 C308.2 5 File Transfer Protocol using TCP 4 20 C308.3 6 Simulation of ARP and RARP using TCP 4 24 C308.3 Cycle II 7 Simulation of DNS using TCP 4 28 C308.3 8 Simulation of error correction code (like Parity Checker) 4 32 C308.4 9 Simulation of FTP Protocol using UDP 4 36 C308.4 10 Study of Network Topologies and, Congestion Control using Network Simulator 2 4 40 C308.4 11 Simulation of Routing Protocol using NS2 Simulator 4 44 C308.5 12 Performance evaluation of Various Protocol using Simulator Tool (Wireshark) 4 48 C308.5 13 Performance analysis of TCP& UDP 4 52 C308.5 13 Routing Configuration using Toggit Simulation Tool 4 56 C308.3 14 Model Examination and Post Assessment Test 4 60
  • 11. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 11 Attainment of CO – Internal Assessment Basedon Laboratory Rubric CO Expt. No Exercise Title Lab Mark (100) Average CO Attained? (Y/N) 1 1 Basic Networking Commands 2 2 Web Scrapping Programming using HTTP Protocol 3 Socket Programming using TCP a. Chat Simulation b. Echo Simulation c Pink Simulation 4 File Transfer Protocol using TCP 3 5 Simulation of ARP and RARP using TCP 6 Simulation of DNS using TCP 7 Simulation of error correction code (like Parity Checker) 8 Simulation of FTP Protocol using UDP 4 9 Study of Network Simulator 2 10 Simulation of Network Topologies, Congestion Control and Routing Protocol using NS2 Simulator 5 11 Performance evaluation of Various Protocol using Simulator Tool (Wiresherk) 12 Performance analysis of TCP& UDP 13 Content Beyond Syllabus: Routing Configuration using Toggit Simulation Tool (A) Total Marks (100) = [CO 1+CO 2+CO 3+CO 4+CO 5] Basedon Model Exam CO Marks (B) Total Marks (100) CO Attained? (Yes/No) Allotted Obtained Internal Assessment = 75 % of A + 25 % of B = Internal Assessment = % Note: If CO Attainment, YES = Laboratory Mark (%) >= Target Value (%) NO = Laboratory Mark (%) < Target Value (%)
  • 12. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 12 Action Plan: (If CO Not Attained) For Regular Laboratory Session CO Reason for not Attaining CO Remedial Action Plan Remarks Signature For Model Exam CO Reason for not Attaining CO Remedial Action Plan Remark Signature
  • 13. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 13 Department of Information Technology RUBRICS FOR LABORATORY ASSESMENT – Annexure I Category Design/ Logic [40] Understood the basic concept and logic/design [40] Understood the logic/design and basic concept but lacks in presenting it [38] Understood the basic concept but lacks in understanding the logic/design [36] Understood the basic concept but fails to give detail description [32] No knowledge in basic concept but implemented the program [30] Code Design [40] Code that satisfies the entire logic [40] Code deigned with some syntax errors [38] Code designed with some logic mistakes [36] Code designed with wrong logic [32] Wrong logic & no programming structure but finished the program [30] Record Submission [10] Submission on date [10] 1 day delay [9] 2 days delay [8] 3 days delay [7] 4 days delay [6] Viva [10] Oral Quiz / Online Quiz Total Marks: 100 Marks
  • 14. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 14 COURSE INTRODUCTION Modern world scenario is ever changing. Data Communication and network have changed the way business and other daily affair works. Now, they highly rely on computer networks and internetwork. A set of devices often mentioned as nodes connected by media link is called a Network. A node can be a device which is capable of sending or receiving data generated by other nodes on the network like a computer, printer etc. These links connecting the devices are called Communication channels. Computer network is a telecommunication channel using which we can share data with other computers or devices, connected to the same network. It is also called Data Network. The best example of computer network is Internet. Computer network does not mean a system with one Control Unit connected to multiple other systems as its slave. That is Distributed system, not Computer Network. A network must be able to meet certain criterias, these are mentioned below: 1. Performance 2. Reliability 3. Scalability It can be measured in the following ways:  Transit time : It is the time taken to travel a message from one device to another.  Response time : It is defined as the time elapsed between enquiry and response. Other ways to measure performance are : 1. Efficiency of software 2. Number of users 3. Capability of connected hardware
  • 15. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 15 CS 8581 -Networks Laboratory Pre / Post Assessment Questions 1.Communication between a computer and a keyboard involves ______________ transmission Ans: Simplex 2.A set of rules that governs data communication Ans: Protocol 3.Three or more devices share a link in ________ connection Ans: Multipoint 4.Communication channel is shared by all the machines on the network in Ans: broadcast network 5.Bluetooth is an example of Ans: personal area network 6.A __________ is a device that forwards packets between networks by processing the routing information included in the packet. Ans: router 7.Network congestion occurs. Ans: In case of traffic overloading 8.The number of layers in Internet protocol stack Ans: 5 9.The number of layers in ISO OSI reference model Ans: 7 10.This layer is an addition to OSI model when compared with TCP IP model Ans: Session and Presentation layer
  • 16. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 16 Expt. No: 1 BASIC NETWORKING COMMANDS Date: Aim: To learn about various Basic Networking commands Procedure / Commands: Network Commands Ethtool is a Network Interface Cards (NICs) utility/configuration tool. Ethtool allows you to query and change your NIC settings such as the Speed, Port, auto-negotiation and many other parameters. ifconfig -a To show the Network Card information Note down the IP address and MAC Address ( Understand MAC address – IP Address) Ping ( Packet Internet Gropper) Verifies IP-level connectivity to another TCP/IP computer by sending Internet Control Message Protocol (ICMP) Echo Request messages. The receipt of corresponding Echo Reply messages are displayed, along with round-trip times. Ping is the primary TCP/IP command used to troubleshoot connectivity, reachability, and name resolution. To check Local Ethernet Connection At the command prompt, ping the loopback address by typing ping 127.0.0.1 ping near by system ping <171.16.6.111> ping -c 10 <ipaddress> write observation ping www.google.com Arp Displays and modifies entries in the Address Resolution Protocol (ARP) cache, which contains one or more tables that are used to store IP addresses and their resolved Ethernet arp *Find Machine Gateway Hardware Address-Why it is necessary Tracert / traceroute - trace Path Traceroute: Determines the path taken to a destination by sending Internet Control Message Protocol (ICMP) Echo Request messages to the destination with incrementally increasing Time to Live (TTL) field values- tracepath similar to traceroute command, but it doesn't require root privileges $ traceroute www.google.co.in $tracepath www.ubidots.com
  • 17. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 17 Netstat Displays active TCP connections, ports on which the computer is listening, Ethernet statistics, the IP routing table, IPv4 statistics (for the IP, ICMP, TCP, and UDP protocols), and IPv6 statistics (for the IPv6, ICMPv6, TCP over IPv6, and UDP over IPv6 protocols). Note Down The few TCP UDP ports nslookup Nslookup (Name Server lookup) is a UNIX shell command to query Internet domain name servers. $nslookup www.annauniv.edu notedown the IP address Undestand Non-authoritative answer dig (Domain Information Groper) is a flexible tool for interrogating DNS name servers. It performs DNS lookups and displays the answers that are returned from the name servers. $dig geekflare.com What do you mean by DNS Server . w prints a summary of the current activity on the system, including what each user is doing, and their processes. Also list the logged in users and system load average for the past 1, 5, and 15 minutes. nmap nmap is a one of the powerful commands, which checks the opened port on the server. Usage example: nmap $server_name Interface Settings You can enable or disable the network interface by using ifup/ifdown commands with ethernet interface parameter. To disable eth0 $ifdown <eth0> check neighbor connection with PING command what ? To enable eth0 $ifup <eth0> This command displays domain name for given IP address and displays IP address for given domain name. It also performs DNS lookups related to DNS query. host www.thingspeak.com host <ipaddress> find difference betewwn ipv4 and ipv6
  • 18. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 18 mtr The mtr command is a combinatiion of ping and traceroute command. It continuously sends packet showing ping time for each hop. It also shows network problems. Syntax: mtr<path> mtr facebook.com see the result & find observation The who is command displays information about a website's record. You may get all the information about a website regarding its registration and owner's information. Syntax: whois <websiteName> whois www.gmail.com whois mail.office365.com Linux curl & wget These commands are used to download a file from the internet using CLI. With curl commands option O will be used while wget command will be used without any option. The file will be saved in the current directory. Download useful materials Other Useful command pwd whoami hostname uname -r Get some useful linux command -atleast five tcpdump It allows the user to display TCP/IP and other packets being transmitted or received over a network to which the computer is attached. tcpdump -c 5 -i eth0 tcpdump -A S -i eth0 tcpdump -XX -i eth0 tcpdump -n -i eth0 tcpdump -i eth0 tcp/udp tcpdump -i eth0 dst 172.16.7.186 As per Laboratory Rubrics in Annexure I CATEGORY MAX. MARKS ALLOTED MARKS AWARDED Design & Logic 40 Code design 40 Record Submission 10 Viva 10 TOTAL 100 Result The various network commands are executed and their results are recorded
  • 19. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 19 Expt. No: 2 WEB SCRAPING PROGRAM USING TCP SOCKETS Date: Aim: To write a Python Program to download web page from a server and use BeautifulSoup package to parse and analyse the web page information. Procedure 1. Import packages and module for web page download 2. 'Package required are requests and BeautifulSoup 3. The requests package is a more Pythonic replacement for Python’s own urllib. download web content using requests and giving URL in parameter syntax : requests.get(URL) content = requests.get("http://www.google.com") 4. Using BeautifulSoup from bs4 pacakage read the content and display the Title and content 5. Use the BeautifulSoup parse the web page using HTML parser and list the contents Program import requests import bs4 url = input("Enter the URL:") obj = requests.get(url) soup = bs4.BeautifulSoup(obj.text,'lxml') soup2 = soup.select('style') print(soup2) Sample Output: As per Laboratory Rubrics in Annexure I CATEGORY MAX. MARKS ALLOTED MARKS AWARDED Design & Logic 40 Code design 40 Record Submission 10 Viva 10 TOTAL 100
  • 20. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 20 Result: Thus to write a Python Program to download web page from a server and use BeautifulSoup package to parse and analyse the web page information was executed successfully.
  • 21. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 21 Expt. No: 3 TCP PROGRAMS Date: Aim: To write Client Server TCP Programs to implement Chat and Echo Procedure: Server Side: 1. import socket # Create a TCP socket for Communication using socket library 2. Socket Creation IV4 /IV6 and TCP / UDP s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) The first parameter is AF_INET the address family ipv4.The SOCK_STREAM means connection oriented TCP protocol. s is the socket object 3. Bind the Socket with hostname and port s.bind(('localhost', port)) 4. Put the socket into listening mode for client communication upto 5 dedicated links s.listen(5) 5. Once the Client send a request to connect , accept and establish the connections with acknowledgement clientsock,address=s.accept() 6. Server receive client message using recv method and Reply with sendmethod to client s.recv(1024) s.send(message) 7. The process until the client closes the connection
  • 22. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 22 Client Side: 1. import socket # Create a TCP socket for Communication using socket library s = socket.socket() 2. Connect the Socket with serverhostname and port s.connect(('localhost',port)) 3. Once the server accept and reply with the connection status.Request send to server with s.send(message) method and Server message received using s.recv(bytes) method 4. The process until the client closes the connection Program Chat Client: import socket # Import socket module s = socket.socket() # Create a socket object host = socket.gethostname() # Get local machine name port = 12000 # Reserve a port for your service. s.connect(('localhost', port)) # Bind to the port print s.recv(1024) while True: msg=raw_input('me:>') s.send(msg) rmsg=s.recv(1024) print(rmsg) if msg=='bye': break s.close() Chat Server: import socket # Import socket module s = socket.socket() # Create a socket object host = socket.gethostname() # Get local machine name port = 12000 # Reserve a port for your service. s.bind(('localhost', port)) # Bind to the port s.listen(5) # Now wait for client connection. print('Waiting for connection..') c, addr = s.accept() # Establish connection with client. print 'Got connection from', addr c.send('Thank you for connecting') while True: rmsg=c.recv(1024) print(rmsg) msg=raw_input('server') c.send(msg) if msg=='bye': break
  • 23. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 23 c.close() # Close the connection Sample Output: SERVER: student@a4it167:~$ python server.py Waiting for connection... Got connection from ('127.0.0.1', 46368) hi Server >hello welcome Server > CLIENT: Thank you for connecting Client >hi hello Client >welcome
  • 24. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 24 ECHO CLIENT: import socket # Import socket module s = socket.socket() # Create a socket object host = socket.gethostname() # Get local machine name port = 33334 # Reserve a port for your service. s.connect(('172.16.7.193', port)) # Bind to the port print s.recv(1024) while True: msg=raw_input('me:>') s.send(msg) rmsg=s.recv(1024) print(rmsg) if msg=='bye': break s.close() ECHO SERVER: import socket # Import socket module s = socket.socket() # Create a socket object host = socket.gethostname() # Get local machine name port = 11001 # Reserve a port for your service. s.bind(('localhost', port)) # Bind to the port s.listen(5) # Now wait for client connection. print('Waiting for connection..') c, addr = s.accept() # Establish connection with client. print 'Got connection from', addr c.send('Thank you for connecting') while True: rmsg=c.recv(1024) print(rmsg) msg=raw_input('server') c.send(msg) if msg=='bye': break c.close() # Close the connection
  • 25. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 25 Sample Output: SERVER: student@a4it167:~$ python server.py Waiting for connection... Got connection from ('127.0.0.1', 46368) hi hello welcome CLIENT: Thank you for connecting Client >hi hello Client >welcome Result Thus Client Server TCP Programs to implement Chat and Echo is executed and verified successfully. As per Laboratory Rubrics in Annexure I CATEGORY MAX. MARKS ALLOTED MARKS AWARDED AIM & PREPARATION 20 CODING STANDARDS, BEST PRACTICES & RESULTS 20 VIVA VOCE 20 RECORD – GRAMMAR & FORMATTING 20 TIMELY SUBMISSION 20 TOTAL 100
  • 26. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 26 Aim: To write a Python program for file transfer protocol Procedure: Server Side: 1.Start 2.Create a TCP socket for Communication using socket library 3.Bind the Socket with hostname and port with process 4.Put socket in listening mode for client communication 5.Once the Client send a request to connect , accept and establish the connections with acknowledgement 6.Get filename 7.Open the file and read the content 8.Close the file. Client Side: 1.Start 2.Create a TCP socket for Communication using a socket library 3.Bind the Socket with hostname and port with process 4.Connect with server accept and reply with the connection status 5.Request send to server with send() method 6.Open the received file and write 7.Display message as file opened 8.Close and display successfully got the file. Expt. No: 4 FILE TRANSFER PROTOCOL Date: Expt. No: 4 FILE TRANSFER PROTOCOL Date:
  • 27. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 27 Program: SERVER: import socket s=socket.socket() port=8012 host="172.16.6.189" s.bind((host,port)) s.listen(5) print'Server listening...' while True: conn,addr=s.accept() print'Got connection from ',addr data = conn.recv(1024) print('Server received', repr(data)) filename='serftp.py' f=open(filename,'rb') l=f.read(1024) while (l): conn.send(l) print('sent',repr(l)) l=f.read(1024) if l==''" break f.close() CLIENT: import socket s=socket.socket() host='172.16.6.189' port=8018 s.connect((host,port)) s.send('Hello Server') with open('kavi3.py','wb') as f: print ('File opened') while True: print'Receiving data...' data=s.recv(16) print('Data=%s',(data)) if not data: break f.write(data) f.close() print'Seccessfully get the file' s.close() print'Connection closed'
  • 28. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 28 Output root@a4it167:~# python ex4.py Server Listening... Got connection from ('127.0.0.1', 34414) ('Server received', "'hello server..'") ('Sent', '"#!/usr/bin/python nimport socketns=socket.socket()nhost=socket.gethostname()nport=7001ns.bind(('localhost', port))ns.listen(5)nprint ('Waiting for connection...')nc, addr = s.accept()nprint 'Got connection from', addrnc.send('Thank you for connecting')nwhile True:n cmsg=c.recv(1024)n print(cmsg) n n smsg=raw_input('Server >')n c.send(smsg)n nc.close()nn"') root@a4it167:~# As per Laboratory Rubrics in Annexure I CATEGORY MAX. MARKS ALLOTED MARKS AWARDED Design & Logic 40 Code design 40 Record Submission 10 Viva 10 TOTAL 100 Result Thus a Python program for simulating file transfer protocol is executed and verified successfully.
  • 29. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 29 Aim: To write a Python program for simulating ARP/RARP protocols using TCP Procedure: Server 1. Start the program 2. create a list with macaddress and ipaddress 3. import pandas and store the csv file as dataframe 4. Create a socket using socket class bind with the 'ServerIPaddress' and PortNo. 5. Listen for client Request 6. Accept the socket which is created by the client. 7. Server maintains the table in which IP and corresponding MAC addresses are stored. 8. Read the IP address which is send by the client. 9. Map the IP address with its MAC address and return the MAC address to client. 10. Do the same for RARP - MAC ADDRESS to IPADDRESS Client 1. Start the program 2. Create the Socket with server 3. Using socket connection is established between client and server. 4. Get the IP address to be converted into MAC address 5. Send this IP address to server. 6. Server returns the MAC address to client if is is available else Display unreachable. 7. Do the same for RARP - Send MAC ADDRESS and get IPADDRESS 8. Server returns the IP address to client if is is available else Display Not Found. Expt. No: 5 SIMULATION OF ARP AND RARP USING TCP Date:
  • 30. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 30 Program: Server #!/usr/bin/python # This is server.py file import socket # Import socket module s = socket.socket() # Create a socket object host = socket.gethostname() # Get local machine name port = 4062 # Reserve a port for your service. s.bind(('localhost', port)) # Bind to the port s.listen(5) print("waiting for client connection") # Now wait for client connection. c, addr = s.accept() # Establish connection with client. print 'Got connection from', addr c.send('Thank you for connecting') iplist=['172.16.7.167','172.16.7.168','172.16.7.166','172.16.7.170','172.16.7.165'] maclist=['f8:bc:12:86:31:c0','f8:bc:12:86:bd:c7','f8:bc:12:86:bd:c8','f8:bc:12:86:bf:c7','f8:bc: 12:86:bc:c8'] while True: data=c.recv(1024) if data in maclist: i=maclist.index(data) c.send(iplist[i]) print "Found" else: print "not found" c.close() # Close the connection Client #!/usr/bin/python # This is server.py file import socket # Import socket module s = socket.socket() # Create a socket object host = socket.gethostname() # Get local machine name port = 4062 # Reserve a port for your service. s.connect(('localhost',port)) while True: cmsg=s.recv(1024) print(cmsg) msg=raw_input('CONNECTION REQUEST>') s.send(msg) if msg=='bye': break s.close() # Close the connection
  • 31. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 31 Sample Output student@a4it167:~$ python arpserver.py waiting for client connection Got connection from ('127.0.0.1', 38698) Found not found student@a4it167:~$ python clientarp.py Thank you for connecting CONNECTION REQUEST>f8:bc:12:86:31:c0 172.16.7.167 CONNECTION REQUEST>f8:bc:12:86:31:c9 As per Laboratory Rubrics in Annexure I CATEGORY MAX. MARKS ALLOTED MARKS AWARDED Design & Logic 40 Code design 40 Record Submission 10 Viva 10 TOTAL 100 Result Thus python program for simulating ARP/RARP protocols using TCP is executed and verified successfully
  • 32. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 32 Aim: To write a Python program for simulating DNS protocols using TCP Procedure: Server 1. Start the program 2. create a list with IPlist and weblist 3. import pandas and store the csv file as dataframe 4. Create a socket using socket class bind with the 'ServerIPaddress' and PortNo. 5. Listen for client Request 6. Accept the socket which is created by the client. 7. Server maintains the table in which IP and corresponding MAC addresses are stored. 8. Read the IP address which is send by the client. 9. Map the IP address with its MAC address and return the MAC address to client. 10. Do the same for RARP - MAC ADDRESS to IPADDRESS Client 1. Start the program 2. Create the Socket with server 3. Using socket connection is established between client and server. 4. Get the IP address to be converted into MAC address 5. Send this IP address to server. 6. Server returns the MAC address to client if is is available else Display unreachable. 7. Do the same for RARP - Send MAC ADDRESS and get IPADDRESS 8. Server returns the IP address to client if is is available else Display Not Found. Expt. No: 6 SIMULATION OF DNS USING TCP Date:
  • 33. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 33 Program: server #!/usr/bin/python # This is server.py file import socket # Import socket module s = socket.socket() # Create a socket object host = socket.gethostname() # Get local machine name port = 40841 # Reserve a port for your service. s.bind(('localhost', port)) # Bind to the port s.listen(5) print("waiting for client connection") # Now wait for client connection. c, addr = s.accept() # Establish connection with client. print 'Got connection from', addr c.send('Thank you for connecting') iplist=['172.16.7.167','172.16.7.168','172.16.7.166','172.16.7.170','172.16.7.165'] weblist=['www.google.com','www.yahoo.com','www.gmail.com'] while True: data=c.recv(1024) if data in weblist: i=weblist.index(data) c.send(iplist[i]) print "Found" else: print "not found" c.close() # Close the connection Client #!/usr/bin/python # This is server.py file import socket # Import socket module s = socket.socket() # Create a socket object host = socket.gethostname() # Get local machine name port = 40841 # Reserve a port for your service. s.connect(('localhost',port)) while True: cmsg=s.recv(1024) print(cmsg) msg=raw_input('CONNECTION REQUEST>') s.send(msg) if msg=='bye': break s.close() # Close the connection
  • 34. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 34 Sample Output: student@a4it167:~$ python arpserver.py waiting for client connection Got connection from ('127.0.0.1', 36631) Found Found Found not found student@a4it167:~$ python clientarp.py Thank you for connecting CONNECTION REQUEST>www.google.com 172.16.7.167 CONNECTION REQUEST>www.yahoo.com 172.16.7.168 CONNECTION REQUEST>www.gmail.com 172.16.7.166 CONNECTION REQUEST>www.bing.com As per Laboratory Rubrics in Annexure I CATEGORY MAX. MARKS ALLOTED MARKS AWARDED Design & Logic 40 Code design 40 Record Submission 10 Viva 10 TOTAL 100 Result Thus python program for simulating DNS protocols using TCP is executed and verified successfully
  • 35. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 35 Aim: To write a python program for simulation of error correction code (parity checker) Procedure: 1. Enter the decimal number 2. Convert the decimal number to binary. 3. Blocks of data from the source are subjected to a check bit or parity bit generator form, where a parity of :  1 is added to the block if it contains odd number of 1’s, and  0 is added if it contains even number of 1’s Program: Server import socket s=socket.socket() host=socket.gethostname() port=6320 s.bind(('localhost',port)) s.listen(5) print('waiting for client connection') c, addr=s.accept() print 'Got connection from', addr c.send("Thank u for connecting...") while True: data=c.recv(1024) if(data.count('1')%2!=0): c.send('accepted') else: c.send('rejected') c.close() Expt. No: 7 SIMULATION OF ERROR CORRECTION CODE (PARITY CHECKER) Date:
  • 36. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 36 Client import socket import random s=socket.socket() host=socket.gethostname() port=6320 s.connect(('localhost',port)) print(s.recv(1024)) bin=bin(29) while True: bin=("Get a number") n=bin.count('1') if(n%2==0): bin=bin+'1' else: bin=bin+'0' c=random.randint(0,1) if(c==1): s.send(bin) else: s.send(bin+'1') smsg=s.recv(1024) print(smsg) if're' in smsg: smsg=s.recv(1024) print(smsg) s.close() Sample Output: student@a4it167:~$ python parity.py waiting for client connection Got connection from ('127.0.0.1', 48836) student@a4it167:~$ python pclient.py Thank u for connecting... rejected
  • 37. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 37 As per Laboratory Rubrics in Annexure I CATEGORY MAX. MARKS ALLOTED MARKS AWARDED Design & Logic 40 Code design 40 Record Submission 10 Viva 10 TOTAL 100 Result Thus a python program for simulation of error correction code (parity checker) is executed and verified successfully
  • 38. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 38 Aim: To write a python program for FTP file transfer using UDP algorithm. Procedure: Server 1. Start the program. 2. Create a UDP socket for communication using socket library. 3. Bind the socket with UDP_IP and IN_PORT with process. 4. Put socket in waiting for input file upload. 5. Once a client send a request to connect, accept and establish connection acknowledgment. 6. Get file name and read the content and send the content of file. 7. close the file. Client 1. Start the program. 2. Create a UDP socket for communication using socket library. 3. Socket is send with filename UDP_IP and UDP_PORT. 4. Request is sent to server with send method. 5. Open the new file and write. 6. Display message as filename Finish! Program: server import socket import select UDP_IP="127.0.0.1" IN_PORT=5016 timeout=3 sock=socket.socket(socket.AF_INET,socket.SOCK_DGRAM) sock.bind((UDP_IP,IN_PORT)) print("Waiting for client file upload") while True: data,addr=sock.recvfrom(1024) if data: print("file_name:",data) file_name=data.strip() file_name=file_name.decode() file_name="17uit071"+file_name print(file_name) f=open(file_name,'wb') Expt. No: 8 SIMULATION OF FTP PROTOCOL USING UDP Date:
  • 39. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 39 while True: ready=select.select([sock],[],[],timeout) if ready[0]: data,addr=sock.recvfrom(1024) print(data) f.write(data) else: print("%s Finish!"%file_name) f.close() break Client import socket import time import sys UDP_IP="127.0.0.1" UDP_PORT=5016 buf=1024 file_name=sys.argv[0] file_name=file_name.encode() sock=socket.socket(socket.AF_INET,socket.SOCK_DGRAM) sock.sendto(file_name,(UDP_IP,UDP_PORT)) print("sending %s...."%file_name) f=open(file_name,"rb") data=f.read(buf) while(data): if(sock.sendto(data,(UDP_IP,UDP_PORT))): data=f.read(buf) print(data) time.sleep(0.02)#Give receiver a bit time to save sock.close() f.close() Sample Output: student@a4it166:~$ python ex8client.py sending ex8client.py.... student@a4it166:~$ student@a4it166:~$ python ex8server.py Waiting for client file upload ('file_name:', 'ex8client.py') 17uit001ex8client.py import socket import time import sys
  • 40. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 40 UDP_IP="127.0.0.1" UDP_PORT=5016 buf=1024 file_name=sys.argv[0] file_name=file_name.encode() sock=socket.socket(socket.AF_INET,socket.SOCK_DGRAM) sock.sendto(file_name,(UDP_IP,UDP_PORT)) print("sending %s...."%file_name) f=open(file_name,"rb") data=f.read(buf) while(data): if(sock.sendto(data,(UDP_IP,UDP_PORT))): data=f.read(buf) print(data) time.sleep(0.02)#Give receiver a bit time to save sock.close() f.close() 17uit001ex8client.py Finish! As per Laboratory Rubrics in Annexure I CATEGORY MAX. MARKS ALLOTED MARKS AWARDED Design & Logic 40 Code design 40 Record Submission 10 Viva 10 TOTAL 100 Result Thus a python program for FTP file transfer using UDP algorithm. is executed and verified successfully.
  • 41. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 41 Aim: To study network simulator 2 Study of NS2: Introduction: The network simulator is discrete event packet level simulator. The network simulator covers a very large number of application of different kind of protocols of different network types consisting of different network elements and traffic models. Network simulator is a package oftools that simulates behaviour of networks such as creating network topologies, log events that happen under any load, analyse the eventsand understand the network Platform required to run the network simulator • Unix and Unix like systems • Linux(Use Fedora or Ubuntu version) • Windows 95/98/NT/2000/XP Backend Environment of network simulator Network simulator is mainly based on two languages. They are C++ and OTcl. OTcl is the object oriented version of Tool Command language. The network simulator is a bank of different network and protocol objects. C++ helps in the following way: • It helps to increase the efficiency of simulation • It is used to provide details of the protocols and their operation • It is used to reduce packet and event processing time OTcl helps in the following way: • With the help of OTcl we can describe different network topologies • it helps us to specify the protocols and their applications • It allows fast development • Tcl is compatible with many platforms and it is flexible for integration • Tcl is very easy to use and it is available for free Basics of Tcl Programming (w.r.t NS2) Before we get into the program we should consider the following things: 1. Initialisation and termination aspects of network simulator 2. Defining the network nodes, links, queues and topology as well 3. Defining the agents and their applications 4. Network adminiatrator(NAM) 5. Tracing Expt. No: 9 STUDY OF NETWORK SIMULATOR 2, NETWORK TOPOLOGIES AND CONGESTION CONTROL Date:
  • 42. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 42 Initialisation: To start a new simulator we write set ns[new simulator] From the above we get that a variable ns is being initialised by using a set command. Here the code [new simulator] is a instantiation of the class Simulator which uses the reserved word ‘new’. So we can call all the methods present inside the class simulator by using the variable ns Creating the output files # To create the trace files we write set tracefile1[open out.tr w] $ns trace-all $tracefile1 #To create the nam files we write set namfile1[open out.nam w] $ns namtrace-all $namfile1 In the above we create a output trace file out.tr and a NAM visualisation file out.nam. But in the Tcl script they are not called by their names declared, while they are called by the pointers initialised for them such as tracefile1 and namfile1 respectively. The line which starts with ‘#’ are commented. The next line opens the file ‘out.tr’ which is used for writing is declared ‘w’. The next line uses a simulator method trace-all by which we will trace all the events in a particular format. The termination program is done by using a ‘finish’ procedure. #Defining the ‘finish’ procedure proc finish { } { global ns tracefile1 namfile1 $ns flush-trace close $tracefile close $namfile exec nam out.nam & exit 0 } In the above the word ‘proc’ is used to declare a procedure called ‘finish’. The word ‘global’ is used to tell what variables are being used outside the procedure. ‘flush-trace’ is a simulator method that dumps the traces on the respective files. The command ‘close’ is used to close the trace files and the command ‘exec’ is used to execute the nam visualisation. The command ‘exit’ closes the application and returns 0 as zero(0) is default for clean exit. In ns we end the program by calling the ‘finish’ procedure #end the program $ns at 125.0 “finish”
  • 43. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 43 Thus the entire operation ends at 125 seconds. To begin the simulation we will use the command #start the simulation process $ns run Defining nodes, links, queues and topology Create a node: set n0[ns node] In the above we created a node that is pointed by a variable n0. While referring the node in the script we use $n0. Similarly we create another node n2. Now we will set a link between the two nodes. $ns duplex-link $n0 $n2 10Mb 10ms DropTail Here, a bi-directional link is created between n0 and n2 with a capacity of 10Mb.sec and a propagation delay of 10ms.In NS an output queue of a node is implemented as a part of a link whose input is that node to handle the overflow at the queue. But if the buffer capacity of the output queue is exceeded then the last packet arrived is dropped and here the ‘DropTail’ option is used. Many other options such as RED(Random Early Discard) mechanism, FQ(Fair Queuing), DRR(Deficit Round Robin), SFQ(Stochastic Fair Queuing)are available. Now we will define the buffer capacity of the queue related to the above link #Set queue size of the link $ns queue-link $n0 $n2 20 Summarizing the above three things we get #create nodes set n0 [$ns node] set n1 [$ns node] set n2 [$ns node] set n3 [$ns node] set n4 [$ns node] set n5 [$ns node] #create links between the nodes $ns duplex-link $n0 $n2 10Mb 10ms DropTail $ns duplex-link $n1 $n2 10Mb 10ms DropTail $ns duplex-link $n2 $n3 0.3Mb 100ms DropTail $ns duplex-link $n3 $n2 0.3Mb 100ms DropTail $ns duplex-link $n0 $n2 0.5Mb 40ms DropTail $ns duplex-link $n0 $n2 0.5Mb 40ms DropTail #set queue-size of the link (n2-n3) to 20 $ns queue-limit $n2 $n3 20
  • 44. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 44 Agents and application TCP TCP is a dynamic reliable congestion protocol which is used to provide reliable transport of packets from one host to another host by sending acknowledgements on proper transfer or loss of packets. Thus TCP requires bi-directional links in order for acknowledgements to return to the source. Now we will show how to set up tcp connection between two nodes #setting a tcp connection set tcp [new Agent/TCP] $ns attach-agent $n0 $tcp set sink [new Agent/TCPSink] $ns attach-agent $n4 $sink $ns connect $tcp $sink $tcp set fid_1 $tcp set packetSize_552 The command ‘set tcp [new Agent/TCP]’ gives a pointer called ‘tcp’ which indicates the tcp agent which is a object of ns. Then the command ‘$ns attach-agent $n0 $tcp’ defines the source node of tcp connection. Next the command ‘set sink[new Agent/TCPSink]’ defines the destination of tcp by a pointer called sink. The next command ‘$ns attach-agent $n4 $sink’ defines the destination node as n4. Next the command ‘$ns connect $tcp $sink’ makes the TCP connection between the source and the destination. i.e n0 and n4. When we have several flows such as TCP, UDP etc in a network. So,to identify these flows we ark these flows by using the command ‘$tcp set fid_1’. In the last line we set the packet size of tcp as 552 while the default packet size of tcp is 1000. FTP over TCP File Transfer Protocol(FTP) is a standard mechanism provided by the Internet for transferring files from one host to another. Well, This is the most common task expected from a networking or a internetworking. FTP differs from other client server applications in that it establishes between the client and the server. One connection is used for data transfer and other one is used for providing control information. FTP uses the services of the TCP. It needs two connections. The well known port 21 is used for control connections and the other port 20 is used for data transfer.
  • 45. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 45 Well here we will learn in how to run a FTP connection over a TCP #Initiating FTP over TCP set ftp [new Application/FTP] $ftp attach-agent $tcp In above, the command ‘set ftp [new Application/FTP]’ gives a pointer called ftp which indicates the FTP application. Next we attach the ftp application with tcp agent as FTP uses the services of TCP UDP The User data protocol is one of the main protocols of the internet protocol suite. UDP helps the host to send messages in the form of datagrams to another host which is present in a Internet protocol network without any kind of requirement for channel transmission setup. UDP provides a unreliable service and the datagrams may arrive out of order, appear duplicated or go missing without notice. UDP asumes that error checking and correction is either not necessary or performed in the application avoiding the overhead of such processing at the network interface level. Time sensitive applications often use UDP because dropping packets is preferable to waiting for delayed packets, which may not be an option in a real-time system . Now we will learn how to create a UDP connection in network simulator #setup a UDP connection set udp [new Agemt/UDP] $ns attach-agent $n1 $udp $set null [new Agent/Null] $ns attach-agent $n5 $null $ns connect $udp $null $udp set fid_2 Similarly, the command ‘set udp [new Agent/UDP]’ gives a pointer called ‘udp’ which indicates the udp agent which is an object of ns. Then the command ‘$ns attach-agent $n1 $udp’ defines the source node of udp connection. Next the command ‘set null [new Agent/Null]’ defines the destination of udp by a pointer called null. The next command ‘$ns attach-agent $n5 $null’ defines the destination node as n5. Next, the command ‘$ns connect $udp $null’ makes the UDP connection between the source and the destination. i.e n1 and n5. When we have several flows such as TCP,UDP etc in a network. So, to identify these flows we mark these flows by using the command ‘$udp set fid_2’
  • 46. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 46 Constant Bit Rate(CBR) Constant Bit rate(CBR) is a term used in telecommunications, relating to the quality of service. When referring to codecs, constant bit rate encoding means that the rate at which a codec’s output data should be consumed is constant. CBR is useful for streaming multimedia content on limited capacity channels since it is the maximum bit rate that matters, not the average, so CBR would be used to take advantage of all of the capacity. CBR would not be the optimal choice for storage as it would not allocate enough data for complex sections (resulting in degraded quality) while wasting data on simple sections. CBR over UDP connection #setup cbr over udp set cbr [new Application/Traffic/CBR] $cbr attach-agent $udp $cbr set packetSize_1000 $cbr set rate_0.01Mb $cbr set random_false In the above we define CBR connection over a UDP one. Well we have already defined the UDP source and UDP agent as same as TCP. Instead of defining the rate we define the time interval between the transmission of packets in the command ‘$cbr set rate_0.01Mb’. Next, with the help of the command ‘$cbr set random_false’ we can set random noise in cbr traffic, we can keep the noise by setting it to false or we can set the noise on by the command ‘$cbr set random_1’. We an set by packet size by using the command ‘$cbr set packetSize_(packet size). We can set the packet size up to sum value in bytes. Scheduling events In ns the tcl script defines how to schedule events or in other words at what time which event will occur and stop. This can be done using the commands ‘$ns at’ So here in our program we will schedule the ftp and cbr. 1 #scheduling the events 2 $ns at 0.1 “cbr start” 3 $ns at 1.0 “ftp start” 4 $ns at 124.0 “ftp stop” 5 $ns at 124.5 “cbr stop”
  • 47. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 47 Network Animator (NAM) When we will run the above program in ns then we can visualise the network in the NAM. But instead of giving random positions to the nodes we can give suitable initial positions to the nodes and can form a suitable topology. So, in our program we can give positions to the nodes in NAM in the following way #Give position to the nodes in NAM $ns duplex_link_op $n0 $n2 orient-right-down $ns duplex_link_op $n1 $n2 orient-right-up $ns duplex_link_op $n2 $n3 orient-right $ns duplex_link_op $n3 $n2 orient-left $ns duplex_link_op $n3 $n4 orient-right-up $ns duplex_link_op $n3 $n5 orient-right-down We can also define the colour of cbr and tcp packets for identification in NAM. For this we use the following command. #Marking the flows $ns color1 Blue $ns color2 Red To view the network animator we need to type the command: nam Tracing Tracing Objects NS simulation can produce visualization trace as well as ASCII file corresponding to the events that are registered at the network. While tracing ns inserts the objects: EnqT, DeqT, RecvT & DrpT. EnqT registers information regarding the arrival of packet and is queued at the input queue of the link. When the overflow of a packet occurs, then the information of the dropped packet is registered n DrpT. DeqT holds the information about the packet that is dequeued instantly. RecvT hold the information about the packet that has been received instanty. Event Time From node To node Pkt type Pkt size Flags Fid Src addr Dst addr Seq num Pkt id Structure of Trace files 1. The first field is event. It gives you tfour possible symbols ‘+’,’-‘,’r’,’d’. These four symbols correspond respectively to enqueued, dequeued, received and dropped.
  • 48. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 48 2. The second field gives the time at which the event occurs. 3. The third gives you the input node of the link at which the event occurs 4. The fourth gives you the output node at which the event occurs 5. The fifth shows the information about the packet .i.e whether the packet is UDP or TCP 6. The sixth gives the packet size 7. The seventh field gives information about some flags 8. The eighth field is the flow id(fid) for IPv6 that a user can set for each flow in tcl script. It is also used for specifying the color of flow in NAM display 9. The ninth field is the source address 10.The tenth field is the destination address 11.The eleventh field is the network layer protocol’s packet sequence number 12.The last field shows the unique id of the packet Following are trace of two events: r 1.84471 2 1 cbr 210 ------- 1 3 .0 1.0 195 600 r 1.84566 2 0 ack 40 ------- 2 3.2 0.1 82 602 The trace file can be viewed with the cat command: cat out.tr The Network Animator (NAM) tool: • The Network Animator(nam) is a completely separate program that is distributed with NS simulator • This program is named nam and it shows the progression of the packets through the network. .NAM FILE: • The nam program reads an input file(containing the packet transmission events) and draw the network events graphically.
  • 49. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 49 Make NS output network event information for NAM: The steps to create a nam file are given below: Create an output file Activate the NAM trace failure in NS before running the simulation (this will tell NS to write NAM events output to the output file). Close the output file at the end of the simulation run. Then the nam file is run with the output file (as input file for nam) Here is an example of code in Tcl to achieve this: #(1) Create the trace file set namfile [open out.nam w] #(2) Tell NS to write NAM network events to this trace file $ns namtrace-all $namfile #(3) Close output file at the end of the simulation run proc finish {} { global ns namfile $ns flush-trace ;# flush trace files close $namfile ;#close trace file exec nam out.nam & ; # run NAM from inside the NS simulation exit 0 }
  • 50. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 50 XGRAPH The xgraph program draws a graph on an X display given data read from either data files or from standard input if no files are specified. It can display up to 64 independent data sets using different colors and/or line styles for each set. It annotates the graph with a title, axis labels, grid lines or tick arks, grid labels and a legend.There are options to control the appearance of most components of the graph. A data set consists of an ordered list of points of the form “directive X Y”. For directive “draw”, a line will be drawn between the previous point and the current point. Specifying a “ move” directive tells xgraph not to draw a line between the points. “draw” is the default directive. The name of a data set can be specified by enclosing the name in double quotes. Overall graphing options for the graph can be specified in data files by writing lines of the form “¡option¿: ¡ value¿”. The interface used to specify the size and location of this window depends on the window manager currently in use. Once the window has been opened, all of the data sets will be displayed graphically with a legend in the upper right corner of the screen.Xgraph also presents three control buttons in the upper left corner of each window: Hardcopy, Close and About Xgraph accepts a large number of options most of which can be specified either on the command line, in the user’s .Xdefaults or .Xresources file, or in the data files themselves. Suppose we have three output files as follows: Now we have to open three output files. The following lines have to appear ‘early’ in the Tcl script. set f0 [open out0.tr w] set f1 [open out1.tr w] set f2 [open out2.tr w] These files have to be closed at some point. We use a modified ‘finish’ procedure to do that. proc finish{} { global f0 f1 f2 #close the output files close $f0 close $f1 close $f2 #Call xgraph to display the results exec xgraph out0.tr out1.tr out2.tr –geometry 800x400 & exit 0 }
  • 51. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 51 Procedure:  Open vi editor and type program. Program name should have the extension “ .tcl” [root@localhost ~]# vi lab1.tcl  Save the program by pressing “ESC key” first, followed by “Shift and :” keys simultaneously and type “wq” and press Enter key.  Open vi editor and type awk program. Program name should have the extension “.awk ” [root@localhost ~]# vi lab1.awk  Save the program by pressing “ESC key” first, followed by “Shift and :” keys simultaneously and type “wq” and press Enter key.  Run the simulation program [root@localhost~]# ns lab1.tcl  Here “ns” indicates network simulator. We get the topology shown in the snapshot.  Now press the play button in the simulation window and the simulation will begins.  After simulation is completed run awk file to see the output , [root@localhost~]# awk –f lab1.awk lab1.tr [root@localhost~]# vi lab1.tr
  • 52. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 52 Program: set ns [new Simulator] set nf [open PA1.nam w] $ns namtrace-all $nf set tf [open PA1.tr w] $ns trace-all $tf proc finish { } { global ns nf tf $ns flush-trace close $nf close $tf exec nam PA1.nam & exit 0 } set n0 [$ns node] set n2 [$ns node] set n3 [$ns node] $ns duplex-link $n0 $n2 200Mb 10ms DropTail $ns duplex-link $n2 $n3 1Mb 1000ms DropTail $ns queue-limit $n0 $n2 10 set udp0 [new Agent/UDP] $ns attach-agent $n0 $udp0 set cbr0 [new Application/Traffic/CBR] $cbr0 set packetSize_ 500 $cbr0 set interval_ 0.005 $cbr0 attach-agent $udp0 set null0 [new Agent/Null] $ns attach-agent $n3 $null0 $ns connect $udp0 $null0 $ns at 0.1 "$cbr0 start" $ns at 1.0 "finish" $ns run Output:
  • 53. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 53 As per Laboratory Rubrics in Annexure I CATEGORY MAX. MARKS ALLOTED MARKS AWARDED Design & Logic 40 Code design 40 Record Submission 10 Viva 10 TOTAL 100 Result Thus NS2 simulator is executed and verified successfully.
  • 54. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 54 Aim: To write program to implement routing protocol.  Distance vector  OSPF RIP ROUTING PROTOCOL 1. Distance vector routing is distributed, i.e., algorithm is run on all nodes. 2. Each node knows the distance (cost) to each of its directly connected neighbors. 3. Nodes construct a vector (Destination, Cost,NextHop) and distributes to its neighbors. 4. Nodes compute routing table of minimum distance to every other node via NextHop using information obtained from its neighbors. Initial State 4. In given network, cost of each link is 1 hop. 5. Each node sets a distance of 1 (hop) to its immediate neighbor and cost to itself as 0. 6. Distance for non-neighbors is marked as unreachable with value ∞ (infinity). 7. For node A, nodes B, C, E and F are reachable, whereas nodes D and G are unreachable. Destination Cost NextHop Destination Cost NextHop Destination Cost NextHop A 0 A A 1 A A 1 A B 1 B B 1 B B ∞ ― C 1 C C 0 C C ∞ ― D ∞ — D 1 D D ∞ ― E 1 E E ∞ ― E ∞ ― F 1 F F ∞ ― F 0 F G ∞ ― G ∞ ― G 1 G Node A's initial table Node C's initial table Node F's initial table Expt. No: 11 SIMULATION OF ROUTING PROTOCOL USING NS2 Date:
  • 55. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 55 Sharing & Updation Each node sends its initial table (distance vector) to neighbors and receives their estimate. Node A sends its table to nodes B, C, E & F and receives tables from nodes B, C, E & F. Each node updates its routing table by comparing with each of its neighbor's table For each destination, Total Cost is computed as: TotalCost = Cost (Node to Neighbor) + Cost (Neighbor to Destination) If TotalCost<Cost then Cost = TotalCost and NextHop = Neighbor Node A learns from C's table to reach node D and from F's table to reach node G. Total Cost to reach node D via C = Cost (A to C) + Cost(C to D) = 1 + 1 = 2. Since 2 < ∞, entry for destination D in A's table is changed to (D, 2, C) Total Cost to reach node G via F = Cost(A to F) + Cost(F to G) = 1 + 1 = 2 Since 2 < ∞, entry for destination G in A's table is changed to (G, 2, F) Each node builds complete routing table after few exchanges amongst its neighbors. Open shortest path first (OSPF) An area is a group of contiguous network and routers. Routers belonging to same area shares a common topology table and area I’d. The area I’d is associated with router’s interface as a router can belong to more than one area. There are some roles of router in OSPF: 1. Backbone router – The area 0 is known as backbone area and the routers in area 0 are known as backbone routers. If the routers exists partially in the area 0then also it is a backbone router. 2. Internal router – An internal router is a router which have all of its interfaces in a single area. 3. Area Boundary Router (ABR) – The router which connects backbone area with another area is called Area Boundary Router. It belongs to more than one area. The ABRs therefore maintain multiple link-state databases that describe both the backbone topology and the topology of the other areas. 4. 4.Area Summary Border Router (ASBR) – When an OSPF router is connected to a different protocol like EIGRP, or Border Gateway Protocol, or any other routing protocol then it is known as AS. The router which connects two different AS (in
  • 56. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 56 which one of the interface is operating OSPF) is known as Area Summary Border Router. These routers perform redistribution. ASBRs run both OSPF and another routing protocol, such as RIP or BGP. ASBRs advertise the exchanged external routing information throughout their Link State Routing and construct the least cost tree for the following graph and explain the working of OSPF.  Each node knows state of link to its neighbors and cost.  Nodes create an update packet called link-state packet (LSP) that contains: IDof the node o List of neighbors for that node and associated cost o 64-bit Sequence number o Time to live  Link-state routing protocols rely on two mechanisms: o Reliable dissemination of link-state information to all other nodes o Route calculation from the accumulated link-state knowledge Apply Link State Routing and construct the least cost tree for the following graph and explain the working of OSPF.  Each node knows state of link to its neighbors and cost.  Nodes create an update packet called link-state packet (LSP) that contains: o ID of the node o List of neighbors for that node and associated cost o 64-bit Sequence number o Time to live  Link-state routing protocols rely on two mechanisms: o Reliable dissemination of link-state information to all other nodes o Route calculation from the accumulated link-state knowledge Reliable Flooding  Each node sends its LSP out on each of its directly connected links.  When a node receives LSP of another node, checks if it has an LSP already for that node. o If not, it stores and forwards the LSP on all other links except the incoming one. o Else if the received LSP has a bigger sequence number, then it is stored and forwarded. Older LSP for that node is discarded. o Otherwise discard the received LSP, since it is not latest for that node. Thus recent LSP of a node eventually reaches all nodes, i.e., reliable flooding. (a) (b) (c) (d) Flooding of LSP in a small network is as follows: o When node X receives Y’s LSP (fig a), it floods onto its neighbors A and C (fig o Nodes A and C forward it to B, but does not sends it back to X (fig c). o Node B receives two copies of LSP with same sequence number.
  • 57. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 57  Accepts one LSP and forwards it to D (fig d). Flooding is complete. LSP is generated either periodically or when there is a change in the topology. Route Calculation Each node knows the entire topology, once it has LSP from every other node. Forward search algorithm is used to compute routing table from the received LSPs. Each node maintains two lists, namely Tentative and Confirmed with entries of the form (Destination, Cost, NextHop). Forward Search algorithm (Djkstra’s Shortest Path)  Initialize the Confirmed list with an entry for the Node (Cost = 0).  Node just added to Confirmed list is called Next. Its LSP is examined.  For each neighbor of Next, calculate cost to reach each neighbor as Cost (Node to Next) + Cost (NexttoNeighbor).  If Neighbor is neither in Confirmed nor in Tentative list, then add (Neighbor, Cost, NextHop) to Tentative list.  If Neighbor is in Tentative list, and Cost is less than existing cost, then replace the entry with (Neighbor, Cost, NextHop).  If Tentative list is empty then Stop, otherwise move least cost entry from Tentative list to Confirmed list. Go to Step 2. Procedure:  Open vi editor and type program. Program name should have the extension “ .tcl” [root@localhost ~]# vi lab1.tcl  Save the program by pressing “ESC key” first, followed by “Shift and :” keys simultaneously and type “wq” and press Enter key.  Open vi editor and type awk program. Program name should have the extension “.awk ” [root@localhost ~]# vi lab1.awk  Save the program by pressing “ESC key” first, followed by “Shift and :” keys simultaneously and type “wq” and press Enter key.  Run the simulation program [root@localhost~]# ns lab1.tcl
  • 58. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 58  Here “ns” indicates network simulator. We get the topology shown in the snapshot.  Now press the play button in the simulation window and the simulation will begins.  After simulation is completed run awk file to see the output , [root@localhost~]# awk –f lab1.awk lab1.tr [root@localhost~]# vi lab1.tr Program: Distance vector set ns [new Simulator] set nf [open out.nam w] $ns namtrace-all $nf set tr [open out.tr w] $ns trace-all $tr proc finish { } { global nf ns tr $ns flush-trace close $tr exec nam out.nam & exit 0 } set n0 [$ns node] set n1 [$ns node] set n2 [$ns node] set n3 [$ns node] set n4 [$ns node] set n5 [$ns node] $ns duplex-link $n0 $n1 10Mb 10ms DropTail $ns duplex-link $n1 $n3 10Mb 10ms DropTail $ns duplex-link $n2 $n1 10Mb 10ms DropTail $ns duplex-link $n2 $n4 10Mb 10ms DropTail $ns duplex-link $n4 $n5 10Mb 10ms DropTail $ns duplex-link $n5 $n3 10Mb 10ms DropTail $ns duplex-link-op $n0 $n1 orient right-down $ns duplex-link-op $n1 $n3 orient right $ns duplex-link-op $n2 $n1 orient right-up set tcp [new Agent/TCP] $ns attach-agent $n0 $tcp set ftp [new Application/FTP] $ftp attach-agent $tcp set sink [new Agent/TCPSink] $ns attach-agent $n3 $sink
  • 59. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 59 set udp [new Agent/UDP] $ns attach-agent $n2 $udp set cbr [new Application/Traffic/CBR] $cbr attach-agent $udp set null [new Agent/Null] $ns attach-agent $n3 $null $ns connect $tcp $sink $ns connect $udp $null $ns rtmodel-at 1.0 down $n1 $n3 $ns rtmodel-at 2.0 up $n1 $n3 $ns rtmodel-at 4.0 down $n1 $n3 $ns rtproto DV $ns at 0.5 "$ftp start" $ns at 0.0 "$cbr start" $ns at 5.0 "finish" $ns run Output:
  • 60. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 60 OSPF Program set ns [new Simulator] set nr [open thro.tr w] $ns trace-all $nr set nf [open thro.nam w] $ns namtrace-all $nf proc finish { } { global ns nr nf $ns flush-trace close $nf close $nr exec nam thro.nam & exit 0 } for { set i 0 } { $i < 12} { incr i 1 } { set n($i) [$ns node]} for {set i 0} {$i < 8} {incr i} { $ns duplex-link $n($i) $n([expr $i+1]) 1Mb 10ms DropTail } $ns duplex-link $n(0) $n(8) 1Mb 10ms DropTail $ns duplex-link $n(1) $n(10) 1Mb 10ms DropTail $ns duplex-link $n(0) $n(9) 1Mb 10ms DropTail $ns duplex-link $n(9) $n(11) 1Mb 10ms DropTail $ns duplex-link $n(10) $n(11) 1Mb 10ms DropTail $ns duplex-link $n(11) $n(5) 1Mb 10ms DropTail set udp0 [new Agent/UDP] $ns attach-agent $n(0) $udp0 set cbr0 [new Application/Traffic/CBR] $cbr0 set packetSize_ 500 $cbr0 set interval_ 0.005 $cbr0 attach-agent $udp0 set null0 [new Agent/Null] $ns attach-agent $n(5) $null0 $ns connect $udp0 $null0 set udp1 [new Agent/UDP] $ns attach-agent $n(1) $udp1 set cbr1 [new Application/Traffic/CBR] $cbr1 set packetSize_ 500 $cbr1 set interval_ 0.005 $cbr1 attach-agent $udp1 set null0 [new Agent/Null] $ns attach-agent $n(5) $null0 $ns connect $udp1 $null0 $ns rtproto LS
  • 61. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 61 $ns rtmodel-at 10.0 down $n(11) $n(5) $ns rtmodel-at 15.0 down $n(7) $n(6) $ns rtmodel-at 30.0 up $n(11) $n(5) $ns rtmodel-at 20.0 up $n(7) $n(6) $udp0 set fid_ 1 $udp1 set fid_ 2 $ns color 1 Red $ns color 2 Green $ns at 1.0 "$cbr0 start" $ns at 2.0 "$cbr1 start" $ns at 45 "finish" $ns run Output
  • 62. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 62 As per Laboratory Rubrics in Annexure I CATEGORY MAX. MARKS ALLOTED MARKS AWARDED Design & Logic 40 Code design 40 Record Submission 10 Viva 10 TOTAL 100 Result Thus program to implement routing protocol such as Distance Vector and OSPF are executed and verified successfully.
  • 63. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 63 Aim: To analyze various Protocols using Ethernet Protocol Analyzer.(WireShark) ETHEREAL ANALYSER: The basic tool for observing the messages exchanged between executing protocol entities is called a packet sniffer. As the name suggests, a packet sniffer captures (“sniffs”) messages being sent/received from/by your computer; it will also typically store and/or display the contents of the various protocol fields in these captured messages. A packet sniffer itself is passive. It observes messages being sent and received by applications and protocols running on your computer, but never sends packets itself. Similarly, received packets are never explicitly addressed to the packet sniffer. Instead, a packet sniffer receives a copy of packets that are sent/received from/by application and protocols executing on your machine. Figure 1 shows the structure of a packet sniffer. At the right of Figure 1 are the protocols (in this case, Internet protocols) and applications (such as a web browser or ftp client) that normally run on your computer. The packet sniffer, shown within the dashed rectangle in Figure 1 is an addition to the usual software in your computer, and consists of two parts. The packet capture library receives a copy of every link-layer frame that is sent from or received by your computer. That messages exchanged by higher layer protocols such as HTTP, FTP, TCP, UDP, DNS, or IP all are eventually encapsulated in link-layer frames that are transmitted over physical media such as an Ethernet cable. In Figure, the assumed physical media is an Ethernet, and so all upper layer protocols are eventually encapsulated within an Ethernet frame. Capturing all link-layer frames thus gives you all messages sent/received from/by all protocols and applications executing in it. The second component of a packet sniffer is the packet analyzer, which displays the contents of all fields within a protocol message. In order to do so, the packet analyzer must “understand” the structure of all messages exchanged by protocols. For example, suppose we are interested in displaying the various fields in messages exchanged by the HTTP protocol. The packet analyzer understands the format of Ethernet frames, and so can identify the IP datagram within an Ethernet frame. It also understands the IP datagram format, so that it can extract the TCP segment within the IP datagram. Finally, it Expt. No: 11 PERFORMANCE EVALUATION OF VARIOUS PROTOCOL USING SIMULATOR TOOL (WIRE SHARK) Date:
  • 64. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 64 understands the TCP segment structure, so it can extract the HTTP message contained in the TCP segment. Finally, it understands the HTTP protocol Procedure: Step1: Open wireshark Ethernet Protocol analyzer from terminal by typing wireshark Step 2: Click the capture tab and select capture devices Step 3: Choose your LAN interface card Step 4: Click the Capture tab and select Capture Filters and delete the default Protocols Step 5: Click the expressions and select Ethernet protocol. Step 6: Apply the Filter Ethernet – eth-src (Source Mac Address) Step 7: Click Start to capture live packets . Step 8: Ping the next Pc in terminal (ARP/ICMP) Step9. Browse Web pages (HTTP) , Access Mail server (TCP / UDP) Step 10: Stop the capture and analyse various protocol frame format and note it down:
  • 65. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 65 As per Laboratory Rubrics in Annexure I CATEGORY MAX. MARKS ALLOTED MARKS AWARDED Design & Logic 40 Code design 40 Record Submission 10 Viva 10 TOTAL 100 Result Thus the various protocol frame format are analyzed using Ethernet Protocol Analyzer.
  • 66. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 66 Aim: To analyze the performance of UDP & TCP protocol using file Transfer programs Procedure 1. Create UDP FTP file transfer and measure the Time taken using Date time package datetime.now() method as well as file size using os.path.getsize(<file name>) method 2. Code snippet Time Calculation and file size # Time Calculation from datetime import datetime start=datetime.now() UDP/TCP File Program etime = datetime.now() print('Time taken for file transfer',estart-stime) # To find the file size import os filesizebytes= os.path.getsize('genericpath.py') 3. Code Snippet Through put Calculation: Throughput =DataTransfer in Bytes / Time Protocol TCP UDP Time Taken for file transfer Through Put As per Laboratory Rubrics in Annexure I CATEGORY MAX. MARKS ALLOTED MARKS AWARDED Design & Logic 40 Code design 40 Record Submission 10 Viva 10 TOTAL 100 Result: The file transferred using UDP & TCP protocol and performance were analyzed. Expt. No: 12 PERFORMACE ANALYSIS UDP & TCP Date:
  • 67. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 67 1. DateTime Client 2. Image Scrapping 3. Chat Room Creation with multiple clients Expt. No: ADDITIONAL EXERCISES Date:
  • 68. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 68 CONTENT BEYOND SYLLABUS
  • 69. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 69 Aim: To study router basic configuration command using simulator software. Required : Simulator software TOGGIT The Toggit Router Simulator is designed to simulate the input and output of a generic router using the Cisco® IOS Expt. No:13 Study of Router Configuration using Toggit Date:
  • 70. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 70 Basic Router Commands & Configuration of Router Start the router simulator. You will see the prompt "Router>". This is the user mode prompt. Type "enable" to take you into privileged mode. You will see the prompt "Router#" Type "config terminal" to go directly into configuration mode. Click on the "Show Network Plan" button. Note that the router that you are configuring should be named Router1. Type "hostname Router1" to change the name of the router to Router1 Ctrl + Z to move to Previlege mode Type "show interface ethernet 0". Note that there is no protocol listed and line protocol is down. Type "show interface serial 0". Note that there is no protocol listed and line protocol is down. Type "show running-config". Again, no protocols are listed. Type "config terminal" to go directly into configuration mode. Type "interface ethernet 0" to enter interface configuration mode for the Ethernet interface. Click the Show Network Plan button on the simulator. Note that the network interface of the router has an IP address of 172.10.0.1. We will assign this IP address and a default subnet mask to this interface: Type "ip address 172.10.0.1 255.255.0.0" to assign the IP configuration. Type "no shutdown" to enable the interface. Type "exit" to leave the Ethernet interface configuration. connection will be 210.16.54.1. Here's how you configure the serial interface: Type "interface serial 0" to enter interface configuration mode for the serial interface. Type "ip address 210.16.54.1 255.255.255.0" to assign the IP address and subnet mask.
  • 71. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 71 Type "bandwidth 56" to set the bandwidth. This setting is measured in Kbps. Note: The bandwidth command is usually only used in the testing lab environment. Type "clock rate 56000" to set the DCE rate. This setting is measured in Bps. Also note that clock rate is two words. Note: The clock rate only needs to be set on the router that handles DCE. Type "no shutdown" to enable the interface. Type "exit" to leave the serial interface configuration. Type "ctrl-z" to leave config mode. Now we can check our configurations: Make sure you are in privileged mode. Type "show interface ethernet 0". Note that line protocol is up. If it is not up, repeat this lab. Type "show interface serial 0". Note that line protocol is up. If it is not up, repeat this lab. Type "show running-config". Note the IP addresses of Ethernet0 and Serial0 entries. Note: To use dynamic routing, the other routers in your network must use the same routing protocol. For this simulation, the other router will work with either RIP or IGRP. Start the router simulator. Go into privileged mode. Type "show ip route". Note that two directly connected routes are shown. Enter config mode. (Type "configure terminal" or "config t") Type "router rip" to enable RIP on your router Once RIP is enabled on a router, you must specify each network in which the router will advertise routing. Type "network 210.16.54.0" Type "network 172.10.0.0" Dynamic routing is now configured through RIP.
  • 72. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 72 Type Ctrl-z to exit config mode. Type "show ip route". Note that routes to all four networks are shown. The same steps would be used to establish IGRP routing: Enter config mode. (Type "configure terminal" or "config t") First remove RIP by typing "no router rip" Type "router igrp" to enable IGRP on your router. Once IGRP is enabled on a router, you must specify each network in which the router will advertise routing. Type "network 210.16.54.0" Type "network 172.10.0.0" Dynamic routing is now configured through IGRP. Type Ctrl-z to exit config mode. Type "show ip route". Note that routes to all four networks are shown. Note: To use dynamic routing in a network, all routers must use the same route advertisement method (IGRP or RIP). Make sure you are in privileged mode. Type = "ping 172.10.0.1" to verify the configuration of the Ethernet port. Type = "ping 172.10.0.10" to verify the connectivity with ServerA.
  • 73. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 73 Sample Output: As per Laboratory Rubrics in Annexure I CATEGORY MAX. MARKS ALLOTED MARKS AWARDED Design & Logic 40 Code design 40 Record Submission 10 Viva 10 TOTAL 100 Result Thus various basic commands for router configuration studied and successfully configure the simulator router.
  • 74. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 74 REFERENCES Video Reference: https://www.youtube.com/playlist?list=PLEbnTDJUr_IegfoqO4iPnPYQui46QqT0j https://www.youtube.com/watch?v=QKfk7YFILws Web Reference: http://enggedu.com/network_lab_exercise_programs/index.php https://www.nsnam.org/ https://www.wireshark.org https://wps.pearsoned.com/ecs_kurose_compnetw_6/216/55463/14198702.cw/index.html Book Reference: T1: Behrouz A.Forouzan, “Data Communication and Networking”, Fifth Edition, TMH, 2013.
  • 75. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 75 ROUGH WORK:
  • 76. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 76 ROUGH WORK:
  • 77. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 77 ROUGH WORK:
  • 78. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 78 ROUGH WORK:
  • 79. CS 8581 – Networks Laboratory Kamaraj College of EngineeringandTechnology,Madurai 79 ROUGH WORK: