0% found this document useful (0 votes)
29 views7 pages

Module 4 - Page-0001

Uploaded by

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

Module 4 - Page-0001

Uploaded by

Deekshitha H S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 7
Module 4 (1): Ex. No: 6 Implement an Ethernet LAN using n nodes and set multiple traffic nodes and plot congestion window for different source /destination. Aim: To implement an Ethernet LAN using n nodes and set multiple traffic nodes and plot congestion window for different source /destination. #Make a NS simulator set ns [new Simulator] set tf [open lab6.tr w] $ns trace-all $tf set nf [open lab6.nam w] $ns namtrace-all $nf # Create the nodes,color and label set n0 [Sns node] $n0 color “magenta” $n0 label “srci" set ni [Sns node] $n1 color "red" set n2 [Sns node] $n2 color” $n2 label “src2" set n3 [Sns node] agenta” $n3 color “blue” $n3 label “dest2” set n4 [$ns node] $n4 shape square set n5 [$ns node] $n5 color "blue" $n5 label "dest1" #Creates a lan from a set of nodes given by . Bandwidth, delay #characteristics along with the link-layer, Interface queue, Mac layer and #channel type for the lan also needs to be defined. $ns make-lan "$n0 $n1 $n2 $n3 $n4" 50Mb 100ms LL Queue/DropTail Mac/802_3 # Create the link $ns duplex-link $n4 $n5 1Mb 1ms DropTail # Create the node position $ns duplex-link-op $n4 $n5 orient right # Adda TCP sending module to node no set tep0 [new Agent/TCP] $ns attach-agent $n0 $tcp0 # Setup a FTP traffic generator on "tcp0" set ftp0 [new Application /FTP] $ftp0 attach-agent $tcp0 $ftpO set packetSize_ 500 $ftpO set interval_0,0001 # Adda TCP receiving module to node nS. set sink0 [new Agent/TCPSink] $ns attach-agent $n5 $sink0 # Direct traffic from "tcp0" to "sink" $ns connect $tcp0 $sinkO # Adda TCP sending module to node n2 set tep1 [new Agent/TCP] $ns attach-agent $n2 $tep1 # Setup aFTP traffic generator on "tep1" set ftp1 [new Application /FTP] $ftp1 attach-agent $tcp1 $ftp1 set packetSize_600 $ftp1 set interval_0.001 # Adda TCP receiving module to node n3 set sink1 [new Agent/TCPSink] $ns attach-agent $n3 $sink1 # Direct traffic from “tcp1" to "sink1" $ns connect $tep1 $sink1 set file1 [open file1.tr w] $tcp0 attach $file set file2 [open file2.tr w] $tcp1 attach $filez $tep0 trace ewnd_ $tep1 trace ewnd_ # Define a ‘finish’ procedure proc finish {} { global ns nf tf $ns flush-trace close $tf close $nf exec nam lab6.nam & exit 0 } # Schedule start/stop times $ns at 0.1 "$ftp0 start” $ns at 5 "Sftp0 stop" $ns at 7 "SftpO start" $ns at 0.2 "$ftp1 start” $ns at 8 "Sftp1 stop" $ns at 14 "$ftpO stop" $ns at 10 “$ftp1 start" $ns at 15 "$ftp1 stop” # Set simulation end time $ns at 16 “finish” $ns run AWK: BEGIN { printf("%f\t%f\t\n",$1,$7); } END { } Topology: Output: xgraph Module 4 (2): Ex. No: 7 Write a Java program for congestion control using leaky bucket algorithm Aim: To write a program for congestion control using Leaky bucket algorithm. Algorithm: Set the bucket size or the buffer size. Set the output rate. Transmit the packets such that there is no overflow. Repeat the process of transmission until all packets are transmitted. (Reject packets where its size is greater than the bucket size) BENS //Java Implementation of Leaky bucket import javaio.*; import java.util.*; class Leakybucket { public static void main(String] args) { int no_of_queries, storage, output_pkt_size; intinput_pkt_size, bucket size, size_left; // initial packets in the bucket storage = 0; // total no. of times bucket content is checked no_of queries // total no. of packets that can ‘{/ be accommodated in the bucket bucket_size = 10; {/ no. of packets that enters the bucket at a time input_pkt_size = 4; I no. of packets that exits the bucket at a time output_pkt_size = 1; for (int i= 0;i

You might also like