ユーザ用ツール

サイト用ツール


powershell:落書き3

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン前のリビジョン
powershell:落書き3 [2024/07/05 02:54] 133.106.51.50powershell:落書き3 [2024/07/05 03:03] (現在) 133.106.51.50
行 46: 行 46:
  
 </code> </code>
 +
 +<code>
 +# PowerShellスクリプト
 +
 +function Test-MTU {
 +    param (
 +        [string]$hostname,
 +        [int]$minMTU,
 +        [int]$maxMTU
 +    )
 +
 +    $logFile = "mtu-result.txt"
 +    Remove-Item $logFile -ErrorAction SilentlyContinue
 +
 +    function Ping-Host {
 +        param (
 +            [string]$host,
 +            [int]$size
 +        )
 +
 +        $pingResult = Test-Connection -ComputerName $host -Count 4 -BufferSize $size -DontFragment -Quiet
 +        return $pingResult
 +    }
 +
 +    function BinarySearch-MTU {
 +        param (
 +            [string]$host,
 +            [int]$low,
 +            [int]$high
 +        )
 +
 +        while ($low -le $high) {
 +            $mid = [math]::Floor(($low + $high) / 2)
 +
 +            if (Ping-Host -host $host -size $mid) {
 +                $low = $mid + 1
 +            } else {
 +                $high = $mid - 1
 +            }
 +        }
 +        return $high
 +    }
 +
 +    # 最適なMTUサイズを探す
 +    $optimalMTU = BinarySearch-MTU -host $hostname -low $minMTU -high $maxMTU
 +    "Optimal MTU size for $hostname is $optimalMTU" | Out-File -FilePath $logFile -Append
 +
 +    # 現在のすべてのインターフェイスのMTUおよびMRU設定を取得
 +    $interfaces = Get-NetIPInterface
 +    foreach ($interface in $interfaces) {
 +        $interfaceInfo = "Interface: $($interface.InterfaceAlias), MTU: $($interface.NlMtu), MRU: $($interface.NlMtu)" # Note: Windows does not expose MRU directly, typically MRU == MTU
 +        $interfaceInfo | Out-File -FilePath $logFile -Append
 +    }
 +}
 +
 +# 設定
 +$hostname = "example.com"
 +$minMTU = 800
 +$maxMTU = 1000
 +
 +# 実行
 +Test-MTU -hostname $hostname -minMTU $minMTU -maxMTU $maxMTU
 +
 +</code>
 +
powershell/落書き3.txt · 最終更新: 2024/07/05 03:03 by 133.106.51.50

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki