Wednesday, October 26, 2011

NTttcp and NetCPS network test tools

From time to time I need to test the network connection between two windows machines and need to get some kind of report. One other thing important when testing is to define some basic parameters for a test scenario e.g. amount of data for transfer, duration of testing etc. In this type of tests, Windows 7 or Windows 2008 network connection information/diagnostics doesn't help me a lot (although Windows Performance could help). I searched through the internet for a small application which doesn't need any installation and can be run on the most windows systems. I liked two tools.
One is NTttcp which is a multithreaded, asynchronous application that sends and receives data between two or more endpoints and reports the network performance for the duration of the transfer. It is essentially a Winsock-based port of the ttcp tool that measures networking performance in terms of bytes transferred per second and CPU cycles per byte. Because it can be difficult to diagnose a system's overall performance without dividing the system into smaller subsystems, NTttcp allows users to narrow the focus of their testing and investigation to just the networking subsystem.
One other tool I found useful and easy to use was NetCPS which is similar to NTttcps but has a simpler report which is ok in most cases.

Here are sample reports from these two tools:

For NTttcp report looks like this:

C:\Program Files (x86)\Microsoft Corporation\NT Testing TCP Tool>NTttcpr -m 1,0,

192.168.13.29 -a 6 -fr

Copyright Version 3.0

Network activity progressing...


Thread Realtime(s) Throughput(KB/s) Throughput(Mbit/s) Avg Bytes per Completion

====== =========== ================ ================== ========================

0 127.312 10542.426 84.339 52066.773

Total Bytes(MEG) Realtime(s) Average Frame Size Total Throughput(Mbit/s)

================ =========== ================== ========================

1342.177280 127.312 1258.575 84.339

Total Buffers Throughput(Buffers/s) Pkts(recv/intr) Intr(count/s) Cycles/Byte

============= ===================== =============== ============= ===========

20480.000 160.865 1 4372.05 63.6

Packets Sent Packets Received Total Retransmits Total Errors Avg. CPU %

============ ================ ================= ============ ==========

581770 1066426 12 0 18.67


For NetCPS report is a bit simpler:

C:\Documents and Settings\divankovic\My Documents\Downloads\NetCPS>netcps -serve
r -m1000
NetCPS 1.0 - Entering server mode. Press ^C to quit
Waiting for new connection...
Client connected from 192.168.0.65Link
---> CPS 6232910.00 KPS: 6086.83 MPS: 5.94
Avrg CPS 5769014.00 KPS: 5633.80 MPS: 5.50
Peek CPS 6642190.00 KPS: 6486.51 MPS: 6.33
Client disconnected. 104857600 Kb transferred in 18.18 seconds.


Here is NTttcp tool and here is NetCPS tools.

Wednesday, September 28, 2011

As a administrator in enterprise environment, there are few basics which I unfortunately tend to forget because I do work most of the time in GUI. When I come to new environment where I need to know the infrastructure - as a client computer in domain, you should run netdom command in order to find out

a. list of domain controllers in domain
b. list of fsmo roles distributed between domain controllers
c. you can even join computers in the domain, manage computer accounts etc.

For example a. - you you should run command:

C:\Users\damirivankovic>netdom query dc
List of domain controllers with accounts in the domain:

HYPERV01
HYPERV02
The command completed successfully.

For example b. - you should run command:
C:\Users\damirivankovic>netdom query fsmo

Schema master HYPERV01.domain.local
Domain naming master HYPERV01.domain.local
PDC HYPERV01.domain.local
RID pool manager HYPERV01.domain.local
Infrastructure master HYPERV01.domain.local
The command completed successfully.

For c. and others - please consult the result of command netdom /?

Thursday, April 28, 2011

Service status check or delayed service start

During the years of administering different versions of Windows - I stumbled upon a problem where one windows/application service couldn't start because there was some prerequsites missing. Usually, one service is dependent on the other - for example: I had several cases where I for some reason need to reset the server and when server starts, some service fails because DB service isn't started yet. In these situations you usually end up in problems where application isn't working and you need to start service manually in order to fix the problem. This is why I find plain batch script very useful and it works for all windows versions. Below I wrote a script for postponing service startup for 5 minutes. Since, windows generaly doesn't have this tool installed - you should download tool sleep.exe from Microsoft web site, wich is part of Windows 2003 Resource Kit. Download resource kit and install it or unpack it and copy sleep.exe to some folder in system path.
Script goes something like:

@echo off
ECHO Delaying application service start for x minutes
sleep.exe 300
NET START "name of the application service"

Now, configure problematic service for a manual start and save this batch script and schedule it for a start at system boot. This will function as a delayed start of the service. This is feature already built into Windows 2008, but it doesn't exist in other windows versions.
To fine-tune a bit more, you should create this batch script and it's shortcut to configure this to start in minimized window so it doesn't obstruct users.

To go a little further, in cases where dependent services exist on the same computer, you should do the service status checking before doing some action of stopping or starting the service. For example - to check if one service is running you should include this in your script:

@echo off
ECHO Checking service status
NET START | FIND "name of the service1" > nul
IF errorlevel 1 GOTO :not_running
IF errorlevel 0 GOTO :is_running

:is_running
NET STOP "name of the service2"

:not_running
sleep.exe 300
NET START "name of the service2"


This script will do the service status checking and if service1 is running it will stop the service2 or if service1 is stopped it will do the delayed start of the service2. I believe you now understand what could you do with this.

Hope this helps. :)

Thursday, February 24, 2011

Windows 2003 time synchronization - to external time source

Although this isn't in my primary focus, time synchronization with external time source is very important. This is especially important for Windows domain environments, but also for larger systems in workgroups. I searched everywhere for this simple information - how to sync clock of the Windows computer(s) in workgroup to some external time source i.e. ntp servers?

I know that this looks simple - but if you really tried to find relevant information for this case, you will usually start at Microsoft Technet or Windows command line (w32tm tool) and eventually end up on user forums browsing through articles or posting questions why this doesn't work. There are several way to do this - one is using Windows Time and Date from control panel (or by doubleclicking on clock on the taskbar). Second way is by changing some setting in registry and using command line and the third way is by using command line. This third way is what I will show you. I find that using command line is best for me - since I can control and validate synchronization process. Benefits of using scripts are:
  • Control the start process
  • Schedule the sync job
  • Log synchronization results in txt file
  • Log synchronization results in Event Viewer (System)
What you will need?

Of course, I assume that you are using Windows 2003 in workgroup environment. You will need Internet connection in order to access time servers and you need to choose the time server you like. Usually, this is NTP server, time server in your country or at least in your time zone. You can search on the internet for available time servers. Last but not the least - if you are connected to some kind of corporate local network with firewall - you need to ensure that UDP port 123 is open for traffic originating from internal network to the internet.

Anyway, since I live in Croatia I will be using one of the local NTP/time servers "zg1.ntp.carnet.hr". Before running sync job, let's check/notice the time difference you have now between your computer clock and correct time showed by one of the time servers in your area. Now, create the batch file with following lines:

w32tm /config /manualpeerlist:zg1.ntp.carnet.hr,0x8 /syncfromflags:MANUAL /reliable:yes
w32tm /config /update
net stop w32time
net start w32time
w32tm /resync /rediscover

You should save this file on your disk and test if this script work for your computer.
After you run this script - you should notice this change i.e. that the time on your computer is now correct.

Hope this helps! :)