Salt * Wet * Bytes

October 17, 2009

Getting the network adapters’ order in Windows

Filed under: AdminScripts, Networking — saltwetfish @ 7:22 am
Tags: , ,

Now, one of the biggest problem for us when deployment new servers is that we want to get everything as automated as possible. One of the most complex to automate is networking configuration. That is, you need to figure out which nic to team and which to set as heartbeat or backup nic, etc. In this, I use nic and network adapter interchangeably.

The most persistent problem is getting a ordered list of network adapters from Windows. Windows itself does not present nics in any order. So your slot 0 (embedded) port 1 could be named as “local area network connection 3″ or called “Broadcom 1GB PCI Ethernet Adapter 4″ and the slot 10 port 2 nic could be named as the first nic. (more…)

May 20, 2008

Network: The relationship between TCPWindowSize and DefaultReceiveWindow

Filed under: Networking — saltwetfish @ 7:22 am
Tags: , ,

We threw this question to our MS premier techie as we were troubleshooting some related issues and I thought his reply would be helpful for some of you out there.

Q1: What’s the relationship between the TCPWindowSize setting and the DefaultReceiveWindow handled by AFD.sys?

TCPWindowSize defines the amount of receive data (in bytes) that can be buffered during a connection at TCP/IP layer. The sending host can send only that amount of data before it must wait for an acknowledgment and window update from the receiving host. Windows will self-tune the TCP window size if it’s not explicitly defined in registry.

DefaultReceiveWindow defines the default receive buffer in Socket layer. By default, it’s 8 KB. Programs based on Socket gets data from that buffer. When a program receives more data than this buffer is configured to hold, all data received up to this count must be transferred to the program before receiving continues. When this happens, an acknowledgement will be sent to the source machine.

For example, if the application wants to read 32KB from the socket, it actually reads it from the buffer for 4 times (32/8 = 4). (more…)

May 13, 2008

Windebug: Server out of domain due to TCP/UDP port maxed

Filed under: Windebug — saltwetfish @ 4:15 am
Tags:

Last 2 weeks we had 2 different business services that faced similar issues. Essentially, their servers would drop off the domain, so when you tried to logon with your domain account, it will complain that the server is not in the domain.

I came to work on this when we had a number of servers from the same service team that had SCOM heartbeat issues. When we tried to logon to have to a look, we found that those servers had dropped out of the domain. (more…)

June 29, 2007

Windows networking script: Set show icon for all NICs

Filed under: AdminScripts — saltwetfish @ 4:07 am
Tags: , ,

In the Internet, there is a number of examples of how to set an individual NIC to show icon in notification area, but you cannot find one if you want to set ALL the NICs by default. This is a required for my work and, hence, modified some of the scripts on the net and using WMI registry class to do the task.

You can download the VBS (please rename doc to vbs) script here

ShowIcon VBS Script

The WriteToLog() is my own function (show you some other days), you can replace it with WScript.echo.

Also note, I stopped indent after some levels so that it does not wrap around too much

‘==========================================
Sub SetShowIconValue
‘==========================================

Const HKLM = &H80000002

Dim ServerName
Dim objReg

Dim CtrlNetworkKeyPath
Dim arrAdapterGUIDs, AdapterGUID
Dim AdapterGUIDConnKeyPath
Dim AdapterNameValue
Dim AdapterNameStringValue
Dim ShowIconDWORDValue

ServerName = “.”

‘Don’t want any errors here to kill the program
On error resume next

Set objReg=GetObject(“winmgmts:{impersonationLevel=impersonate}!\\” & _
ServerName & “\root\default:StdRegProv”)

‘This path is fixed in Windows

CtrlNetworkKeyPath = “SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}”

‘grab all the subkeys, i.e. the Adapter GUIDs

objReg.EnumKey HKLM, CtrlNetworkKeyPath, arrAdapterGUIDs

for each AdapterGUID in arrAdapterGUIDs

if InStr(AdapterGUID, “{“) > 0 then ‘look for keys that looks like a GUID

AdapterGUIDConnKeyPath = CtrlNetworkKeyPath & “\” & AdapterGUID & “\Connection”

AdapterNameStringValue = “”

objReg.GetStringValue

HKLM,AdapterGUIDConnKeyPath,”Name”,AdapterNameStringValue

if AdapterNameStringValue <> “” then

WriteToLog “Looking at registry path: ” & AdapterGUIDConnKeyPath
WriteToLog “Network Name: ” & AdapterNameStringValue

‘Just set all NICs regardless of their status, no harm done

objReg.SetDWORDValue HKLM,AdapterGUIDConnKeyPath,”ShowIcon”,1

if Err.Number = 0 then
WriteToLog “Show Icon value is set to: 1″

else
WriteToLog “Error ” & CStr(Err.Number) & ” while trying to check ShowIcon value, ” & Err.Description
end if

else

WriteToLog “Cannot get name for network adapter GUID:” & AdapterGUIDConnKeyPath

end if

end if

next

On error goto 0

End Sub

June 26, 2007

Scripting Network configurations

Filed under: AdminScripts — saltwetfish @ 6:55 am
Tags: , ,

I have the most difficult task of writing a script that will perform some post-setup configuration on Windows server that should do the following:

  1. Team required NICs and set the speed/duplex accordingly
  2. Set the IP configuration information for the NIC (teamed) on pubic LAN
  3. Set all NICs to “show icon in notification area”
  4. Disable NICs that are not in use
  5. Rename all NICs to based on our standard
  6. Unbind specific NICs from network protocols and services if not needed
  7. Set the binding order of the NICs

So far the results are pretty good, I have managed to get 1, 2, 4 and 5 completed. 3 is easy, just a bit more coding that I wanted. 6 and 7 are proofing to be an impossible task if you are not a C++ or VBS programmer.

The problem with admin scripting of Windows network is that there is no one consistent interface or provider in which you can perform the various actions. You may need to visit the network via WMI, the registry, explorer|control panel, netsh, vendor specific CLIs and even DDK programming, if you need to achieve all of the tasks above.

Anyway, I will post my scripts here as I get each components completed

Blog at WordPress.com.