By converting the speed value from bytes to bits (multiply by 8).
Code:
proc ::nxLib::FormatSpeed {speed {seconds 0}} {
set speed [expr {double($speed) * 8}]
if {$seconds > 0} {set speed [expr {double($speed) / $seconds}]}
foreach decimals {0 2 2} unit {Kb/s Mb/s Gb/s} {
if {abs($speed) < 1024} {break}
set speed [expr {double($speed) / 1024.0}]
}
return [format "%.*f%s" $decimals $speed $unit]
}