Upload
niranjan-nair-rl
View
235
Download
0
Embed Size (px)
Citation preview
8/18/2019 Computer Networks lab maual
1/35
A
C
collision
B
Exp No:1
Date:
SIMULATION OF CSMA/CD
Aim:
To simulate the CSMA/CD protocol using ViRtSim software and study its characteristics.
Theory:
Carrier sense multiple access is a network access method used on shared network topologies
such as thernet to control access to the network. De!ices attached to the network ca"le
listen#carrier sense$ "efore transmitting. %f the channel is in use& de!ices wait "efore transmitting.
All de!ices ha!e e'ual access to use the network when it is clear.
Collusion detection defines what happens when two de!ices sense a clear channel& then
attempt to transmit at the same time. A collision occurs and "oth de!ices stop transmission& wait
for a random amount of time and then retransmit. This is the techni'ue used to access the ()*.+
thernet network channel. This method handles collision as they occur& "ut if the "us is
constantly "usy& collision can occur so often that the performance drops drastically.
data to B data to
8/18/2019 Computer Networks lab maual
2/35
OUTPUT:
8/18/2019 Computer Networks lab maual
3/35
8/18/2019 Computer Networks lab maual
4/35
8/18/2019 Computer Networks lab maual
5/35
A
C
B
A
C
B
Coi!io" i" a "et#or$
Data to B
A%ter !pe&i%ied i"ter'a
data to C
8/18/2019 Computer Networks lab maual
6/35
A(orithm:
• Declare two frame !aria"les and assign them the data frames to "e transmitted.
• %nitiali,e the CSMA/CD function.
• Send data from node a to node " and sense multiple access.
• Send data from node " to node c and sense multiple access.• Check if collision occurs.
• %f collision occurs wait for -)))ms and then retransmit the two data from the nodes one
after the other.
• Stop the eecution.
Pro&ed)re:
• select programViRtsimsimulation CSMA CSMA/CD
• nter the program& sa!e and run it
*e!)t:
Thus the CSMA/CD protocol was simulated using ViRtsim software and its
characteristics was studied
Exp No: +
8/18/2019 Computer Networks lab maual
7/35
A
C
B
Date:
SIMUATION OF CSMA/CA
Aim:
To simulate the CSMA/CA protocol using ViRtSim software .
Theory:
Carrier sense multiple access is a network access method used on shared network
topologies such as thernet to control access to the network .de!ices attached to the network
ca"le listen#carrier sense$ "efore transmitting. %f the channel is in use& de!ice wait "efore
transmitting. Multiple access indicates that many de!ice can connect to and share the same
network. All de!ices ha!e e'ual access to use the network when it is clear.
Collision a!oidance defines what happens when two de!ices sense a clear channel& then
attempt to transmit the same time .a collision occurs and "oth de!ices stop transmission& wait for
a random amount of time and retransmit. This is techni'ue used to access the ()*.+ thernet
network channel .This method handles collision as they occur& "ut if the "us is constantly "usy&
collision can occur so often that the performance drops drastically.
RT
*e,)e!t to !e"d -*TS. !e"t to A
8/18/2019 Computer Networks lab maual
8/35
O)tp)t :
8/18/2019 Computer Networks lab maual
9/35
A
C
B
A
C
B
A
C
B
CT
Cear to !e"d -CTS. !e"t to A
data
Data tra"!mitted to B
AC
A&$"o#ed(e -AC. !e"t to A
8/18/2019 Computer Networks lab maual
10/35
A(orithm:
• Declare a frame !aria"le and assign them the data frame to "e transmitted.
• %nitiali,e the CSMA/CA function.
• 0odes keep listening to the channel.
• Send re'uest to send frame from node a to node ".• Send clear to send frame from node " to node a.
• Send data from node a to node " and sense multiple access.
• Send acknowledge frame from node " to node a.
• Stop the eecution.
Pro&ed)re:
• select programViRtsimsimulation CSMA CSMA/CA
• nter the program& sa!e and run it
*e!)t
Thus the CSMA/CA protocol was simulated using ViRtSim software.
1utput2
8/18/2019 Computer Networks lab maual
11/35
Exp No: 0
Date:
8/18/2019 Computer Networks lab maual
12/35
IMPLEMENTATION OF DISTANCE ECTO* *OUTIN2
Aim:
To implement and test the distance !ector routing using ViRtSim.
Theory:
%n distance !ector router shares its knowledge a"out the entire network with information
from its neigh"ors in a step procedure. 1nce this is complete it will ha!e a complete idea a"out
the network. The ta"le consists of network %D& cost and net hop. The cost refers to the num"er
of hop count #least$ to reach a particular destination. Routers using distance3!ector algorithms
send all or part of their routing ta"le entries to ad4acent routers on a periodic "asis. This happens
e!en if there are no changes in the network. 5y recei!ing a routing update& a router can !erify all
the know routes and make changes to its routing ta"le. This process is also known as 6routing "y
rumor7.
Pro&ed)re:
• 1pen ViRtSim and select simulationdistance !ector routing.
• Design the re'uired network "y including the routers& links and corresponding weights on
the links
• Select the sender and destination node and click the 6find path7.• Click the 6calculate7 "utton which displays all the route details and shows the shortest
route.
*e!)t:
Thus the distance !ector routing algorithm was implemented and simulated using
ViRtSim software.
8/18/2019 Computer Networks lab maual
13/35
O)tp)t:
Exp No:3
Date:
8/18/2019 Computer Networks lab maual
14/35
IMPLEMENTATION OF LIN STATE *OUTIN2
Aim:
To implement and test the link state routing using ViRtSim.
Theory:
%n link state routing e!ery router shows its knowledge a"out its neigh"or to the entire
network and ultimately all routers will ha!e a routing ta"le within the link state data"ase. 8ink3
state routing protocols respond 'uickly to network changes sending trigger updates only when a
network change has occurred. 8ink3state routing protocols send periodic updates& known as link3
state refreshes& at longer time inter!als& such ad!ertisement #8SA$ is concerning that link. The
8SA is then transmitted to all neigh"oring de!ices. ach routing de!ice takes a copy of the 8SA&
updates its link3state data"ase& and forwards the 8SA to all neigh"oring de!ices. This flooding of
8SAs is re'uired to ensure that all routing de!ices create data"ase that accurately reflect the
network topology "efore updating their routing ta"les
Pro&ed)re2
• 1pen ViRtSim and select simulation 8ink state routing.
• Design the re'uired network "y including the routers and links.
• Select the sender and destination node and click the 6find path9.
Click the 6calculate7 "utton which displays all the route details and shows the shortest
route
*e!)t:
Thus the link state routing algorithm was implemented and simulated using ViRtSim
software.
8/18/2019 Computer Networks lab maual
15/35
Ex No:4
Date:
FILE ENC*5PTION AND DEC*5PTION USIN2 PC TO PC COMMUNICATION
Aim:
To encrypt and decrypt file using pc to pc communication.
Theory:
%t is unlikely that system can completely present unauthori,ed access to transmission media. The
media used today is called encryption& means that the sender transform the original information
to another form and send resulting unintelligence message o!er the network. Decryption re!erses
"ack the original message. The sender uses an encryption algorithm and a key to transform plain
tet into cipher tet.
Pro&ed)re:
Step -2 1pen Vi3Rt sim and choose :C T1 :C 3;
8/18/2019 Computer Networks lab maual
16/35
Ex No:6
Date:
SIMULATION OF *IN2 TOPOLO25 USIN2 LAN T*AINE* IT
Aim:
To simulate the ring topology using 8A0 trainer kit and study its characteristics.
Theory:
%n ring topology& each de!ice has a dedicated point to point line configuration with the
two de!ices on either side of it. A signal is passed along the ring in one direction from de!ice tode!ice until it reaches its destination. ach de!ice in the ring incorporates a repeater. ?hen a
de!ice recei!es a signal intended for another de!ice its repeater regenerates the "it and passes
them along unidirectional traffic.
I LAN T*AINE* IT 7 *IN2 TOPOLO25
Pro&ed)re:
8/18/2019 Computer Networks lab maual
17/35
Step -2 Switch on the 8A0 trainer kit and gi!e connections as shown in the "lock diagram. The
0%C - is placed in programming mode.
Step *2 select ViRtSim in the :C and then the utilities.
Step +2 select ARM downloader and click read de!ice %D.
Step =2 reset the 0%C - and then the de!ice %D will "e read successfully.
Step >2 to load the ARM processor& select the respecti!e he "it file and click load flash.
Step @2 to load the
8/18/2019 Computer Networks lab maual
18/35
*e!)t:
Thus ring topology was implemented and simulated using V%38A0 trainer kit and ViRtSim
software.
8/18/2019 Computer Networks lab maual
19/35
Ex No: 7
Date:
SIMULATION OF BUS TOPOLO25 USIN2 LAN T*AINE* IT
Aim:
To simulate the "us topology using 8A0 trainer kit and study its characteristics.
Theory:
The "us topology connects each station on the network into something called the segment
trunk. A "us is usually referred to a ca"le that connects end to end and this is used to transmit thesignals from one end to the other end. At e!ery end a terminator is placed so that it understands
in which direction the data is tra!elling and also terminator is used to a"sor" the signals. %f the
terminator does not a"sor" the signal then the same signal is reflected "ack to the "us confusing
the whole data flow.
I LAN T*AINE* IT7 BUS TOPOLO25
Pro&ed)re:
Step -: Switch on the 8A0 trainer kit and gi!e connections as shown in the "lock diagram. The
0%C - is placed in programming mode.
8/18/2019 Computer Networks lab maual
20/35
Step *2 select ViRtSim in the :C and then the utilities.
Step +2 select ARM downloader and click read de!ice %D.
Step =2 reset the 0%C - and then the de!ice %D will "e read successfully.
Step >2 to load the ARM processor& select the respecti!e he "it file and click load flash.
Step @2 to load the
8/18/2019 Computer Networks lab maual
21/35
*e!)t:
Thus "us topology was implemented and simulated using V%38A0 trainer kit and ViRtSim
software.
Ex No:9
8/18/2019 Computer Networks lab maual
22/35
Date:
SIMULATION OF STA* TOPOLO25 USIN2 LAN T*AINE* IT
Aim:
To simulate the star topology using 8A0 trainer kit and study its characteristics.
Theory:
%n a star topology each de!ice has a dedicated point to point link only to a central
controller& usually called hu". The de!ices are not directly linked to each other. Fnlike a mesh
topology a star topology does not allow direct traffic "etween de!ices. The controller act as an
echange& it sends the data to the controller which then relays the data to the other connected
de!ice. %ts ad!antage includes ro"ustness. %f one link fails only that link is affected and all other link remains acti!e.
I LAN T*AINE* IT STA* TOPOLO25
Pro&ed)re:
Step -2 Switch on the 8A0 trainer kit and gi!e connections as shown in "lock diagram. The 0C%
- is placed in programming mode.
Step *2 Select ViRtSim in the :C and then the utilities.
Step +2 Select ARM downloader and click read de!ice %D.
Step =2 Reset the 0%C - and then the de!ice %D will "e read successfully.
)ode )ode)ode C
)ode (
)&C+ )&C)&C#
8/18/2019 Computer Networks lab maual
23/35
Step >2 To load the ARM processor& select the respecti!e he "it file and click load flash.
Step @2 To load the
8/18/2019 Computer Networks lab maual
24/35
Ex No:;
Date:
IMPLEMENTATION OF STOP AND
8/18/2019 Computer Networks lab maual
25/35
Pro&ed)re:
Step -2 connect the master/ser!er to the computer 0%C port.
Step *2 Select ViRtSim in the :C and then the utilities.
Step +2 Select ARM downloader and click read de!ice %D.
Step =2 Reset the 0%C - then the de!ice %D will "e read successfully.
Step >2 To load the ARM processor& select the respecti!e he "it file and click load flash.
Step @2 To load the
8/18/2019 Computer Networks lab maual
26/35
*e!)t:
Thus the stop and wait protocol was implemented and simulated using V%38A0 trainer kit and
ViRtSim software.
8/18/2019 Computer Networks lab maual
27/35
Ex No:1=
Date:
IMPLEMENTATION OF 2O BAC N P*OTOCOL
Aim:
To implement and test the o "ack G 0 protocol using 8A0 trainer kit and ViRtSim.
Theory:
%n o "ack G 0 protocol if one frame is damaged or lost& all frames send since the lost
frame acknowledged is retransmitted. The recei!er sends an acknowledge frame for a group of
data frames. 1nly one acknowledgement is enough for a group of transmitted data. %n case of lost
data frames the transmitter sends a negati!e acknowledgement with data frame that is damagedor lost. 1nce the sender recei!es a 0AH& it retransmits the data. %f there is a repetition the
recei!er discards one of the data.
Pro&ed)re:
Step -2 Connect the master/ser!er to the computer 0%C port.
Step *2 Select ViRtSim in the :C and then the utilities.
Step +2 Select ARM downloader and click read de!ice %D.
Step =2 Reset the 0%C - and then the de!ice %D will read successfully.
Step >2 To load the ARM processor& select the respecti!e he "it file and click load flash.
Step @2 To load the
8/18/2019 Computer Networks lab maual
28/35
Step --2 connect the :C with the kit and send the data.
Step -*2 ?hile transmitting& enter the error "y pressing the error "utton on the 8A0 kit as
many times as the num"er of frames in data.
Step -+2 A 0A frame will "e transmitted to the sender and transmission will "e stopped.
Step -=2 The transmission is resumed when the data is again send.
Step ->2 1nce data reaches the destination stop the eecution.
*e!)t:
Thus the o "ack 3 0 protocol was implemented and simulated using V%38A0 trainer kit
and ViRtSim software.
Exp No: 11
8/18/2019 Computer Networks lab maual
29/35
Date:
St)dy o% Net#or$!im)ator -NS. a"d Sim)atio" o% Co"(e!tio"
Co"tro A(orithm! )!i"( NS
Aim :
To Study of 0etwork simulator #0S$ and Simulation of Congestion Control Algorithms using 0S.
Theory:
NET
8/18/2019 Computer Networks lab maual
30/35
likelihood of a "uffer o!erflow in a network& the time re'uired for an accurate answer can "eetremely large. Speciali,ed techni'ues such as Icontrol !ariatesI and Iimportance samplingIha!e "een de!eloped to speed simulation.
Exampe! o% "et#or$ !im)ator!
There are many "oth free/open3source and proprietary network simulators. amples of nota"le network simulation software are& ordered after how often they are mentioned in research papers2
-.ns #open source$
*.1:0T #proprietary software$+. 0etSim #proprietary software$
U!e! o% "et#or$ !im)ator!
0etwork simulators ser!e a !ariety of needs. Compared to the cost and time in!ol!ed in settingup an entire test "ed containing multiple networked computers& routers and data links& network simulators are relati!ely fast and inepensi!e. They allow engineers& researchers to test scenariosthat might "e particularly difficult or epensi!e to emulate using real hardware 3 for instance&simulating a scenario with se!eral nodes or eperimenting with a new protocol in the network. 0etwork simulators are particularly useful in allowing researchers to test new networking protocols or changes to eisting protocols in a controlled and reproduci"le en!ironment. Atypical network simulator encompasses a wide range of networking technologies and can helpthe users to "uild comple networks from "asic "uilding "locks such as a !ariety of nodes and
links. ?ith the help of simulators& one can design hierarchical networks using !arious types of nodes like computers& hu"s& "ridges& routers& switches& links& mo"ile units etc.
Various types of ?ide Area 0etwork #?A0$ technologies like TC:& ATM& %: etc. and 8ocal Area 0etwork #8A0$ technologies like thernet& token rings etc.& can all "e simulated with a typicalsimulator and the user can test& analy,e !arious standard results apart from de!ising some no!el protocol or strategy for routing etc. 0etwork simulators are also widely used to simulate "attlefield networks in 0etwork3centric warfare
There are a wide !ariety of network simulators& ranging from the !ery simple to the !erycomple. Minimally& a network simulator must ena"le a user to represent a topology& Specifying
the nodes on the network& the links "etween those nodes and the traffic "etween the nodes. Morecomplicated systems may allow the user to specify e!erything a"out the protocols used to handletraffic in a network. raphical applications allow users to easily !isuali,e the workings of their simulated en!ironment. Tet3"ased applications may pro!ide a less intuiti!e interface& "ut may permit more ad!anced forms of customi,ation.
http://en.wikipedia.org/wiki/Ns_(simulator)http://en.wikipedia.org/wiki/OPNEThttp://en.wikipedia.org/wiki/NetSimhttp://en.wikipedia.org/wiki/Test_bedhttp://en.wikipedia.org/wiki/Computerhttp://en.wikipedia.org/wiki/Computerhttp://en.wikipedia.org/wiki/Router_(computing)http://en.wikipedia.org/wiki/Data_linkhttp://en.wikipedia.org/wiki/Data_linkhttp://en.wikipedia.org/wiki/Emulatehttp://en.wikipedia.org/wiki/Emulatehttp://en.wikipedia.org/wiki/Network_hubhttp://en.wikipedia.org/wiki/Network_hubhttp://en.wikipedia.org/wiki/Network_bridgehttp://en.wikipedia.org/wiki/Network_bridgehttp://en.wikipedia.org/wiki/Wide_Area_Networkhttp://en.wikipedia.org/wiki/Local_Area_Networkhttp://en.wikipedia.org/wiki/Local_Area_Networkhttp://en.wikipedia.org/wiki/Ethernethttp://en.wikipedia.org/wiki/Ethernethttp://en.wikipedia.org/wiki/Token_ringhttp://en.wikipedia.org/wiki/Network-centric_warfarehttp://en.wikipedia.org/wiki/Ns_(simulator)http://en.wikipedia.org/wiki/OPNEThttp://en.wikipedia.org/wiki/NetSimhttp://en.wikipedia.org/wiki/Test_bedhttp://en.wikipedia.org/wiki/Computerhttp://en.wikipedia.org/wiki/Router_(computing)http://en.wikipedia.org/wiki/Data_linkhttp://en.wikipedia.org/wiki/Emulatehttp://en.wikipedia.org/wiki/Network_hubhttp://en.wikipedia.org/wiki/Network_bridgehttp://en.wikipedia.org/wiki/Wide_Area_Networkhttp://en.wikipedia.org/wiki/Local_Area_Networkhttp://en.wikipedia.org/wiki/Local_Area_Networkhttp://en.wikipedia.org/wiki/Ethernethttp://en.wikipedia.org/wiki/Token_ringhttp://en.wikipedia.org/wiki/Network-centric_warfarehttp://en.wikipedia.org/wiki/Network-centric_warfare
8/18/2019 Computer Networks lab maual
31/35
Pa&$et o!!
1ccurs when one or more packets of data tra!elling across a computer networkfail to reachtheir destination. :acket loss is distinguished as one of the three main error types encountered indigital communicationsK the other two "eing "it error and spurious packets caused due to noise.
:ackets can "e lost in a network "ecause they may "e dropped when a 'ueue in the network node
o!erflows. The amount of packet loss during the steady state is another important property of acongestion control scheme. The larger the !alue of packet loss& the more difficult it is for transport layer protocols to maintain high "andwidths& the sensiti!ity to loss of indi!idual packets& as well as to fre'uency and patterns of loss among longer packet se'uences is stronglydependent on the application itself.
Thro)(hp)t
This is the main performance measure characteristic& and most widely used. %n communicationnetworks& such as thernet or packet radio& throughput or network. Throughput is the a!eragerate of successful message deli!ery o!er a communication channel. The throughput is usually
measured in "its per second #"it/s or "ps$& and sometimes in data packets per second or data packets per time slot This measure how soon the recei!er is a"le to get a certain amount of datasend "y the sender. %t is determined as the ratio of the total data recei!ed to the end to end delay.Throughput is an important factor which directly impacts the network performance
Deay
Delay is the time elapsed while a packet tra!els from one point e.g.& source premise or network ingress to destination premise or network degrees. The larger the !alue of delay& the moredifficult it is for transport layer protocols to maintain high"and widths. ?e will calculate end toend delay
>)e)e Le"(th
A 'ueuing system in networks can "e descri"ed as packets arri!ing for ser!ice& waiting for ser!ice if it is not immediate& and if ha!ing waited for ser!ice& lea!ing the system after "eingser!ed. Thus 'ueue length is !ery important characteristic to determine that how well the acti!e'ueue management of the congestion control algorithm has "een working.
*ESULT:
Thus the study of 0etwork simulator #0S*$ was studied.
8/18/2019 Computer Networks lab maual
32/35
Exp No: 1+
Date:
St)dy o% So&$et Pro(rammi"( ? Cie"t Ser'er Mode
Aim:
To implement socket programming date and time display from client to ser!er using TC:Sockets
AL2O*IT@M:
Ser'er
-.Create a ser!er socket and "ind it to port.*.8isten for new connection and when a connection arri!es& accept it.
+.Send ser!er ‟s date and time to the client.
=.Read client‟s %: address sent "y the client.
>.Display the client details.
@.Repeat steps *3> until the ser!er is terminated.
.Close all streams.
(.Close the ser!er socket.
E.Stop.
Cie"t
-.Create a client socket and connect it to the ser!er ‟s port num"er.
*.Retrie!e its own %: address using "uilt3in function.
+.Send its address to the ser!er.
=.Display the date L time sent "y the ser!er.
>.Close the input and output streams.
@.Close the client socket.
. Stop.
8/18/2019 Computer Networks lab maual
33/35
P*O2*AM:
//TCP Date Ser'er77t&pdate!er'era'a
import 4a!a.io.K
import 4a!a.util.K
class tcpdateser!er
N
pu"lic static !oid main#String argOP$
N
Ser!erSocket ss Q nullK Socket csK :rintStream psK 5ufferedReader disK String inetK try
N
ss Q new Ser!erSocket#====$K System.out.println#I:ress CtrlC to 'uitI$K while#true$
N
cs Q ss.accept#$K
ps Q new :rintStream#cs.get1utputStream#$$K
Date d Q new Date#$
ps.println#d$K
dis Q new 5ufferedReader#new %nputStreamReader#cs.get%nputStream#$$$K inet Q dis.read8ine#$KSystem.out.println#IClient System/%: address is 2I inet$K ps.close#$K dis.close#$K
catch#%1ception e$
N System.out.println#IThe eception is 2I e$K
// TCP Date Cie"t77t&pdate&ie"ta'a
import 4a!a.net.K
import 4a!a.io.K class tcpdateclient
N
pu"lic static !oid main #String argsOP$ N Socket socK 5ufferedReader disK String sdateK:rintStream psK
try N %netAddress ia Q %netAddress.get8ocalost#$K if #args.length QQ )$
soc Q new Socket#%netAddress.get8ocalost#$&====$K
8/18/2019 Computer Networks lab maual
34/35
else soc Q new Socket#%netAddress.get5y0ame#argsO)P$&====$K
dis Q new 5ufferedReader#new %nputStreamReader#soc.get%nputStream#$$$K
sdateQdis.read8ine#$K System.out.println#IThe date/time on ser!er is 2 I sdate$K ps Q new
:rintStream#soc.get1utputStream#$$K
ps.println#ia$K
ps.close#$K catch#%1ception e$
N
System.out.println#IT C:T%10 is 2I e$K
*ESULT:
Thus the program for implementing to display date and time from client to ser!er usingTC: Sockets was eecuted successfully and output !erified using !arious samples.
8/18/2019 Computer Networks lab maual
35/35
OUTPUT :
U 4a!ac tcpdateser!er.4a!a U 4a!a tcpdateser!er :ress CtrlC to 'uit Client System/%: address is 2 localhost.localdomain/-*.).).-Client System/%: address is 2 localhost.localdomain/-*.).).-
4a!ac tcpdateclient.4a!a U 4a!a tcpdateclient The date/time on ser!er is2 ?ed ul )@)2-*2)+ MT *)--
!ery time when a client connects to the ser!er& ser!er ‟s date/time will "ereturned to the client for synchroni,ation.