Ignore:
Timestamp:
Jul 17, 2024, 10:48:28 PM (5 months ago)
Author:
chronos
Message:
  • Modified: Service internet speed min and max used as contracted speeds. Real speed will be calculated with bonus speed and further queues calculations.
  • Added: Bonus internet speed service field.
  • Modified: Few PHP 8.3 fixes.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/NetworkConfigRouterOS/Generators/Queue.php

    r929 r970  
    33class SpeedLimit
    44{
    5   var $Min;
    6   var $Max;
    7   var $PacketMark;
     5  public int $Min;
     6  public int $Max;
     7  public ?int $PacketMark;
    88
    99  function __construct(int $Min, int $Max, int $PacketMark = null)
     
    2525class SpeedLimitItem
    2626{
    27   var $Name;
    28   var $Parent;
    29   var $LimitIn;
    30   var $LimitOut;
    31   var $FixedSpeed;
    32   var $SubItems;
     27  public string $Name;
     28  public ?SpeedLimitItem $Parent;
     29  public SpeedLimit $LimitIn;
     30  public SpeedLimit $LimitOut;
     31  public bool $FixedSpeed;
     32  public SpeedLimitItems $SubItems;
    3333
    3434  function __construct(string $Name, SpeedLimitItem $Parent = null)
     
    184184    $UsersMaxSpeedIn = round($Finance->MaxSpeed / $InDivider) * 1000;
    185185    $UsersMaxSpeedOut = round($Finance->MaxSpeed / $OutDivider) * 1000;
    186     $VoipMaxSpeedIn = $TotalMaxSpeedIn - 136;
    187     $VoipMaxSpeedOut = $TotalMaxSpeedOut - 136;
    188     $VoipSpeedIn = 100; //$SpeedReserve;
    189     $VoipSpeedOut = 100; //$SpeedReserve;
    190186    $OutInterface = 'eth1';
    191187    $InInterface = 'ifb0';
     
    206202    $this->LoadSpeedLimits($Main);
    207203
    208     // Slow free internet
     204    // Free internet
    209205    $Free = new SpeedLimitItem('free', $Main);
    210206    $Free->LimitIn = new SpeedLimit($FreeInetSpeed, $FreeInetSpeed, GetMarkByComment('free-in'));
     
    226222      while ($Service = $DbResult4->fetch_assoc())
    227223      {
     224        $MinSpeed = $Service['InternetSpeedMin'];
     225        $MaxSpeed = $Service['InternetSpeedMax'];
     226        if ($Service['InternetSpeedBonus'] > $MaxSpeed) $MaxSpeed = $Service['InternetSpeedBonus'];
     227
    228228        echo('Služba '.$Service['Name'].': ');
    229229        $MemberName = RouterOSIdent($Member['Name'].'-'.$Member['Id'].'-'.$ServiceIndex);
    230         $SpeedIn = round($Service['InternetSpeedMin'] / $InDivider);
    231         $SpeedOut = round($Service['InternetSpeedMin'] / $OutDivider);
    232         $UserMaxSpeedIn = round($Service['InternetSpeedMax'] / $InDivider);
    233         $UserMaxSpeedOut = round($Service['InternetSpeedMax'] / $OutDivider);
     230        $MinReduction = 100;
     231        $SpeedIn = round($MinSpeed / $InDivider / $MinReduction);
     232        $SpeedOut = round($MinSpeed / $OutDivider / $MinReduction);
     233        $UserMaxSpeedIn = round($MaxSpeed / $InDivider);
     234        $UserMaxSpeedOut = round($MaxSpeed / $OutDivider);
    234235
    235236        // Reduce max speed by speed limits
     
    302303    echo($Main->Print());
    303304    $ItemsQueue = $Main->GetCommands();
    304     $Routerboard->ListUpdate($PathQueue, array('name', 'limit-at', 'max-limit', 'parent', 'packet-mark'), $ItemsQueue, array(), true);
     305    //$Routerboard->ListUpdate($PathQueue, array('name', 'limit-at', 'max-limit', 'parent', 'packet-mark'), $ItemsQueue, array(), true);
    305306  }
    306307
     
    415416    while (count($DevicesToCheck) > 0)
    416417    {
    417       //echo('Pass'."\n");
    418418      $NewDevicesToCheck = array();
    419419      foreach ($DevicesToCheck as $DeviceId)
    420420      {
    421         //echo($this->Devices[$DeviceId]['Name'].': ');
    422421        foreach ($this->Devices[$DeviceId]['Interfaces'] as $InterfaceId)
    423422        {
     
    435434              if ($NewMaxSpeed > $Link['MaxRealSpeed'])
    436435                $NewMaxSpeed = $Link['MaxRealSpeed'];
    437               //echo($this->Devices[$Device2Id]['Name'].' '.$Device2Id.', ');
    438436              $this->Devices[$Device2Id]['MaxSpeed'] = $NewMaxSpeed;
    439437              // Set nodes tree relation
    440438              $this->Devices[$Device2Id]['Parent'] = $DeviceId;
    441439              $this->Devices[$DeviceId]['Childs'][] = $Device2Id;
    442               //echo($NewMaxSpeed.", ".count($NewDevicesToCheck).' ');
    443440              $NewDevicesToCheck[] = $Device2Id;
    444441            }
    445442          }
    446443        }
    447         //echo("\n");
    448444      }
    449445      $DevicesToCheck = $NewDevicesToCheck;
     
    515511    $InDivider = 1;
    516512    $OutDivider = 1;
    517     $TotalMaxSpeedIn = round($Finance->RealMaxSpeed / $InDivider) * 1000;
    518     $TotalMaxSpeedOut = round($Finance->RealMaxSpeed / $OutDivider) * 1000;
    519513    $UsersMaxSpeedIn = round($Finance->MaxSpeed / $InDivider) * 1000;
    520514    $UsersMaxSpeedOut = round($Finance->MaxSpeed / $OutDivider) * 1000;
    521     $VoipMaxSpeedIn = $TotalMaxSpeedIn - 136;
    522     $VoipMaxSpeedOut = $TotalMaxSpeedOut - 136;
    523     $VoipSpeedIn = 100; //$SpeedReserve;
    524     $VoipSpeedOut = 100; //$SpeedReserve;
    525     $OutInterface = 'eth1';
    526     $InInterface = 'ifb0';
    527     $InetInterface = $this->System->Config['MainRouter']['InetInterface'];
    528515
    529516    $DbResult = $this->Database->select('Service', '*', '(`ChangeAction` IS NULL) AND (`Id`='.TARIFF_FREE.')');
Note: See TracChangeset for help on using the changeset viewer.