Skip to content

Instantly share code, notes, and snippets.

@eserdinyo
Last active May 20, 2018 09:27
Show Gist options
  • Save eserdinyo/970800bb5a3f11bb6135dc71880c61b4 to your computer and use it in GitHub Desktop.
Save eserdinyo/970800bb5a3f11bb6135dc71880c61b4 to your computer and use it in GitHub Desktop.
A file for Compter Network final exam.
#1 sm adından bir simulator nesnesi oluşturun
set sm [new Simulator]
#2 tüm verileri yaz
set nf [open throughput.tr w]
$sm namtrace-all $nf
#3 50 düğüm oluştur
for {set i 0} {$i < 50} {incr i} {
set n($i) [$sm node]
}
#4 bağlantıları oluştur
for {set i 0} {$i < 50} {incr i} {
$sm duplex-link $n($i) $n([expr $(i + 1)]) 1Mb 10ms SFQ
}
#5 Taşıma katmanında UDP protokolü kullanın
set udp [new Agent/UDP]
$sm attach-agent $n12 $udp
#5 Taşıma katmanında TCP protokolü kullanın
set tcp [new Agent/TCP]
$sm attach-agent $n12 $tcp
#6 Trafik üreteci olarak CBR kullanın. Saniyede 256 byte, 100 veri üretsin
set cbr [new Application/Traffic/CBR]
$cbr attach-agent $udp
$cbr set packetSize_ 256
$cbr set Interval_ 0.01
#6 Trafik üreteci olarak FTP kullanın.
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ftp set packetSize_ 256
$ftp set Interval_ 0.01
#7 12 nolu düğümden 2 nolu düğüme veri trafiği
set null [new Agent/Null]
$sm attach-agent $n2 $null
$sm connect $udp $null
#7 12 nolu düğümden veri trafiği
set sink [new Agent/TCPSink]
$sm attach-agent $n2 $sink
$sm connect $tcp $sink
#8 Oluşturulan trafik 1. saniyede başlayıp 29. saniye sonlansın
$sm at 1.0 "cbr start"
$sm at 29.0 "cbr stop"
#9 Finish prosedürü yazarak simülasyon süresini 30 sn olarak belirleyin
proc finish {} {
global sm nf
$sm flush-trace
close $nf
exec nam throughput.tr &
exit 0
}
$sm at 30.0 "finish"
$sm "run"
#10 2 nolu düğümün saniyede almış olduğu paketleri byte olarak thp2 dosyasına yazınız
perl ./througput.pl out.tr 2 1 > thp2
# RIP yonlendirme protokol C++
void mergeRoute(Route *new) {
int i;
for(i=0; i < numRoutes; i++) {
if(new -> Destination == routingTable[i].Destination) {
if(new -> Cost + 1 < routingTable[i].Cost) {
break;
} else if(new ->NextHop == routingTable[i].NextHop) {
break;
}else {
return;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment