





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Computer Networks lab record for cse
Typology: Exercises
1 / 9
This page cannot be seen from the preview
Don't miss anything!
Exp No:9 IMPLEMENTATION FULL DUPLEX CHAT USING TCP
Date-
Aim: To write a program for implementing Full Duplex using TCP.
Algorithm:
Program:
set ns [new Simulator] setnt [open test2.tr w] $ns trace-all $nt setnf [open test2.nam w] $ns namtrace-all $nf $ns color 1 darkmagenta $ns color 2 yellow $ns color 3 blue $ns color 4 green $ns color 5 black settotalNodes 3 for {set i 0} {$i< $totalNodes} {incri} { set node_($i) [$ns node] } set server 0
Exp No:10 SIMULATE THE PACKET TRANSMISSION OVER ETHERNET LAN AND ITS CSMA/CD PROTOCOL
Aim: To simulate the packet transmission over Ethernet LAN and its CSMA/CD protocol using NS2.
Algorithm:
Program: set ns [new Simulator] #define color for data flows $ns color 1 Blue $ns color 2 Red #open tracefiles set tracefile1 [open out.tr w] setwinfile [open winfile w] $ns trace-all $tracefile #open nam file setnamfile [open outter.nam w] $ns namtrace-all $namfile #define the finish procedure
$ns simplex-link-op $n3 $n2 orient left #set queue size of link(n2-n3) to 20 $ns queue-limit $n2 $n3 20 #setup TCP connection settcp [new Agent/TCP/Newreno] $ns attach-agent $n0 $tcp set sink [new Agent/TCPSink/DelAck] $ns attach-agent $n4 $sink $ns connect $tcp $sink $tcp set fid_ 1 $tcp set packet_size_ 552 #set ftp over tcp connection set ftp [new Application/FTP] $ftp attach-agent $tcp #setup a UDP connection setudp [new Agent/UDP] $ns attach-agent $n1 $udp set null [new Agent/Null] $ns attach-agent $n5 $null $ns connect $udp $null $udp set fid_ 2 #setup a CBR over UDP connection setcbr [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
#scheduling the events $ns at 0.1 "$cbr start" $ns at 1.0 "$ftp start" $ns at 124.0 "$ftp stop" $ns at 125.5 "$cbr stop" procplotWindow {tcpSource file} { global ns set time 0. set now [$ns now] setcwnd [$tcpSource set cwnd_] puts $file "$now $cwnd" $ns at [expr $now+$time] "plotWindow $tcpSource $file" } $ns at 0.1 "plotWindow $tcp $winfile" $ns at 125.0 "finish" $ns run