You are on page 1of 2

import java.util.*; import java.util.

*; } set ns [new Simulator] $tcp1 attach $tfile


public class dist_vec System.out.println("state value for public class leakyBucket for(;count!=0;i++) set nf [open prog3.nam w] $tcp1 trace cwnd_
{ router"+i+"is"); { { $ns namtrace-all $nf
public static void main(String for(j=0;j<n;j++) static int min(int x, int y) if(count>cap) set nd [open prog3.tr w] set tcp2 [new Agent/TCP/Reno]
$ns trace-all $nd $ns attach-agent $n2 $tcp2
args[]) { {
$ns color 1 Blue set sink2 [new Agent/TCPSink]
{ System.out.println("To "+j+" -via if(x<y) drop =
$ns color 2 Red $ns attach-agent $n8 $sink2
int dist[ ][ ]; "+via[i][j]+" distance is "+dist[i][j]); return x; count-cap;
$ns connect $tcp2 $sink2
int via[ ][ ]; } else count=cap; proc finish { } { $tcp2 set class_ 2
int dmat[ ][ ]; } return y; } global ns nf nd $tcp2 set packetSize_ 55
int i=0,j=0,k=0,count=0,n; } } $ns flush-trace
Scanner in = new public static void main(String args[ ]) System.out.print(i+1); close $nf set ftp2 [new Application/FTP]
Scanner(System.in); { close $nd $ftp2 attach-agent $tcp2
System.out.println("Enter int inp[ ] = new int[25]; System.out.print("\t\t0"); exec nam prog3.nam & set tfile2 [open cwnd2.tr w]
the number of nodes:"); int mini= exit 0 $tcp2 attach $tfile2
n=in.nextInt(); i,count=0,cap,nsec,drop=0,mini,process; min(count,process); } $tcp2 trace cwnd_
dmat = new int[n][n]; Scanner in =new Scanner(System.in);
dist = new int[n][n]; System.out.println("Enter the bucket System.out.print("\t\t"+mini); set n0 [$ns node] $ns at 0.5 "$ftp1 start"
via = new int[n][n]; size: "); count=count-mini; set n1 [$ns node] $ns at 1.0 "$ftp2 start"
System.out.println("Enter cap = in.nextInt(); set n2 [$ns node] $ns at 5.0 "$ftp2 stop"
the distance of the nodes: "); System.out.println("Enter the operation System.out.print("\t\t"+count); set n3 [$ns node] $ns at 5.0 "$ftp1 stop"
set n4 [$ns node] $ns at 5.5 "finish"
for(i=0;i<n;i++) rate: ");
set n5 [$ns node] $ns run
for(j=0;j<n;j++) process = in.nextInt(); System.out.print("\t\t"+drop);
set n6 [$ns node]
{ System.out.println("Enter the number of System.out.println(); set n7 [$ns node]
seconds: "); set n8 [$ns node]
dmat[i][j]=in.nextInt(); nsec = in.nextInt(); } AWK file:-
for(i=0;i<nsec;i++) } $n7 shape box
dist[i][j]=dmat[i][j]; { } $n7 color Blue BEGIN {
via[i][j]=j; System.out.println("Enter the packet size $n8 shape hexagon }
} entering at"+i+1+"sec"); $n8 color Red {
do inp[i]=in.nextInt(); if($6=="cwnd_") {
{ } $ns duplex-link $n1 $n0 2Mb 10ms DropTail printf("%f\t%f\n",$1,$7);
count=0; System.out.println("Seconds/packet $ns duplex-link $n2 $n0 2Mb 10ms DropTail }
for(i=0;i<n;i++) received/packet sent/packet left/packet $ns duplex-link $n0 $n3 1Mb 20ms DropTail }
for(j=0;j<n;j++) dropped"); $ns make-lan "$n3 $n4 $n5 $n6 $n7 $n8" 512Kb END {
for(k=0;k<n;k++) for(i=0;i<nsec;i++) 40ms LL Queue/DropTail Mac/802_3 }
{ {
$ns duplex-link-op $n1 $n0 orient right-down ns prog3.tcl
if(dist[i][j]>dmat[i][k]+dist[k][j]) count += inp[i];
$ns duplex-link-op $n2 $n0 orient right-up awk –f prog3.awk cwnd.tr > a1
{ if(count>cap)
$ns duplex-link-op $n0 $n3 orient right awk –f prog3.awk cwnd2.tr > a2
{ $ns queue-limit $n0 $n3 20 xgraph a1 a2
dist[i][j]=dmat[i][k]+dist[k][j]; drop = count-cap; vi prog3.tr
count=cap; set tcp1 [new Agent/TCP/Vegas]
via[i][j]=k; } $ns attach-agent $n1 $tcp1
System.out.print(i+1); set sink1 [new Agent/TCPSink]
count++; System.out.print("\t\t"+inp[i]); $ns attach-agent $n7 $sink1
} mini= min(count,process); $ns connect $tcp1 $sink1
} System.out.print("\t\t"+mini); $tcp1 set class_ 1
}while(count!=0); count=count-mini; $tcp1 set packetsize_ 55
for(i=0;i<n;i++) System.out.print("\t\t"+count);
{ System.out.print("\t\t"+drop); set ftp1 [new Application/FTP]
drop=0; $ftp1 attach-agent $tcp1
System.out.println(); set tfile [open cwnd.tr w]

You might also like