4 namespace eval excentis {
13 namespace eval ByteBlower {
78 proc FlowLossRate { flowlist args } {
80 set flowexecutelist [ list ]
82 set outputmode "percentage"
84 foreach { item value } $args {
85 set item [
string tolower $item ]
91 # Pass it on to ExecuteScenario.
92 append newArgs "$item $value"
99 foreach flow $flowlist {
100 set flowtoexecute [ list ]
102 foreach {item value} $flow {
106 lappend flowtoexecute "-tx" $txparam
110 # parse rx parameters to exclude non-basic triggers / latency/capture
112 lappend flowtoexecute "-rx" $rxparam
115 error "ByteBlowerHL error: Invalid flow parameter: $item"
119 lappend flowexecutelist $flowtoexecute
122 set result [
eval ExecuteScenario [ list $flowexecutelist ] $newArgs ]
123 if { [string equal $outputmode "percentage"]} {
124 set resulttx 0
set resultrx 0
126 set losspercentage [ list ]
127 foreach flow $result {
129 set index [lsearch $flow "-rx"]
131 foreach {item value} $flow {
137 if {$value != "NA"} {
142 puts stderr "ByteBlowerHL warning: Flow error detected. Loss percentage may be wrong. Error code: $value"
143 set errormessage $value
149 lappend losspercentage [
expr $resulttx != 0 ? (1.0 - (double($resultrx) / $resulttx)) * 100 : 0 ]
150 if { ![ string equal $errormessage "" ]} {
151 lappend losspercentage "-error" $errormessage
153 return $losspercentage
154 }
elseif { [ string equal $outputmode "percentagePerFlow" ]} {
155 set resultList [ list ]
156 foreach flow $result {
158 set resulttx 0
set resultrx 0
160 set losspercentage [ list ]
161 set index [lsearch $flow "-rx"]
163 foreach {item value} $flow {
169 if {$value != "NA"} {
174 puts stderr "ByteBlowerHL warning: Flow error detected. Loss percentage may be wrong. Error code: $value"
175 set errormessage $value
180 lappend losspercentage [
expr $resulttx != 0 ? (1.0 - (double($resultrx) / $resulttx)) * 100 : 0 ]
181 if { ![ string equal $errormessage "" ]} {
182 lappend losspercentage "-error" $errormessage
185 lappend resultList $losspercentage
190 foreach flow $result {
191 set resulttx 0
set resultrx 0
193 foreach {item value} $flow {
197 lappend fresult "-tx" $resulttx
200 if {$value != "NA"} {
202 lappend fresult "-rx" $resultrx
204 lappend fresult "-rx" $value
208 puts stderr "ByteBlowerHL warning: Flow error detected. Loss percentage may be wrong. Error code: $value"
209 lappend fresult "-error" $value
213 lappend numbers $fresult
219 proc x.RxParam.FlowLoss.Parse { rxparamlist } {
231 foreach {item value} $rxparamlist {
238 error "Only 1 trigger allowed per rx port parameter list"
242 # do nothing, latency will be ignored
245 # do nothing, capture will be ignored
248 lappend result $item $value
258 if { $trigger != ""} {
259 set filter ""
set type "basic"
260 foreach {item value} $trigger {
264 if {$type != "basic"} {
265 # if the trigger type is other than basic, the flow will transmit, but not receive
270 set filterFormat $value
277 error "Not a valid trigger parameter: \"$item\""
281 lappend result "-trigger" $trigger
287 proc x.TxResult.FlowLoss.Parse {counter} {
300 return [
lindex $counter 1]
303 proc x.RxResult.FlowLoss.Parse {counter} {
311 return [
lindex $counter 1]