⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 4q2p.tcl

📁 This is a simulator written in Tcl to simulate a network node carrying GSM and GPRS traffics with Qo
💻 TCL
字号:
# to test a reverse CP order: BE the lowest CP and EF athe highest CP, and # accordingly map to q number: BE q 0, AF2 q1, AF1 q 2, EF q 3. # Three different policies are defined here: Best Effort (BE),# Assured Forwarding (AF) and Expedited Forwarding (EF).# Each policy has a table of parameters which are:#  cp:  initial code point for the packets in this policy#  qw:  queue weight for WRR and WIRR#  in_min:  minimum dropping threshold in the RED-queues for the in-packets#  in_max:  maximum dropping threshold in the RED-queues for the in-packets#  in_prob: the maximum dropping probability in the RED-queues for the in-packets#  out_min:  minimum dropping threshold in the RED-queues for the out-packets#  out_max:  maximum dropping threshold in the RED-queues for the out-packets#  out_prob: maximum dropping probability in the RED-queues for the out-packets#  qlimit:  maximum number of packets in the queue# Assign initial DS-codepointsset EF(cp) 30set AF1(cp) 20set AF2(cp) 10set BE(cp)  0; # default CP setting in ns for BE service# Assign queue weights for WRR-schedulerset EF(qw) 4set AF1(qw) 3set AF2(qw) 2set BE(qw) 1# Set RED parameters (in packets, except for the probability) # EF, for conversational trafficset EF(in_min) 5.0set EF(in_max) 5.0set EF(in_prob) 0.0001set EF(out_min) 0.0   ;# Drop every packet that is out of profileset EF(out_max) 0.0set EF(out_prob) 1.00set EF(meanPktSize) 200 # AF1, for streaming traffic, 2 virtual queues with different size, but no early-dropping, can tolerate some fluctuationset AF1(in_min) 8.0     set AF1(in_max) 8.0     set AF1(in_prob) 0.005set AF1(out_min) 5.0    set AF1(out_max) 5.0    set AF1(out_prob) 0.10set AF1(meanPktSize) 400# AF2, for interactive trafficset AF2(in_min) 30     ;# ~30% of the queue limitset AF2(in_max) 60     ;# ~60%set AF2(in_prob) 0.05set AF2(out_min) 15    ;# ~15%set AF2(out_max) 60    ;# ~60%set AF2(out_prob) 0.10set AF2(meanPktSize) 1000# BE, for background trafficset BE(in_min) 15     ;# ~15% of the queue limitset BE(in_max) 60     ;# ~60%set BE(in_prob) 0.10set BE(out_min) 15set BE(out_max) 60set BE(out_prob) 0.10set BE(meanPktSize) 1000# DiffServ Core queue (one-way: from a to b)proc confDSCore { a b } {    global ns  q n AF1 AF2 EF BE    #upvar  $qname q    set q($a$b) [[$ns link $a $b] queue]      # The number of physical queues and precedences    $q($a$b) set numQueues_ 4        $q($a$b) setNumPrec 2    $q($a$b) setMREDMode RIO-D; # set all queues to be RIO de-coupled mode    $q($a$b) meanPktSize $EF(meanPktSize) 3    $q($a$b) meanPktSize $AF1(meanPktSize) 2    $q($a$b) meanPktSize $AF2(meanPktSize) 1    $q($a$b) meanPktSize $BE(meanPktSize) 0    # Set scheduler (and queue weigths)    $q($a$b) setSchedularMode WRR      ;# Options: RR, WRR, WIRR, PRI    $q($a$b) addQueueWeights 3 $EF(qw) ;# For WRR and WIRR. Syntax: $q addQueueWeights [queue] [weight]    $q($a$b) addQueueWeights 2 $AF1(qw)    $q($a$b) addQueueWeights 1 $AF2(qw)    $q($a$b) addQueueWeights 0 $BE(qw)    # Configure PHBs    # EF    $q($a$b) addPHBEntry $EF(cp) 3 0 ;    $q($a$b) addPHBEntry [expr $EF(cp)+1] 3 1    $q($a$b) configQ 3 0 $EF(in_min) $EF(in_max) $EF(in_prob)    $q($a$b) configQ 3 1 $EF(out_min) $EF(out_max) $EF(out_prob)        # AF1    $q($a$b) addPHBEntry $AF1(cp) 2 0 ;    $q($a$b) addPHBEntry [expr $AF1(cp)+1] 2 1    $q($a$b) configQ 2 0 $AF1(in_min) $AF1(in_max) $AF1(in_prob)    $q($a$b) configQ 2 1 $AF1(out_min) $AF1(out_max) $AF1(out_prob)        # AF2    $q($a$b) addPHBEntry $AF2(cp) 1 0 ;    $q($a$b) addPHBEntry [expr $AF2(cp)+1] 1 1    $q($a$b) configQ 1 0 $AF2(in_min) $AF2(in_max) $AF2(in_prob)    $q($a$b) configQ 1 1 $AF2(out_min) $AF2(out_max) $AF2(out_prob)    #BE    $q($a$b) addPHBEntry $BE(cp) 0 0 ;    $q($a$b) addPHBEntry [expr $BE(cp)+1] 0 1    $q($a$b) configQ 0 0 $BE(in_min) $BE(in_max) $BE(in_prob)    $q($a$b) configQ 0 1 $BE(out_min) $BE(out_max) $BE(out_prob)        puts "GGSN (DiffServ Core router) PHB Table: "    $q($a$b) printPHBTable    }# Configure DS edge queues for access links, both server- and client-sideproc confDSEdges { src dst cir service_type } {    global ns q BE EF AF1 AF2        # Edge queues : only server->edge router simplex direction link    set q($src$dst) [[$ns link $src [$src neighbors]] queue]	    if { $service_type == "EF" } {	set cp_ $EF(cp)        set in_min_ $EF(in_min)	set in_max_ $EF(in_max)	set in_prob_ $EF(in_prob)	set out_min_ $EF(out_min)	set out_max_ $EF(out_max)	set out_prob_ $EF(out_prob)        set meanPktSize_ $EF(meanPktSize)      } elseif { $service_type == "AF1" } {	set cp_ $AF1(cp)	set in_min_ $AF1(in_min)	set in_max_ $AF1(in_max)	set in_prob_ $AF1(in_prob)	set out_min_ $AF1(out_min)	set out_max_ $AF1(out_max)	set out_prob_ $AF1(out_prob)        set meanPktSize_ $AF1(meanPktSize)     } elseif { $service_type == "AF2" } {	set cp_ $AF2(cp)	set in_min_ $AF2(in_min)	set in_max_ $AF2(in_max)	set in_prob_ $AF2(in_prob)	set out_min_ $AF2(out_min)	set out_max_ $AF2(out_max)	set out_prob_ $AF2(out_prob)        set meanPktSize_ $AF2(meanPktSize)    } elseif { $service_type == "BE" } {	set cp_ $BE(cp)	set in_min_ $BE(in_min)	set in_max_ $BE(in_max)	set in_prob_ $BE(in_prob)	set out_min_ $BE(out_min)	set out_max_ $BE(out_max)	set out_prob_ $BE(out_prob)        set meanPktSize_ $BE(meanPktSize)    }      $q($src$dst) set numQueues_ 1   $q($src$dst) setNumPrec     2   $q($src$dst) meanPktSize    $meanPktSize_   $q($src$dst) addPolicyEntry [$src id] -1 TSW2CM $cp_ $cir    if { $service_type == "BE" } {          $q($src$dst) addPolicerEntry TSW2CM $BE(cp) $BE(cp);   # only 1 precedence for BE	} else {	  $q($src$dst) addPolicerEntry TSW2CM $cp_ [expr $cp_ + 1]	}   $q($src$dst) addPHBEntry $cp_ 0 0   $q($src$dst) addPHBEntry [expr $cp_ + 1] 0 1   $q($src$dst) configQ 0 0 $in_min_ $in_max_ $in_prob_   $q($src$dst) configQ 0 1 $out_min_ $out_max_ $out_prob_      #puts "[$src id]->[$dst id], Service type: $service_type"   #$q($src$dst) printPHBTable   #$q($src$dst) printPolicyTable}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -