Cn Record Experiments
Cn Record Experiments
NO : 01
NETWORK TOPOLOGY - STAR, BUS, RING
DATE :
AIM:
To create different network topologies such as star, bus and ring using network
simulator tool.
SOFTWARE REDUIRED:
• NS-2
THEORY:
STAR TOPOLOGY:
BUS TOPOLOGY:
Bus topology uses one main cable to which all nodes are directly connected. The main
cable acts as a backbone for the network. One of the computers in the network typically acts as
the computer server. The advantage of bus topology is that it is easy to connect a computer or a
peripheral device. The cable requirements are relatively less, resulting in lower cost.
RING TOPOLOGY:
In ring topology the computers in the network are connected in a circular fashion and
the data travels in one direction. Each computer is directly connected to the next computer
forming a single pathway for signals through the network. This type of network is easy to install
and manage.
ALGORITHM:
2
8. Call the finish procedure.
9. Save the file & Run the simulation.
10. Observe the traffic & Plot the behaviour with respect to different topologies.
TASK:
Construct a mesh, star and ring network for _______ nodes and observe the packet
transmission between the sender and receiver nodes. Consider node _______ as sender and
node _______ as receiver. Assume node _______ as a central hub for star topology.
PROGRAM:
STAR TOPOLOGY
set ns [new Simulator]
set nf [open out.nam w]
$ns namtrace-all $nf
proc finish {} {
global ns nf
$ns flush-trace
close $nf
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]
set n6 [$ns node]
$n0 label "Sender"
$n2 label "Sender"
$n5 label "Receiver"
$n6 label "Receiver"
$n4 shape box
$ns duplex-link $n0 $n4 1Mb 10ms DropTail
$ns duplex-link $n1 $n4 1Mb 10ms DropTail
$ns duplex-link $n2 $n4 1Mb 10ms DropTail
$ns duplex-link$n3 $n4 1Mb 10ms DropTail
$ns duplex-link$n4 $n5 1Mb 10ms DropTail
$ns duplex-link$n6 $n4 1Mb 10ms DropTail
set tcp0 [new Agent/TCP]
$ns attach-agent $n0 $tcp0
set tcp1 [new Agent/TCP]
$ns attach-agent $n2 $tcp1
set sink0 [new Agent/TCPSink]
$ns attach-agent $n5 $sink0
$ns connect $tcp0 $sink0
set sink1 [new Agent/TCPSink]
$ns attach-agent $n6 $sink1
$ns connect $tcp1 $sink1
set cbr [new Application/Traffic/CBR]
3
OUTPUT:
STAR TOPOLOGY:
BUS TOPOLOGY:
4
$cbr attach-agent $tcp0
set ftp [new Application/FTP]
$ftp attach-agent $tcp1
$ns at 0.5 "$cbr start"
$ns at 4.5 "$cbr stop"
$ns at 1.0 "$ftp start"
$ns at 5.5 "$ftp stop"
$ns at 6.0 "finish"
$ns run
BUS TOPOLOGY
set ns [new Simulator]
set nf [open out.nam w]
$ns namtrace-all $nf
proc finish {} {
global ns nf
$ns flush-trace
#Close the trace file
close $nf
#Executenam on the trace file
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]
set n6 [$ns node]
$n0 label "Sender"
$n2 label "Sender"
$n5 label "Receiver"
$n6 label "Receiver"
set lan0 [$ns newLan "$n0 $n1 $n2 $n3 $n4 $n5 $n6" 0.5Mb 40ms LL Queue/DropTail
MAC/Csma/Cd Channel]
set tcp0 [new Agent/TCP]
$ns attach-agent $n0 $tcp0
set tcp1 [new Agent/TCP]
$ns attach-agent $n2 $tcp1
set sink0 [new Agent/TCPSink]
$ns attach-agent $n5 $sink0
$ns connect $tcp0 $sink0
set sink1 [new Agent/TCPSink]
$ns attach-agent $n6 $sink1
$ns connect $tcp1 $sink1
set cbr [new Application/Traffic/CBR]
$cbr attach-agent $tcp0
set ftp [new Application/FTP]
$ftp attach-agent $tcp1
$ns at 0.5 "$cbr start"
$ns at 4.5 "$cbr stop"
5
OUTPUT:
RING TOPOLOGY:
6
$ns at 1.5 "$ftp start"
$ns at 5.5 "$ftp stop"
$ns at 6.0 "finish"
$ns run
RING TOPOLOGY
set ns [new Simulator]
set nf [open out.nam w]
$ns namtrace-all $nf
proc finish {} {
global ns nf
$ns flush-trace
close $nf
exec nam out.nam &
exit0
}
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
set n5 [$ns node]
set n6 [$ns node]
$n0 label "Sender"
$n2 label "Sender"
$n5 label "Receiver"
$n6 label "Receiver"
$ns duplex-link $n0 $n1 1Mb 10ms DropTail
$ns duplex-link $n1 $n2 1Mb 10ms DropTail
$ns duplex-link $n2 $n3 1Mb 10ms DropTail
$ns duplex-link $n3 $n4 1Mb 10ms DropTail
$ns duplex-link $n4 $n5 1Mb 10ms DropTail
$ns duplex-link $n5 $n6 1Mb 10ms DropTail
$ns duplex-link $n6 $n0 1Mb 10ms DropTail
set tcp0 [new Agent/TCP]
$ns attach-agent $n0 $tcp0
set tcp1 [new Agent/TCP]
$ns attach-agent $n2 $tcp1
set sink0 [new Agent/TCPSink]
$ns attach-agent $n5 $sink0
$ns connect $tcp0 $sink0
set sink1 [new Agent/TCPSink]
$ns attach-agent $n6 $sink1
$ns connect $tcp1 $sink1
set cbr [new Application/Traffic/CBR]
$cbr attach-agent $tcp0
set ftp [new Application/FTP]
$ftp attach-agent $tcp1
$ns at 0.5 "$cbr start"
$ns at 4.5 "$cbr stop"
$ns at 1.5 "$ftp start"
$ns at 5.5 "$ftp stop"
$ns at 6.0 "finish"
$ns run
7
8
POINTS
PERFORMANCE INDICATOR
(1 - 4)
C1 – Preparation
C2 – Observation/Measurements
C3 – Results
C4 – Interpretation
C5 – Viva voce
TOTAL (20 Points)
RESULT:
Thus the different network topologies star, bus and ring were implemented using network
simulator-2 and the packet transmission was observed between the nodes.
9
Flow Chart::
10
EX.NO : 02 ERROR DETECTION/ ERROR CORRECTION
DATE : TECHNIQUES
AIM:
To implement error detection and error correction mechanisms using Cyclic Redundancy
Check method.
SOFTWARE REQUIREMENT:
• C++ Compiler.
THEORY:
Data-link layer uses some error control mechanism to ensure that frames (data bit
streams) are transmitted with certain level of accuracy. When the bits are transmitted from one
point to another they are subjected to unpredictable changes because of interference. To detect
and correct errors some extra bits called as redundant bits are added with original data. These
redundant bits are added by the sender and removed by the receiver. Their presence allows the
receiver to detect or correct corrupted bits. CRC approach is used to detect if the received frame
contains valid data. This technique involves binary division of the data bits being sent. The
divisor is generated using polynomials. The sender performs a division operation on the bits
being sent and calculates the remainder. Before sending the actual bits, the sender adds the
remainder at the end of the actual bits. Actual data bits plus the remainder is called a codeword.
The sender transmits data bits as code words.
ALGORITHM:
1. Get the binary input data of n bits.
2. Assume a CRC generator polynomial of k bits.
3. Append k-1 zeros as redundant bits with the input data of n bits.
4. Perform modulo-2 binary division to divide binary input data by the CRC generator
polynomial.
5. Obtain remainder of division and store the CRC code.
6. Append the remainder at the end of the input data to form the encoded data.
7. Perform modulo-2 division at the receiver.
8. If the remainder is zero there is no error otherwise there is some error in the received
bits.
TASK:
___
Given the data word and CRC generator polynomial show the
generation of CRC codeword at the sender using C++ code. At the receiver side check if there
is any error in communication.
PROGRAM:
Sender Code:
Sender Code:
#include <string>
#include <bitset>
#include <iostream>
using namespace std;
int main(){
string msg,crc,encoded="";
11
OUTPUT:
Sender:
Enter the Message: 1101011
enter the crc generator polynomial:1001
00000111
Receiver:
12
cout<<"Enter the message=";
getline(cin,msg);
cout<<"Enter the crc generator polynomial=";
getline(cin,crc);
int m=msg.length(), n=crc.length();
encoded+=msg;
for (std::size_t i = 0; i < msg.length(); ++i)
{
for(int i=1 ; i<=n-1; i++)
encoded+='0';
for(int i=0;i <=encoded.length()-n; )
{
for(int j=0;j<n; j++)
encoded[i+j]= encoded[i+j]==crc[j]? '0' :'1';
for(; i<encoded.length() && encoded[i]!='1'; i++);
}
cout << bitset<8>(msg.c_str()[i]) << endl;
cout<<msg+encoded.substr(encoded.length()-n+1);
return 0;
}
}
Receiver Code:
#include <iostream>
//#include <string>
using namespace std;
int main()
{
string msg,crc,encoded="";
cout<<" Enter the Message";
getline(cin,msg);
cout<<"enter the crc generated polynomial";
getline(cin,crc);
int m=msg.length(),n=crc.length();
encoded+=msg;
for(int i=1;i<=n-1;i++)
encoded+='0';
for(int i=0;i<=encoded.length()-n;)
{
for(int j=0;j<n;j++)
encoded[i+j]=encoded[i+j]==crc[j]?'0':'1';
for(;i<encoded.length()&& encoded[i]!='1';i++);
}
encoded=encoded.substr(encoded.length()-n+1);
cout<<encoded;
int p=stoi(encoded);
if(p==0)
cout<<"No Error";
else
cout<<"error";
return 0;
}
13
14
POINTS
PERFORMANCE INDICATOR
(1 - 4)
C1 – Preparation
C2 – Observation/Measurements
C3 – Results
C4 – Interpretation
C5 – Viva voce
TOTAL (20 Points)
RESULT:
Thus the error detection and error correction mechanisms were implemented using
Cyclic Redundancy Check method.
15
Flow Chart::
16
EX.NO : 03
CSMA/CA AND CSMA/CD PROTOCOLS
DATE :
AIM:
To create a scenario and study the performance of network with CSMA /CA protocol
and compare with CSMA/CD protocol.
SOFTWARE REQUIREMENT:
• Network Simulator-2
THEORY:
The CSMA protocol operates on the principle of carrier sensing. In this protocol, a
station listens to see the presence of transmission on the cable and decides to act accordingly.
CSMA/CD:
In CSMA/CD, if a station receives other transmissions when it is transmitting, then a
collision can be detected as soon as it occurs and the transmission time can be saved. As soon as
collision is detected, the transmitting stations release jam signal. The jam signal will alert other
stations. The stations then are not supposed to transmit immediately after the collision has
occurred. Otherwise there is a possibility that the same frames would collide again. After some
back off delay time the stations will retry transmission. If again the collision takes place then
the back off time increased progressively. The efficiency of the system can be improved only
by using CSMA/CD.
CSMA/CA:
If the station is ready to transmit, senses the line by using one of the persistent
strategies. As soon as it finds the line to be idle, the station waits for an IFG (Inter frame gap)
amount of time. It then waits for some random time and sends the frame. After sending the
frame, it sets a timer and waits for the acknowledgement from the receiver. If the
acknowledgement is received before expiry of the timer, then the transmission is successful.
But if the transmitting station does not receive the expected acknowledgement before the timer
expiry then it increments back off parameter, wait for the back off time and re senses the line.
ALGORITHM:
17
OUTPUT: CSMA/CD
18
PROGRAM:
CSMA/CD
set ns [new Simulator]
#Define different colors for data flows (for NAM)
$ns color 1 green
$ns color 2 Red
set nf [open out.nam w]
$ns namtrace-all $nf
proc finish {} {
global ns nf
$ns flush-trace
close $nf
exec nam out.nam &
exit0
}
#Create six 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]
$ns at 0.0 "$n4 label Sender"
$ns at 0.0 "$n5 label sender"
$ns at 0.0 "$n0 label receiver"
$ns at 0.0 "$n1 label receiver"
$ns at 0.0 "$n3 label intermediate"
$n5 color red
$n5 shape box
$n4 color violet
$n4 shape box
#Create links between the nodes
$ns duplex-link $n4 $n2 2Mb 10ms DropTail
$ns duplex-link $n5 $n2 2Mb 10ms DropTail
$ns simplex-link $n2 $n3 0.3Mb 100ms DropTail
$ns simplex-link $n3 $n2 0.3Mb 100ms DropTail
set lan [$ns newLan "$n3 $n0 $n1" 0.5Mb 40ms LL Queue/DropTail MAC/Csma/Cd Channel]
#Setup a TCP connection
set tcp [new Agent/TCP/Newreno]
$ns attach-agent $n4 $tcp
set sink [new Agent/TCPSink/DelAck]
$ns attach-agent $n0 $sink
$ns connect $tcp $sink
$tcp set fid_ 1
$tcp set window_ 8000
$tcp set packetSize_ 552
#Setup a FTP over TCP connection
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ftp set type_ FTP
#Setup a UDP connection
set udp [new Agent/UDP]
$ns attach-agent $n5 $udp
set null [new Agent/Null]
19
OUPUT: CSMA/CA
20
$ns attach-agent $n1 $null
$ns connect $udp $null
$udp set fid_ 2
#Setup a CBR over UDP connection
set cbr [new Application/Traffic/CBR]
$cbr attach-agent $udp
$cbr set type_ CBR
$cbr set packet_size_ 1000
$cbr set rate_ 0.01mb
$cbr set random_ false
$ns at 0.1 "$cbr start"
$ns at 1.0 "$ftp start"
$ns at 124.0 "$ftp stop"
$ns at 124.5 "$cbr stop"
$ns at 125.0 "finish"
$ns run
CSMA/CA
set ns [new Simulator]
#Define different colors for data flows (for NAM)
$ns color 1 green
$ns color 2 Red
set nf [open out.nam w]
$ns namtrace-all $nf
proc finish {} {
global ns nf
$ns flush-trace
close $nf
exec nam out.nam &
exit0
}
#Create six 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]
$ns at 0.0 "$n4 label Sender"
$ns at 0.0 "$n5 label sender"
$ns at 0.0 "$n0 label receiver"
$ns at 0.0 "$n1 label receiver"
$ns at 0.0 "$n3 label intermediate"
$n5 color red
$n5 shape box
$n4 color violet
$n4 shape box
#Create links between the nodes
$ns duplex-link $n4 $n2 2Mb 10ms DropTail
$ns duplex-link $n5 $n2 2Mb 10ms DropTail
$ns simplex-link $n2 $n3 0.3Mb 100ms DropTail
$ns simplex-link $n3 $n2 0.3Mb 100ms DropTail
set lan [$ns newLan "$n3 $n0 $n1" 0.5Mb 40ms LL Queue/DropTail MAC/Csma/Ca Channel]
#Setup a TCP connection
21
22
set tcp [new Agent/TCP/Newreno]
$ns attach-agent $n4 $tcp
set sink [new Agent/TCPSink/DelAck]
$ns attach-agent $n0 $sink
$ns connect $tcp $sink
$tcp set fid_ 1
$tcp set window_ 8000
$tcp set packetSize_ 552
#Setup a FTP over TCP connection
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ftp set type_ FTP
#Setup a UDP connection
set udp [new Agent/UDP]
$ns attach-agent $n5 $udp
set null [new Agent/Null]
$ns attach-agent $n1 $null
$ns connect $udp $null
$udp set fid_ 2
#Setup a CBR over UDP connection
set cbr [new Application/Traffic/CBR]
$cbr attach-agent $udp
$cbr set type_ CBR
$cbr set packet_size_ 1000
$cbr set rate_ 0.01mb
$cbr set random_ false
$ns at 0.1 "$cbr start"
$ns at 1.0 "$ftp start"
$ns at 124.0 "$ftp stop"
$ns at 124.5 "$cbr stop"
$ns at 125.0 "finish"
$ns run
POINTS
PERFORMANCE INDICATOR
(1 - 4)
C1 – Preparation
C2 – Observation/Measurements
C3 – Results
C4 – Interpretation
C5 – Viva voce
TOTAL (20 Points)
RESULT:
Thus the CSMA/CA and CSMA/CD protocols were implemented using network
simulator-2 and the network performance was studied.
23
Flow Chart::
24
EX.NO : 04
HIGH LEVEL DATA LINK CONTROL
DATE :
AIM:
To simulate high level data control protocol using network simulator-2.
SOFTWARE REQUIREMENT:
• NS-2
THEORY:
High-Level Data Link Control (HDLC) is a bit-oriented code-transparent synchronous
data link layer protocol developed by the International Organization for Standardization (ISO) .
HDLC frames can be transmitted over synchronous or asynchronous serial communication
links. These links have no mechanism to mark the beginning or end of a frame, so the beginning
and end of each frame is to defined. This is done by using a frame delimiter, or flag, which is a
unique sequence of bits that is guaranteed not to be present inside a frame. This sequence is
'01111110', or, in hexadecimal notation, 0x7E. A frame delimiter at the end of a frame may also
mark the start of the next frame. A sequence of 7 or more consecutive 1-bits within a frame will
cause the frame to be aborted. When no frames are being transmitted on a simplex or full-
duplex synchronous link, a frame delimiter is continuously transmitted on the link.
ALGORITHM:
1. Create a simulator object.
2. Open the NAM-trace file.
3. Define a finish procedure.
4. Close the trace file and execute name on trace file.
5. Create the required number of nodes.
6. Create duplex links between the nodes.
7. Setup UDP Connection between sender and receiver nodes.
8. Apply CBR Traffic over UDP.
9. Choose distance vector routing protocol as a high level data link control.
10. Make any one of the links to go down to check the working nature of HDLC.
11. Schedule events and run the program.
TASK:
The following are the task to be done,
1. Construct a network with _______ nodes.
2. Consider node _______ as sender and node ______ as receiver.
3. Consider node _______ and node_______ as intermediate nodes.
4. Disconnect the link between node _______ and node _______ and observe the
packet transmission.
PROGRAM:
set ns [new Simulator]
$ns rtproto DV
$ns macType Mac/Sat/UnslottedAloha
set nf [open aloha.nam w]
25
26
$ns namtrace-all $nf
set f0 [open aloha.tr w]
$ns trace-all $f0
proc finish {} {
global ns f0 nf
$ns flush-trace
close $f0
close $nf
exec nam aloha.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]
set n6 [$ns node]
set n7 [$ns node]
set n8 [$ns node]
set n9 [$ns node]
$n5 shape box
$n1 label "Sender"
$n7 label "Sender"
$n2 label "Receiver"
$n8 label "Receiver"
$n3 label "Intermediate"
$n9 label "Intermediate"
$ns duplex-link $n0 $n1 1Mb 50ms DropTail
$ns duplex-link $n1 $n2 1Mb 50ms DropTail
$ns duplex-link $n2 $n3 1Mb 50ms DropTail
$ns duplex-link $n3 $n4 1Mb 50ms DropTail
$ns duplex-link $n4 $n0 1Mb 50ms DropTail
$ns duplex-link $n3 $n9 1Mb 50ms DropTail
$ns duplex-link $n6 $n5 1Mb 50ms DropTail
$ns duplex-link $n7 $n5 1Mb 50ms DropTail
27
OUTPUT:
28
$ns duplex-link $n8 $n5 1Mb 50ms DropTail
$ns duplex-link $n9 $n5 1Mb 50ms DropTail
$ns duplex-link-op $n3 $n9 queuePos 0.5
set udp0 [new Agent/UDP]
$ns attach-agent $n1 $udp0
set tcp0 [new Agent/TCP]
$ns attach-agent $n7 $tcp0
set null0 [new Agent/Null]
$ns attach-agent $n8 $null0
$ns connect $udp0 $null0
set sink0 [new Agent/TCPSink]
$ns attach-agent $n2 $sink0
$ns connect $tcp0 $sink0
set cbr0 [new Application/Traffic/CBR]
$cbr0 attach-agent $udp0
set ftp0 [new Application/FTP]
$ftp0 attach-agent $tcp0
$ns at 0.5 "$cbr0 start"
$ns at 0.7 "$ftp0 start"
$ns rtmodel-at 1.0 down $n3 $n2
$ns rtmodel-at 2.0 up $n3 $n2
$ns at 4.0 "$cbr0 stop"
$ns at 4.5 "$ftp0 stop"
$ns at 5.0 "finish"
$ns run
POINTS
PERFORMANCE INDICATOR
(1 - 4)
C1 – Preparation
C2 – Observation/Measurements
C3 – Results
C4 – Interpretation
C5 – Viva voce
TOTAL (20 Points)
RESULT:
Thus the High Level Data Link Control protocol was simulated using NS2 and the
packet transmission was observed between the nodes.
29
30
EX.NO : 05 IP ADDRESS CONFIGURATION AND EXECUTION OF IP
DATE : COMMANDS
AIM:
i) To configure the ipv4 address of a host computer and connect it in a Local Area Network.
ii)To execute the ip commands such as ping, trace route and nslookup.
SOFTWARE REQUIREMENT:
i) IP ADDRESS CONFIGURATION
PROCEDURE:
On the host computer
On the host computer the following steps are used to share the internet connection
1. Log on to the host computer as Administrator or as Owner.
2. Click Start, and then click Control Panel.
3. Click Network and Internet Connections.
4. Click Network Connections.
5. Right-click the connection that you use to connect to the Internet. For example, if you
connect to the Internet by using a modem, right-click the connection that you want under Dial-
up/ other network available.
6. Click Properties.
7. Click the Advanced tab.
8. Under Internet Connection Sharing, select the Allow other network users to connect
through this computer's Internet connection check box.
9. If you are sharing a dial-up Internet connection, select the Establish a dial-up connection
whenever a computer on my network attempts to access the Internet check box if you want
to permit your computer to automatically connect to the Internet.
10. Click OK. You receive the following message:
“When Internet Connection Sharing is enabled, your LAN adapter will be set to use IP address
192.168.0. 1. Your computer may lose connectivity with other computers on your network. If
these other computers have static IP addresses, it is a good idea to set them to obtain their IP
addresses automatically. Are you sure you want to enable Internet Connection Sharing?”
31
Output:
Ping:
Nslookup:
32
5. Right-click Local Area Connection and then click Properties.
6. Click the General tab, click Internet Protocol (TCP/IP) in the connection uses the
following items list, and then click Properties.
7. In the Internet Protocol (TCP/IP) Properties dialog box, click Obtain an IP address
automatically (if it is not already selected), and then click OK.
Note: You can also assign a unique static IP address in the range of 192.168.0.2 to 254. For
example, you can assign the following static IP address, subnet mask, and default gateway,
IP Address 192.168.31.202
Subnet mask 255.255.255.0
Default gateway 192.168.31.1
THEORY:
Ping-This command is used for checking the network connectivity. Ping verifies IP-
level connectivity to another TCP/IP device by sending Internet Control Message Protocol
(ICMP) Echo Request messages. If received, the corresponding Echo Reply messages are
displayed, along with round-trip times. Otherwise, a timed-out request or an ICMP unreachable
message is displayed. The first command that every computer user runs on the command line
when having connectivity problems is the “ping” command. Ping is useful for testing
connectivity for both the local computer from where the command is executed and also for a
remote computer or server which is to be reached. For example if we try to “ping” our local
default gateway IP address we get replies back (icmp echo replies), this means our local
computer is properly connected to the network. If we ping a remote server on the internet and
get replies back, it means that the remote server is properly connected to its network as well.
ping [IP Address] : By default it will send 4 ICMP packets to the stated IP address.
ping [hostname or domain] : When “pinging” a hostname or domain name, the command will
resolve first the name to IP address and then send the icmp packets to that IP.
nslookup- The nslookup command can be used in windows and unix to find various details
relating to the Domain Name System (DNS) like IP addresses of a particular computer.
nslookup comes with a number of subcommands to help us to get more information from the
specific dns servers. This command displays information from Domain Name System (DNS)
servers. If you write the command as above it shows as default your pc's server name firstly.
“nslookup” stands for “Name System Lookup” and is very useful in obtaining Domain Name
System (DNS) related information about a domain or about an IP address (reverse DNS
lookup).
nslookup [domain name]: The most popular usage of this command is to obtain the IP
address of a specified domain name.
33
Trace route:
34
traceroute- traceroute shows the route of a packet. A traceroute is a function which traces the
path from one network to another. It allows us to diagnose the source of many problems.
“tracert” in windows stands for “Trace Route”. In linux, the same command is “traceroute”. The
command traces the path that a TCP/IP packet takes towards a destination target and shows
some information (if available) of the routing nodes within this path. “tracert” sends ICMP echo
packets to the destination with varying Time-to-Live (TTL) values.
tracert [domain or IP] : Traces the TCP/IP path to the specified destination target IP or
domain.
POINTS
PERFORMANCE INDICATOR
(1 - 4)
C1 – Preparation
C2 – Observation/Measurements
C3 – Results
C4 – Interpretation
C5 – Viva voce
TOTAL (20 Points)
RESULT:
Thus the IP address was configured on the server and client computers and the internet
connectivity is shared between the devices connected in a LAN. And also the IP commands
ping, trace route and nslookup were executed in command prompt.
35
Flow Chart::
36
EX.NO : 06
DISTANCE VECTOR ROUTING ALGORITHM
DATE :
AIM:
To construct a network with the given number of nodes and implement distance vector
routing algorithm by maintaining routing tables with changing traffic and topology of the
network.
SOFTWARE REDUIRED:
• NS-2
THEORY:
Routing algorithm is a part of network layer software responsible for deciding the best
link for the packets to be transmitted. In routing the pathway with lowest cost is decided.
Distance Vector Routing (DVR) algorithm is a lowest cost path algorithm. Each router
periodically shares its knowledge to its neighbors which contains a list of networks or nodes it
can reach and the distance to nodes. This information is used to update the routing table. The
protocol that implements distance vector routing is called Routing Information Protocol (RIP).
The cost is calculated based on the hop count. Distance-vector routing protocols measure the
distance by the number of routers a packet a passes, one router is counted as one hop distance.
ALGORITHM:
PROGRAM:
37
OUTPUT:
38
for { set i 0 } { $i < 12} { incr i 1 } {
set n($i) [$ns node]}
$ns rtproto DV
$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)
39
40
POINTS
PERFORMANCE INDICATOR
(1 - 4)
C1 – Preparation
C2 – Observation/Measurements
C3 – Results
C4 – Interpretation
C5 – Viva voce
TOTAL (20 Points)
RESULT:
Thus the distance vector routing algorithm were performed using network simulator-2
and its performance was studied.
41
Flow Chart::
42
EX.NO : 07
LINK STATE ROUTING ALGORITHM
DATE :
AIM:
To construct a network with the given number of nodes and implement link state routing
algorithm by maintaining routing tables with changing traffic and topology of the network.
SOFTWARE REDUIRED:
• NS-2
THEORY:
Link state routing algorithm defines the characteristic of a link(edge) that represents a
network in the internet. In this algorithm the cost associated with an edge defines the state of
the link. Links with lower cost are preferred to links with higher costs. If the cost of a link is
infinity it indicates the link is broken or does not exist. To create a least-cost tree each node has
a complete map of the network with the state of each link. Link state packet is sent to the
neighboring nodes to identify the presence of the node and the cost of the link. The collection of
states for all links is called link-state database(LSDB). When a node receives an LSP from its
neighbors it compares with a copy it already have. If the newly arrived LSP is older than the
one it has, it discards the LSP. If it is newer or the first one received the node discards the old
LSP and keeps the received one. It then sends a copy of it out of each interface except the one
from which the packet arrived.
ALGORITHM:
PROGRAM:
44
}
$ns rtproto LS
$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)
$ns at 45 "finish"
$ns run
45
46
POINTS
PERFORMANCE INDICATOR
(1 - 4)
C1 – Preparation
C2 – Observation/Measurements
C3 – Results
C4 – Interpretation
C5 – Viva voce
TOTAL (20 Points)
RESULT:
Thus the link state routing algorithm were performed using network simulator-2 and its
performance was studied.
47
Flow Chart::
48
EX.NO : 8
TCP CONGESTION CONTROL ALGORITHM
DATE :
AIM:
To create a network and implement congestion control algorithm using NS2.
SOFTWARE REQUIREMENT:
• Network Simulator-2
THEORY:
Congestion control is a mechanism used to avoid the traffic congestion. When too many
packets are present in the subnet the performance of the network will get degraded. This
situation is called congestion. A Network faces the problem of congestion if the users of the
network send data at a rate greater than the capacity of the network. Congestion control refers to
the techniques and mechanisms that can either prevent congestion before it happens or remove
congestion after it has happened in a network. It maintains load below its maximum capacity.
To control the number of segments to transmit, TCP uses a variable called congestion window
(cwnd). The size of the congestion window is controlled by the congestion situation in the
network.
TCP handles congestion based on three algorithms: slow start, congestion avoidance and
fast recovery. In the slow-start algorithm, the size of the congestion window increases
exponentially until it reaches a threshold. In the congestion-avoidance algorithm, the size of the
congestion window increases additively until congestion is detected. The fast-recovery
algorithm is optional in TCP. Like congestion avoidance, this algorithm is also an additive
increase, but it increases the size of the congestion window when a duplicate ACK arrives.
ALGORITHM:
PROGRAM:
set ns [new Simulator]
set nf [open out.nam w]
$ns namtrace-all $nf
proc finish {} {
global ns nf
$ns flush-trace
close $nf
exec nam out.nam &
exit 0
}
set n0 [$ns node]
49
OUTPUT:
50
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
set n5 [$ns node]
set n6 [$ns node]
$n0 label "Sender"
$n1 label "Sender"
$n4 label "Sender"
$n5 label "Sender"
$n3 label "Receiver"
$ns duplex-link $n0 $n2 2Mb 10ms DropTail
$ns duplex-link $n1 $n2 2Mb 10ms DropTail
$ns duplex-link $n2 $n3 2Mb 10ms DropTail
$ns duplex-link $n4 $n6 2Mb 10ms DropTail
$ns duplex-link $n5 $n6 2Mb 10ms DropTail
$ns duplex-link $n6 $n3 2Mb 10ms DropTail
$ns queue-limit $n2 $n3 10
$ns queue-limit $n6 $n3 8
$ns duplex-link-op $n2 $n3 queuePos 0.1
$ns duplex-link-op $n6 $n3 queuePos 0.1
set tcp0 [new Agent/TCP]
$ns attach-agent $n0 $tcp0
set sink0 [new Agent/TCPSink]
$ns attach-agent $n3 $sink0
$ns connect $tcp0 $sink0
set ftp0 [new Application/FTP]
$ftp0 attach-agent $tcp0
set udp0 [new Agent/UDP]
$ns attach-agent $n1 $udp0
set null0 [new Agent/Null]
$ns attach-agent $n3 $null0
$ns connect $udp0 $null0
set cbr0 [new Application/Traffic/CBR]
$cbr0 attach-agent $udp0
set tcp1 [new Agent/TCP]
$ns attach-agent $n4 $tcp1
set sink1 [new Agent/TCPSink]
$ns attach-agent $n3 $sink1
$ns connect $tcp1 $sink1
set ftp1 [new Application/FTP]
$ftp1 attach-agent $tcp1
set udp1 [new Agent/UDP]
$ns attach-agent $n5 $udp1
set null1 [new Agent/Null]
$ns attach-agent $n3 $null1
$ns connect $udp1 $null1
set cbr1 [new Application/Traffic/CBR]
$cbr1 attach-agent $udp1
$ns at 0.5 "$cbr0 start"
$ns at 4.5 "$cbr0 stop"
$ns at 1.0 "$ftp0 start"
$ns at 5.5 "$ftp0 stop"
$ns at 0.5 "$cbr1 start"
51
52
$ns at 4.5 "$cbr1 stop"
$ns at 1.0 "$ftp1 start"
$ns at 5.5 "$ftp1 stop"
$ns at 6.0 "finish"
$ns run
POINTS
PERFORMANCE INDICATOR
(1 - 4)
C1 – Preparation
C2 – Observation/Measurements
C3 – Results
C4 – Interpretation
C5 – Viva voce
TOTAL (20 Points)
RESULT:
Thus the congestion control algorithm was simulated using network simulator-2 and its
performance were observed.
53
Flow Chart::
54
EX.NO : 9
DATA ENCRYPTION AND DECRYPTION ALGORITHMS
DATE :
AIM:
To write a C program for encrypting and decrypting a string using algorithm and execute it.
SOFTWARE REDUIRED:
• C Compiler
THEORY:
Encryption is the process of translating plain text data (plaintext) into another form that appears
to be random and meaningless (cipher text). Decryption is the process of converting cipher text
back to plaintext. To encrypt more amount of data, symmetric encryption is used. A symmetric
key is used during both the encryption and decryption processes. To decrypt a particular piece
of cipher text, the key that was used to encrypt the data must be used. The goal of every
encryption algorithm is to make it as difficult as possible to decrypt the generated cipher text
without using the key. A good encryption algorithm contains longer key, so it is more difficult
to decrypt a piece of cipher text without possessing the key. It is difficult to determine the
quality of an encryption algorithm. Algorithms that look promising sometimes turn out to be
very easy to break, given the proper attack. When selecting an encryption algorithm, it is a good
idea to choose one that has been in use for several years and has successfully resisted all
attacks. Caesar cipher is one of the simplest encryption techniques in which each character in
plain text is replaced by a character some fixed number of positions down to it. For example, if
key is 3 then character is replaced by another character that is 3 positions down to it. Like A
will be replaced by D, C will be replaced by F and so on.
ALGORITHM:
1. Start the program by including the default headers for programming.
2. Declare the plain / cipher text and key integers.
3. Get the string as input.
4. Get input to choose the encryption or decryption operation.
5. Extract the ASCII value of each character of the string.
6. Increment the ASCII value by three for encryption and decrement the ASCII value by
three for decryption using switch case function.
7. Display the encrypted or decrypted string.
8. End the program
PROGRAM:
#include <stdio.h>
int main()
{
int i, x;
char str[100];
1
Encrypted string: WTXJ
2
Decrypted string: ROSE
56
printf("\nPlease choose following options:\n");
printf("1 = Encrypt the string.\n");
printf("2 = Decrypt the string.\n");
scanf("%d", &x);
//using switch case statements
switch(x)
{
case 1:
for(i = 0; (i< 100 && str[i] != '\0'); i++)
str[i] = str[i] + 3; //the key for encryption is 3 that is added to ASCII value
printf("\nEncrypted string: %s\n", str);
break;
case 2:
for(i = 0; (i< 100 && str[i] != '\0'); i++)
str[i] = str[i] - 3; //the key for encryption is 3 that is subtracted to ASCII value
printf("\nDecrypted string: %s\n", str);
break;
default:
printf("\nError\n");
}
return 0;
}
POINTS
PERFORMANCE INDICATOR
(1 - 4)
C1 – Preparation
C2 – Observation/Measurements
C3 – Results
C4 – Interpretation
C5 – Viva voce
TOTAL (20 Points)
RESULT:
Thus a C program for encrypting and decrypting a string using algorithm was written,
executed and verified.
57
58
EX.NO : 10
STOP AND WAIT PROTOCOLS
DATE :
AIM:
To implement stop and wait protocol using LAN Trainer kit.
SYSTEM REQUIREMENT:
S. No Hardware/Software Requirement
1 LAN Trainer kit (NEU) 1
2 NIU card 2
3 Operating system Windows 7, 32 bit
4 Number of PCs 2
5 Jumper cables As required
THEORY:
Stop and wait is the fundamental technique to provide reliable transfer under unreliable
packet delivery system. After transmitting one packet, the sender waits for an acknowledgment
(ACK) from the receiver before transmitting the next one. In this way, the sender can recognize
that the previous packet is transmitted successfully and we could say "stop-n-wait" guarantees
reliable transfer between nodes. To support this feature, the sender keeps a record of each
packet it sends. Also, to avoid confusion caused by delayed or duplicated ACKs, "stop-n-wait"
send each packet with unique sequence numbers and receive that numbers in each ACK. If the
sender doesn't receive ACK for previous sent packet after a certain period of time, the sender
times out and retransmits that packet again. There are two cases when the sender doesn't receive
ACK; One is when the ACK is lost and the other is when the frame itself is not transmitted. To
support this feature, the sender keeps timer per each packet.
Design
Design a network to illustrate reliable data transfer with packet length of 1000 bytes
using stop and wait protocol. Illustrate the performance of the network by changing the time out
values from 1000 ms to 4000 ms in steps of 500ms.
Procedure:
1. Click on the Stop & Wait icon from the desktop on both PCs.
59
Model Tabulation:
Time out value in ms Successfully Tx packets Practical throughput
1000 1 0.01
1500 2 0.02
2000 52 0.52
3000 52 0.52
4000 52 0.52
Model Graph:
60
Setting the configuration menu:
PC1 PC2
Node id 0 Node id 0
Protocol CSMA/CD Protocol CSMA/CD
Baud rate 8Kbps (At both the config Baud Rate 8Kbps (At both the config
menu and NEU) menu and NEU)
Duration 100s Duration 100s
Packet 1000 bytes Packet 1000 bytes
Length Length
Bit Delay 0 (at NEU) Bit Delay 0 (at NEU)
Direction Sender Direction Receiver
4. Click OK button and Download the driver to the NIU using the BOOT button
command. Booting from any one of the applications is enough.
5. Run the experiment by clicking button or by choosing RUN _ Start from each
application.
6. Set the Timeout Value to 1500 ms
61
62
POINTS
PERFORMANCE INDICATOR
(1 - 4)
C1 – Preparation
C2 – Observation/Measurements
C3 – Results
C4 – Interpretation
C5 – Viva voce
TOTAL (20 Points)
RESULT:
Thus the stop and wait protocol was implemented using LAN Trainer kit and throughput
was calculated.
63
64
EX.NO : 11
GO BACK-N AND SELECTIVE REPEAT PROTOCOLS
DATE :
AIM:
To design and simulate a network topology to illustrate Go Back N and Selective Repeat
Protocols using LAN Trainer kit
SYSTEM REQUIREMENT:
S. No Hardware/Software Requirement
1 LAN Trainer kit (NEU) 1
2 NIU card 2
3 Operating system Windows 7, 32 bit
4 Number of PCs 2
5 Jumper cables As required
THEORY:
Go-Back N Protocol:
Selective Repeat ARQ / Selective Reject ARQ is a specific instance of the Automatic
Repeat-request (ARQ) Protocol. The receiver process keeps track of the sequence number of
the earliest frame it has not received, and sends that number with every ACK it sends. If a
frame from the sender does not reach the receiver, the sender continues to send subsequent
frames until it has emptied its window. The receiver continues to fill its receiving window with
the subsequent frames, replying each time with an ACK containing the sequence number of the
earliest missing frame. Once the sender has sent all the frames in its window, it re-sends the
frame number given by the ACKs, and then continues where it left off. The size of the sending
and receiving windows must be equal, and half the maximum sequence number (assuming that
sequence numbers are numbered from 0 to n-1) to avoid miscommunication in case of packets
being dropped.
Design:
Design a network topology to illustrate Go Back N and Selective Repeat Protocols.
Assume the window size and inter packet delay as 4 and 400ms respectively. Run the
simulation for 100 seconds duration and analyze the throughput performance for various time
out values.
65
Model Tabulation:
Go-Back N Protocol
Model Graph:
Go-Back N Protocol
66
Procedure:
Go-Back N Protocol
1. Click on the Sliding Window GBN icon from the desktop on both PCs.
4. Click OK button and Download the driver to the NIU using the BOOT button
command. Booting from any one of the applications is enough.
5. Run the experiment by clicking button or by choosing RUN _ Start from each
application.
6. Set the Timeout Value to 1500 ms
67
68
7. Note down the no of successfully Transmitted Packets.
8. Repeat the above steps for various time out values and plot the graph between timeout
Value &Throughput. Find the optimum timeout value from the plot.
Procedure:
Selective Repeat Protocol
1. Click on the Selective Repeat icon from the desktop on both PCs.
69
70
Setting the configuration menu:
PC1 PC2
Node id 0 Node id 0
Protocol CSMA/CD Protocol CSMA/CD
Baud rate 8Kbps (At both the config Baud Rate 8Kbps (At both the config
menu and NEU) menu and NEU)
Duration 100s Duration 100s
Packet 1000 bytes Packet 1000 bytes
Length Length
Bit Delay 0 (at NEU) Bit Delay 0 (at NEU)
Direction Sender Direction Receiver
No of Packets 4 No of Packets 4
Note: The No of Packets parameter defines the window size.
3. Set the Inter Packet Delay to 400msecs
4. Click OK button and Download the driver to the NIU using the BOOT button
command. Booting from any one of the applications is enough.
5. Run the experiment by clicking button or by choosing RUN _ Start from each
application.
6. Set the Timeout Value to 1000 ms
71
Model Tabulation:
Go-Back N Protocol
Model Graph:
Selective Repeat Protocol
72
7. Note down the no of successfully Transmitted Packets.
8. Repeat the above steps for various time out values and plot the graph between timeout
Value &Throughput. Find the optimum timeout value from the plot.
POINTS
PERFORMANCE INDICATOR
(1 - 4)
C1 – Preparation
C2 – Observation/Measurements
C3 – Results
C4 – Interpretation
C5 – Viva voce
TOTAL (20 Points)
RESULT:
Thus the Go Back N and Selective Repeat Protocols was implemented using LAN
Trainer kit and throughput was calculated.
73