3.8.Ethernet-throughput interactions
Last updated
Was this helpful?
Last updated
Was this helpful?
Sequence Diagram
Programming
1.iperf UDP server
$p = Start-Process -FilePath "$serverDrive\$serverShareFolder\$iperfdir\iperf.exe" -ArgumentList "-s -u -w 256k"
#echo $p
$id=(get-process iperf).Id
Wait-Process -id $id -timeout ($timeout_iperf +20)
$iperf = Get-Process iperf -ErrorAction SilentlyContinue
if ($iperf) {
taskkill /T /F /PID $id
}
2.iperf UDP client
$_bandwidth=$bandwidth+"M"
$pinfo = New-Object System.Diagnostics.ProcessStartInfo
$pinfo.FileName = "$serverDrive\$serverShareFolder\$iperfdir\iperf.exe"
$pinfo.Arguments="-u -c $clientIP -t $timeout_iperf -i 1 -f 'm' -b $_bandwidth -w 256k"
$pinfo.UseShellExecute = $false
$pinfo.CreateNoWindow = $true
$pinfo.RedirectStandardOutput = $true
$p = New-Object System.Diagnostics.Process
$p.StartInfo = $pinfo
$p.Start() | Out-Null
$p.WaitForExit()
$stdout = $p.StandardOutput.ReadToEnd()
3.iperf TCP server
$p = Start-Process -FilePath "$serverDrive\$serverShareFolder\$iperfdir\iperf.exe" -ArgumentList "-s -w 256k"
$id=(get-process iperf).Id
Wait-Process -id $id -timeout ($timeout_iperf +20)
$iperf = Get-Process iperf -ErrorAction SilentlyContinue
if ($iperf) {
taskkill /T /F /PID $id
}
4.iperf TCP client
$pinfo = New-Object System.Diagnostics.ProcessStartInfo
$pinfo.FileName = "$serverDrive\$serverShareFolder\$iperfdir\iperf.exe"
$pinfo.Arguments="-c $clientIP -t $timeout_iperf -i 1 -f 'm' -w 256k"
$pinfo.UseShellExecute = $false
$pinfo.CreateNoWindow = $true
$pinfo.RedirectStandardOutput = $true
$p = New-Object System.Diagnostics.Process
$p.StartInfo = $pinfo
$p.Start() | Out-Null
$p.WaitForExit()
$stdout = $p.StandardOutput.ReadToEnd()
5.Change NIC speed & duplex mode
Param (
[parameter(mandatory=$False,HelpMessage='threshold for performane test')]
[string]$computer
[parameter(mandatory=$False,HelpMessage='disk type for performane test')]
[string]$speed = "1"
)
#"0" {$duplex = "Auto Detect"}
#"1" {$duplex = "10Mbps \ Half Duplex"}
#"2" {$duplex = "10Mbps \ Full Duplex"}
#"3" {$duplex = "100Mbps \ Half Duplex"}
#"4" {$duplex = "100Mbps \ Full Duplex"}
#"6" {$duplex = "1Gbps \ Full Duplex"}
#$computer = "192.168.31.22"
#$speed = "1"
$HKLM = 2147483650
$reg = [wmiclass]"\\$computer\root\default:StdRegprov"
$keyroot = "SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}"
Get-WmiObject -Class Win32_NetworkAdapterConfiguration -ComputerName $computer -Filter "IPEnabled='$true'" |
foreach {
$data = $_.Caption -split "]"
$suffix = $data[0].Substring(($data[0].length-4),4)
$key = $keyroot + "\$suffix"
$value = "*SpeedDuplex"
$dup = $reg.SetStringValue($HKLM, $key, $value, $speed) ## REG_SZ
$nic = $_.GetRelated("Win32_NetworkAdapter") | select Speed, NetConnectionId
netsh interface set interface $nic.NetConnectionID DISABLED
netsh interface set interface $nic.NetConnectionID ENABLED
}