如何在不重新启动的情况下强制在Windows(XP和2003 Server)上重新加载TCP / IP设置

时间:2009-06-25 15:20:34

标签: tcp settings

我正在尝试优化TCP / IP设置,例如TCP窗口大小,MSS和MTU。我想通过以下步骤完成此操作:

  1. 调整设置。
  2. 强制重新加载TCP设置
  3. 运行测试并节省吞吐量和延迟。
  4. 冲洗,泡沫,重复。
  5. 我的问题是我不知道如何做第2步。我读过的所有内容都说需要重新启动,但是必须有一种方法强制它,不是吗?

2 个答案:

答案 0 :(得分:1)

虽然您可以右键单击网络图标,然后选择修复

Repair your network connection http://img146.imageshack.us/img146/7096/picture5okk.png

以编程方式访问它的方法是使用“netsh”命令行实用程序:

> netsh interface dump

以下是指向blog which may help的链接。

我在Win 2003 Server上尝试了一些建议的命令,谢谢你,微软,他们显然已经改变了命令语法。

但我确定如果你玩它,你会找到适合你情况的适当命令。

答案 1 :(得分:1)

以下是一些VBScript示例,用于提取您请求的数据(包括MTU,窗口大小等等):

所有常规适配器信息:

On Error Resume Next
Dim strComputer
Dim objWMIService
Dim propValue
Dim objItem
Dim SWBemlocator
Dim UserName
Dim Password
Dim colItems

strComputer = "."
UserName = ""
Password = ""
Set SWBemlocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = SWBemlocator.ConnectServer(strComputer,"root\CIMV2",UserName,Password)
Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapter",,48)
For Each objItem in colItems
    WScript.Echo "AdapterType: " & objItem.AdapterType
    WScript.Echo "AdapterTypeId: " & objItem.AdapterTypeId
    WScript.Echo "AutoSense: " & objItem.AutoSense
    WScript.Echo "Availability: " & objItem.Availability
    WScript.Echo "Caption: " & objItem.Caption
    WScript.Echo "ConfigManagerErrorCode: " & objItem.ConfigManagerErrorCode
    WScript.Echo "ConfigManagerUserConfig: " & objItem.ConfigManagerUserConfig
    WScript.Echo "CreationClassName: " & objItem.CreationClassName
    WScript.Echo "Description: " & objItem.Description
    WScript.Echo "DeviceID: " & objItem.DeviceID
    WScript.Echo "ErrorCleared: " & objItem.ErrorCleared
    WScript.Echo "ErrorDescription: " & objItem.ErrorDescription
    WScript.Echo "GUID: " & objItem.GUID
    WScript.Echo "Index: " & objItem.Index
    WScript.Echo "InstallDate: " & objItem.InstallDate
    WScript.Echo "Installed: " & objItem.Installed
    WScript.Echo "InterfaceIndex: " & objItem.InterfaceIndex
    WScript.Echo "LastErrorCode: " & objItem.LastErrorCode
    WScript.Echo "MACAddress: " & objItem.MACAddress
    WScript.Echo "Manufacturer: " & objItem.Manufacturer
    WScript.Echo "MaxNumberControlled: " & objItem.MaxNumberControlled
    WScript.Echo "MaxSpeed: " & objItem.MaxSpeed
    WScript.Echo "Name: " & objItem.Name
    WScript.Echo "NetConnectionID: " & objItem.NetConnectionID
    WScript.Echo "NetConnectionStatus: " & objItem.NetConnectionStatus
    WScript.Echo "NetEnabled: " & objItem.NetEnabled
    for each propValue in objItem.NetworkAddresses
        WScript.Echo "NetworkAddresses: " & propValue
    next
    WScript.Echo "PermanentAddress: " & objItem.PermanentAddress
    WScript.Echo "PhysicalAdapter: " & objItem.PhysicalAdapter
    WScript.Echo "PNPDeviceID: " & objItem.PNPDeviceID
    for each propValue in objItem.PowerManagementCapabilities
        WScript.Echo "PowerManagementCapabilities: " & propValue
    next
    WScript.Echo "PowerManagementSupported: " & objItem.PowerManagementSupported
    WScript.Echo "ProductName: " & objItem.ProductName
    WScript.Echo "ServiceName: " & objItem.ServiceName
    WScript.Echo "Speed: " & objItem.Speed
    WScript.Echo "Status: " & objItem.Status
    WScript.Echo "StatusInfo: " & objItem.StatusInfo
    WScript.Echo "SystemCreationClassName: " & objItem.SystemCreationClassName
    WScript.Echo "SystemName: " & objItem.SystemName
    WScript.Echo "TimeOfLastReset: " & objItem.TimeOfLastReset
Next

所有特定的适配器配置:

On Error Resume Next
Dim strComputer
Dim objWMIService
Dim propValue
Dim objItem
Dim SWBemlocator
Dim UserName
Dim Password
Dim colItems

strComputer = "."
UserName = ""
Password = ""
Set SWBemlocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = SWBemlocator.ConnectServer(strComputer,"root\CIMV2",UserName,Password)
Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration",,48)
For Each objItem in colItems
    WScript.Echo "ArpAlwaysSourceRoute: " & objItem.ArpAlwaysSourceRoute
    WScript.Echo "ArpUseEtherSNAP: " & objItem.ArpUseEtherSNAP
    WScript.Echo "Caption: " & objItem.Caption
    WScript.Echo "DatabasePath: " & objItem.DatabasePath
    WScript.Echo "DeadGWDetectEnabled: " & objItem.DeadGWDetectEnabled
    for each propValue in objItem.DefaultIPGateway
        WScript.Echo "DefaultIPGateway: " & propValue
    next
    WScript.Echo "DefaultTOS: " & objItem.DefaultTOS
    WScript.Echo "DefaultTTL: " & objItem.DefaultTTL
    WScript.Echo "Description: " & objItem.Description
    WScript.Echo "DHCPEnabled: " & objItem.DHCPEnabled
    WScript.Echo "DHCPLeaseExpires: " & objItem.DHCPLeaseExpires
    WScript.Echo "DHCPLeaseObtained: " & objItem.DHCPLeaseObtained
    WScript.Echo "DHCPServer: " & objItem.DHCPServer
    WScript.Echo "DNSDomain: " & objItem.DNSDomain
    for each propValue in objItem.DNSDomainSuffixSearchOrder
        WScript.Echo "DNSDomainSuffixSearchOrder: " & propValue
    next
    WScript.Echo "DNSEnabledForWINSResolution: " & objItem.DNSEnabledForWINSResolution
    WScript.Echo "DNSHostName: " & objItem.DNSHostName
    for each propValue in objItem.DNSServerSearchOrder
        WScript.Echo "DNSServerSearchOrder: " & propValue
    next
    WScript.Echo "DomainDNSRegistrationEnabled: " & objItem.DomainDNSRegistrationEnabled
    WScript.Echo "ForwardBufferMemory: " & objItem.ForwardBufferMemory
    WScript.Echo "FullDNSRegistrationEnabled: " & objItem.FullDNSRegistrationEnabled
    for each propValue in objItem.GatewayCostMetric
        WScript.Echo "GatewayCostMetric: " & propValue
    next
    WScript.Echo "IGMPLevel: " & objItem.IGMPLevel
    WScript.Echo "Index: " & objItem.Index
    WScript.Echo "InterfaceIndex: " & objItem.InterfaceIndex
    for each propValue in objItem.IPAddress
        WScript.Echo "IPAddress: " & propValue
    next
    WScript.Echo "IPConnectionMetric: " & objItem.IPConnectionMetric
    WScript.Echo "IPEnabled: " & objItem.IPEnabled
    WScript.Echo "IPFilterSecurityEnabled: " & objItem.IPFilterSecurityEnabled
    WScript.Echo "IPPortSecurityEnabled: " & objItem.IPPortSecurityEnabled
    for each propValue in objItem.IPSecPermitIPProtocols
        WScript.Echo "IPSecPermitIPProtocols: " & propValue
    next
    for each propValue in objItem.IPSecPermitTCPPorts
        WScript.Echo "IPSecPermitTCPPorts: " & propValue
    next
    for each propValue in objItem.IPSecPermitUDPPorts
        WScript.Echo "IPSecPermitUDPPorts: " & propValue
    next
    for each propValue in objItem.IPSubnet
        WScript.Echo "IPSubnet: " & propValue
    next
    WScript.Echo "IPUseZeroBroadcast: " & objItem.IPUseZeroBroadcast
    WScript.Echo "IPXAddress: " & objItem.IPXAddress
    WScript.Echo "IPXEnabled: " & objItem.IPXEnabled
    for each propValue in objItem.IPXFrameType
        WScript.Echo "IPXFrameType: " & propValue
    next
    WScript.Echo "IPXMediaType: " & objItem.IPXMediaType
    for each propValue in objItem.IPXNetworkNumber
        WScript.Echo "IPXNetworkNumber: " & propValue
    next
    WScript.Echo "IPXVirtualNetNumber: " & objItem.IPXVirtualNetNumber
    WScript.Echo "KeepAliveInterval: " & objItem.KeepAliveInterval
    WScript.Echo "KeepAliveTime: " & objItem.KeepAliveTime
    WScript.Echo "MACAddress: " & objItem.MACAddress
    WScript.Echo "MTU: " & objItem.MTU
    WScript.Echo "NumForwardPackets: " & objItem.NumForwardPackets
    WScript.Echo "PMTUBHDetectEnabled: " & objItem.PMTUBHDetectEnabled
    WScript.Echo "PMTUDiscoveryEnabled: " & objItem.PMTUDiscoveryEnabled
    WScript.Echo "ServiceName: " & objItem.ServiceName
    WScript.Echo "SettingID: " & objItem.SettingID
    WScript.Echo "TcpipNetbiosOptions: " & objItem.TcpipNetbiosOptions
    WScript.Echo "TcpMaxConnectRetransmissions: " & objItem.TcpMaxConnectRetransmissions
    WScript.Echo "TcpMaxDataRetransmissions: " & objItem.TcpMaxDataRetransmissions
    WScript.Echo "TcpNumConnections: " & objItem.TcpNumConnections
    WScript.Echo "TcpUseRFC1122UrgentPointer: " & objItem.TcpUseRFC1122UrgentPointer
    WScript.Echo "TcpWindowSize: " & objItem.TcpWindowSize
    WScript.Echo "WINSEnableLMHostsLookup: " & objItem.WINSEnableLMHostsLookup
    WScript.Echo "WINSHostLookupFile: " & objItem.WINSHostLookupFile
    WScript.Echo "WINSPrimaryServer: " & objItem.WINSPrimaryServer
    WScript.Echo "WINSScopeID: " & objItem.WINSScopeID
    WScript.Echo "WINSSecondaryServer: " & objItem.WINSSecondaryServer
Next