Changeset 21431


Ignore:
Timestamp:
2010-05-12T22:54:57+02:00 (7 years ago)
Author:
craigc
Message:

[packages] multiwan: Updated probabilities matrix, added rounding.

Location:
packages/net/multiwan
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • packages/net/multiwan/Makefile

    r21424 r21431  
    99 
    1010PKG_NAME:=multiwan 
    11 PKG_VERSION:=1.0.8 
     11PKG_VERSION:=1.0.11 
    1212PKG_RELEASE:=1 
    1313 
  • packages/net/multiwan/files/usr/bin/multiwan

    r21424 r21431  
    640640local total_weight 
    641641local total_wans 
     642local roundme 
     643local roundlen 
    642644local i 
    643645local x 
    644 local y 
     646local n 
    645647 
    646648echo "## Refreshing Load Balancer ##" 
     
    661663         done 
    662664 
     665iptables -F MultiWanLoadBalancer -t mangle 
     666 
    663667total_weight=0 
    664668total_wans=0 
    665 last_probability=0 
    666 x=0 
    667 y=0  
    668  
    669 iptables -F MultiWanLoadBalancer -t mangle 
    670669 
    671670i=0 
     
    683682done 
    684683 
     684last_probability=0 
     685roundme=0 
     686roundlen=0 
     687x=0 
     688n=0  
     689 
    685690i=0 
    686691while [ $i -lt $wancount ]; do  
     
    695700if [ "$gateway" != "x" -a "$ifname" != "x" -a "$failchk" != "x" -a "$weight" != "disable" ]; then 
    696701nexthop="$nexthop nexthop via $gateway dev $ifname weight $weight" 
    697 y=$last_probability 
    698 last_probability=$(expr $x / $(expr $wancount - $i + 1)) 
    699 rand_probability=$(expr $(expr $(expr $weight \* 100) / $total_weight) + $last_probability + $y) 
     702 
     703n=$(expr $n + $last_probability) 
     704last_probability=$(expr $x / $(expr $total_wans - $i + 1)) 
     705rand_probability=$(expr $(expr $weight \* 1000) / $total_weight) 
     706roundlen=`expr length $rand_probability - 1` 
     707roundme=${rand_probability:$roundlen} 
     708rand_probability=$(echo $rand_probability | sed s/$roundme//) 
     709         
     710        if [ $roundme -ge 5 ]; then 
     711                rand_probability=$(expr $rand_probability + 1) 
     712        fi 
     713 
     714rand_probability=$(expr $rand_probability + $n + $last_probability) 
    700715x=$rand_probability 
    701716 
    702717        if [ $rand_probability -lt 10 ]; then 
    703718                rand_probability="0.0${rand_probability}" 
    704         elif [ $rand_probability -lt 100 -a $i != $total_wans ]; then 
     719        elif [ $rand_probability -lt 100 ]; then 
    705720                rand_probability="0.${rand_probability}" 
    706721        else 
Note: See TracChangeset for help on using the changeset viewer.