📄 isigen.tcl
字号:
# Copyright (C) 2001 by USC/ISI# All rights reserved. # # Redistribution and use in source and binary forms are permitted# provided that the above copyright notice and this paragraph are# duplicated in all such forms and that any documentation, advertising# materials, and other materials related to such distribution and use# acknowledge that the software was developed by the University of# Southern California, Information Sciences Institute. The name of the# University may not be used to endorse or promote products derived from# this software without specific prior written permission.# # THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.# # An example script that simulates ISI web traffic. ## Some attributes:# 1. Topology: ~1100 nodes, 960 web clients, 40 web servers# 100 ftp clients, 10 ftp servers# 2. Traffic: approximately 1,700,000 packets, heavy-tailed connection # sizes, throughout 3600 second simulation time# 3. Simulation scale: ~33 MB memory, ~1 hrs running on Red Hat Linux 7.0# Pentium II Xeon 450 MHz PC with 1GB physical memory## Created by Kun-chan Lan (kclang@isi.edu)global num_node n verbose num_ftp_client num_nonisi_web_client num_isi_server set verbose 1set enableWEB 1set enableFTP 0source isitopo.tcl# Basic ns setupset ns [new Simulator]$ns rtproto Manualcreate_topology#trace files setup (isi: inbound traffic www: all traffic)$ns trace-queue $n(9) $n(1) [open isi.in w]$ns trace-queue $n(1) $n(9) [open isi.out w]$ns trace-queue $n(9) $n([expr $num_node - 1]) [open www.out w]$ns trace-queue $n([expr $num_node - 1]) $n(9) [open www.in w]set stopTime 3600.1set stopTimeW $stopTimeset stopTimeF $stopTime# Number of Sessionsset numSessionI 3000set numSessionO 1500# Random seed at every runglobal defaultRNG$defaultRNG seed 0if {$enableWEB == 1} {#setup Web model# Create page poolWWWset poolWWW [new PagePool/EmpWebTraf]# Setup web servers and clients$poolWWW set-num-client [llength [$ns set srcW_]]$poolWWW set-num-server [llength [$ns set dstW_]]$poolWWW set-num-remote-client $num_nonisi_web_client$poolWWW set-num-server-lan $num_isi_serverset i 0foreach s [$ns set srcW_] { $poolWWW set-client $i $n($s) incr i}set i 0foreach s [$ns set dstW_] { $poolWWW set-server $i $n($s) incr i}# Inter-session Intervalset WWWinterSessionO [new RandomVariable/Empirical]$WWWinterSessionO loadCDF cdf/2pm.dump.www.out.sess.inter.cdfset WWWinterSessionI [new RandomVariable/Empirical]$WWWinterSessionI loadCDF cdf/2pm.dump.www.in.sess.inter.cdf#set WWWinterSessionO [new RandomVariable/Exponential]#$WWWinterSessionO set avg_ 13.6#set WWWinterSessionI [new RandomVariable/Exponential]#$WWWinterSessionI set avg_ 1.6## Number of Pages per Sessionset WWWsessionSizeO [new RandomVariable/Empirical]$WWWsessionSizeO loadCDF cdf/2pm.dump.www.out.pagecnt.cdfset WWWsessionSizeI [new RandomVariable/Empirical]$WWWsessionSizeI loadCDF cdf/2pm.dump.www.in.pagecnt.cdf# Create sessions$poolWWW set-num-session [expr $numSessionI + $numSessionO]puts "creating WWW outbound session"set interPage [new RandomVariable/Empirical]$interPage loadCDF cdf/2pm.dump.www.out.idle.cdfset pageSize [new RandomVariable/Constant]$pageSize set val_ 1set interObj [new RandomVariable/Empirical]$interObj loadCDF cdf/2pm.dump.www.out.obj.cdf set objSize [new RandomVariable/Empirical]$objSize loadCDF cdf/2pm.dump.www.out.pagesize.cdfset reqSize [new RandomVariable/Empirical]$reqSize loadCDF cdf/2pm.dump.www.out.req.cdfset persistSel [new RandomVariable/Empirical]$persistSel loadCDF cdf/persist.cdfset serverSel [new RandomVariable/Empirical]$serverSel loadCDF cdf/2pm.dump.outbound.server.cdfset windowS [new RandomVariable/Empirical]$windowS loadCDF cdf/2pm.dump.www.outbound.wins.cdfset windowC [new RandomVariable/Empirical]$windowC loadCDF cdf/2pm.dump.www.outbound.winc.cdfset mtu [new RandomVariable/Empirical]$mtu loadCDF cdf/mtu.cdfset launchTime 0for {set i 0} {$i < $numSessionO} {incr i} { if {$launchTime <= $stopTimeW} { set numPage [$WWWsessionSizeO value] puts "Session Outbound $i has $numPage pages $launchTime" $poolWWW create-session $i \ $numPage [expr $launchTime + 0.1] \ $interPage $pageSize $interObj $objSize \ $reqSize $persistSel $serverSel $windowS $windowC $mtu 1 set launchTime [expr $launchTime + [$WWWinterSessionO value]] }}puts "creating WWW inbound session"set interPage [new RandomVariable/Empirical]$interPage loadCDF cdf/2pm.dump.www.in.idle.cdfset pageSize [new RandomVariable/Constant]$pageSize set val_ 1set interObj [new RandomVariable/Empirical]$interObj loadCDF cdf/2pm.dump.www.in.obj.cdf set objSize [new RandomVariable/Empirical]$objSize loadCDF cdf/2pm.dump.www.in.pagesize.cdfset reqSize [new RandomVariable/Empirical]$reqSize loadCDF cdf/2pm.dump.www.in.req.cdfset persistSel [new RandomVariable/Empirical]$persistSel loadCDF cdf/persist.cdfset serverSel [new RandomVariable/Empirical]$serverSel loadCDF cdf/2pm.dump.www.inbound.server.cdfset windowS [new RandomVariable/Empirical]$windowS loadCDF cdf/2pm.dump.www.inbound.wins.cdfset windowC [new RandomVariable/Empirical]$windowC loadCDF cdf/2pm.dump.www.inbound.winc.cdfset mtu [new RandomVariable/Empirical]$mtu loadCDF cdf/mtu.cdfset launchTime 0for {set i 0} {$i < $numSessionI} {incr i} { if {$launchTime <= $stopTimeW} { set numPage [$WWWsessionSizeI value] puts "Session Inbound $i has $numPage pages $launchTime" $poolWWW create-session [expr $i + $numSessionO] \ $numPage [expr $launchTime + 0.1] \ $interPage $pageSize $interObj $objSize \ $reqSize $persistSel $serverSel $windowS $windowC $mtu 0 set launchTime [expr $launchTime + [$WWWinterSessionI value]] }}}if {$enableFTP == 1} {# setup FTP model# Create page poolset poolFTP [new PagePool/EmpFtpTraf]# Setup FTP servers and clients$poolFTP set-num-client [llength [$ns set srcF_]]$poolFTP set-num-server [llength [$ns set dstF_]]$poolFTP set-num-remote-client $num_ftp_client$poolFTP set-num-server-lan $num_isi_serverset i 0foreach s [$ns set srcF_] { $poolFTP set-client $i $n($s) incr i}set i 0foreach s [$ns set dstF_] { $poolFTP set-server $i $n($s) incr i}# Inter-session Intervalset FTPinterSessionO [new RandomVariable/Empirical]$FTPinterSessionO loadCDF cdf/2pm.dump.ftp.outbound.sess.inter.cdfset FTPinterSessionI [new RandomVariable/Empirical]$FTPinterSessionI loadCDF cdf/2pm.dump.ftp.inbound.sess.inter.cdf## Number of File per Sessionset FTPsessionSizeO [new RandomVariable/Empirical]$FTPsessionSizeO loadCDF cdf/2pm.dump.ftp.outbound.fileno.cdfset FTPsessionSizeI [new RandomVariable/Empirical]$FTPsessionSizeI loadCDF cdf/2pm.dump.ftp.inbound.fileno.cdf$poolFTP set-num-session [expr $numSessionI + $numSessionO]puts "creating FTP outbound session"set interFile [new RandomVariable/Empirical]$interFile loadCDF cdf/2pm.dump.ftp.outbound.file.inter.cdfset fileSize [new RandomVariable/Empirical]$fileSize loadCDF cdf/2pm.dump.ftp.outbound.size.cdfset serverSel [new RandomVariable/Empirical]$serverSel loadCDF cdf/2pm.dump.outbound.server.cdfset windowS [new RandomVariable/Empirical]$windowS loadCDF cdf/2pm.dump.ftp.outbound.wins.cdfset windowC [new RandomVariable/Empirical]$windowC loadCDF cdf/2pm.dump.ftp.outbound.winc.cdfset launchTime 0for {set i 0} {$i < $numSessionO} {incr i} { if {$launchTime <= $stopTimeF} { set numFile [$FTPsessionSizeO value] puts "Session Outbound $i has $numFile files $launchTime" $poolFTP create-session $i \ $numFile [expr $launchTime + 0.1] \ $interFile $fileSize $serverSel $windowS $windowC 1 set launchTime [expr $launchTime + [$FTPinterSessionO value]] }}puts "creating FTP inbound session"set interFile [new RandomVariable/Empirical]$interFile loadCDF cdf/2pm.dump.ftp.inbound.file.inter.cdfset fileSize [new RandomVariable/Empirical]$fileSize loadCDF cdf/2pm.dump.ftp.inbound.size.cdfset serverSel [new RandomVariable/Empirical]$serverSel loadCDF cdf/2pm.dump.ftp.inbound.server.cdfset windowS [new RandomVariable/Empirical]$windowS loadCDF cdf/2pm.dump.ftp.inbound.wins.cdfset windowC [new RandomVariable/Empirical]$windowC loadCDF cdf/2pm.dump.ftp.inbound.winc.cdfset launchTime 0for {set i 0} {$i < $numSessionI} {incr i} { if {$launchTime <= $stopTimeF} { set numFile [$FTPsessionSizeI value] puts "Session Inbound $i has $numFile files $launchTime" $poolFTP create-session [expr $i + $numSessionO] \ $numFile [expr $launchTime + 0.1] \ $interFile $fileSize $serverSel $windowS $windowC 0 set launchTime [expr $launchTime + [$FTPinterSessionI value]] }}}## Start the simulation$ns at $stopTime "finish"proc finish {} { global ns gf $ns flush-trace exit 0}puts "ns started"$ns run
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -