summaryrefslogtreecommitdiffstats
path: root/private/sdktools/nbsim
diff options
context:
space:
mode:
authorAdam <you@example.com>2020-05-17 05:51:50 +0200
committerAdam <you@example.com>2020-05-17 05:51:50 +0200
commite611b132f9b8abe35b362e5870b74bce94a1e58e (patch)
treea5781d2ec0e085eeca33cf350cf878f2efea6fe5 /private/sdktools/nbsim
downloadNT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.gz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.bz2
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.lz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.xz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.zst
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.zip
Diffstat (limited to 'private/sdktools/nbsim')
-rw-r--r--private/sdktools/nbsim/dialogs.dlg16
-rw-r--r--private/sdktools/nbsim/dialogs.h6
-rw-r--r--private/sdktools/nbsim/dialogs.resbin0 -> 540 bytes
-rw-r--r--private/sdktools/nbsim/makefile6
-rw-r--r--private/sdktools/nbsim/makefile.inc1
-rw-r--r--private/sdktools/nbsim/nbsim.c626
-rw-r--r--private/sdktools/nbsim/nbsim.rc12
-rw-r--r--private/sdktools/nbsim/nbsimp.h120
-rw-r--r--private/sdktools/nbsim/sources43
9 files changed, 830 insertions, 0 deletions
diff --git a/private/sdktools/nbsim/dialogs.dlg b/private/sdktools/nbsim/dialogs.dlg
new file mode 100644
index 000000000..032d7deb2
--- /dev/null
+++ b/private/sdktools/nbsim/dialogs.dlg
@@ -0,0 +1,16 @@
+1 DLGINCLUDE "Dialogs.H"
+
+ID_NBSIM DIALOG 6, 18, 303, 129
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+CAPTION "NetBench Simulator"
+FONT 8, "MS Shell Dlg"
+BEGIN
+ PUSHBUTTON "Start Simulation", ID_START, 190, 4, 72, 14
+ EDITTEXT ID_CLIENT_LOW, 191, 24, 18, 12, ES_AUTOHSCROLL
+ EDITTEXT ID_CLIENT_HIGH, 191, 42, 18, 12, ES_AUTOHSCROLL
+ LTEXT "Initial Client Count", 104, 214, 28, 65, 8
+ LTEXT "Ending Client Count", 105, 214, 46, 67, 8
+ LISTBOX ID_OUTPUT, 2, 4, 181, 111, WS_VSCROLL | WS_TABSTOP
+ LTEXT "No Active Threads", ID_STATUS, 190, 64, 90, 10
+END
diff --git a/private/sdktools/nbsim/dialogs.h b/private/sdktools/nbsim/dialogs.h
new file mode 100644
index 000000000..d668da0be
--- /dev/null
+++ b/private/sdktools/nbsim/dialogs.h
@@ -0,0 +1,6 @@
+#define ID_START 101
+#define ID_CLIENT_LOW 102
+#define ID_CLIENT_HIGH 103
+#define ID_NBSIM 100
+#define ID_OUTPUT 106
+#define ID_STATUS 107
diff --git a/private/sdktools/nbsim/dialogs.res b/private/sdktools/nbsim/dialogs.res
new file mode 100644
index 000000000..01f1813d5
--- /dev/null
+++ b/private/sdktools/nbsim/dialogs.res
Binary files differ
diff --git a/private/sdktools/nbsim/makefile b/private/sdktools/nbsim/makefile
new file mode 100644
index 000000000..6ee4f43fa
--- /dev/null
+++ b/private/sdktools/nbsim/makefile
@@ -0,0 +1,6 @@
+#
+# DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source
+# file to this component. This file merely indirects to the real make file
+# that is shared by all the components of NT OS/2
+#
+!INCLUDE $(NTMAKEENV)\makefile.def
diff --git a/private/sdktools/nbsim/makefile.inc b/private/sdktools/nbsim/makefile.inc
new file mode 100644
index 000000000..8e76f3dfd
--- /dev/null
+++ b/private/sdktools/nbsim/makefile.inc
@@ -0,0 +1 @@
+nbsim.rc: dialogs.dlg
diff --git a/private/sdktools/nbsim/nbsim.c b/private/sdktools/nbsim/nbsim.c
new file mode 100644
index 000000000..dd4de0a8d
--- /dev/null
+++ b/private/sdktools/nbsim/nbsim.c
@@ -0,0 +1,626 @@
+/*++
+
+Copyright (c) 1992 Microsoft Corporation
+
+Module Name:
+
+ nbsim.c
+
+Abstract:
+
+ The NetBench Simulator
+
+Author:
+
+ Mark Lucovsky (markl) 23-May-1995
+
+Revision History:
+
+--*/
+
+#include "nbsimp.h"
+
+int
+WINAPI
+WinMain(
+ HINSTANCE hInstance,
+ HINSTANCE hPrevInstance,
+ LPSTR lpCmdLine,
+ int nShowCmd
+ )
+{
+ InitializeNbSim();
+ exit(0);
+ return 0;
+}
+
+VOID
+InitializeNbSim( VOID )
+{
+
+ ClientLow = 1;
+ ClientHigh = 32;
+
+ DialogBox(
+ GetModuleHandle(NULL),
+ MAKEINTRESOURCE(ID_NBSIM),
+ NULL,
+ NbSimDlgProc
+ );
+}
+
+BOOL
+CALLBACK
+NbSimDlgProc(
+ HWND hDlg,
+ UINT uMsg,
+ WPARAM wParam,
+ LPARAM lParam
+ )
+{
+
+ BOOL ReturnValue;
+
+ ReturnValue = TRUE;
+
+ hwndDlg = hDlg;
+ switch (uMsg) {
+ HANDLE_MSG(hDlg, WM_INITDIALOG, NbSimDlgInit);
+ HANDLE_MSG(hDlg, WM_COMMAND, NbSimDlgCommand);
+
+ default:
+ ReturnValue = FALSE;
+ break;
+ }
+ return ReturnValue;
+}
+
+
+BOOL
+NbSimDlgInit(
+ HWND hwnd,
+ HWND hwndFocus,
+ LPARAM lParam
+ )
+{
+
+ //
+ // Get output window handle
+ //
+
+ hwndOutput = GetDlgItem(hwnd, ID_OUTPUT);
+
+ SetDlgItemInt(hwnd, ID_CLIENT_LOW, ClientLow, FALSE);
+ SetDlgItemInt(hwnd, ID_CLIENT_HIGH, ClientHigh, FALSE);
+ return(TRUE);
+}
+
+void
+NbSimDlgCommand (
+ HWND hwnd,
+ int id,
+ HWND hwndCtl,
+ UINT codeNotify
+ )
+
+{
+ CHAR OutputBuffer[ 512 ];
+ int i;
+ BOOL TranslateLow;
+ BOOL TranslateHigh;
+ UINT ValueLow;
+ UINT ValueHigh;
+
+
+ switch (id) {
+
+ case ID_START:
+ case IDOK:
+
+ SetWindowText(GetDlgItem(hwnd, ID_START),"Stop Simulation");
+
+ ValueLow = GetDlgItemInt(hwnd, ID_CLIENT_LOW, &TranslateLow, FALSE);
+ if ( TranslateLow && (ValueLow >= MIN_CLIENTS && ValueLow <= MAX_CLIENTS-1) ) {
+ ;
+ }
+ else {
+ TranslateLow = FALSE;
+ }
+
+ ValueHigh = GetDlgItemInt(hwnd, ID_CLIENT_HIGH, &TranslateHigh, FALSE);
+ if ( TranslateHigh && (ValueHigh >= MIN_CLIENTS+1 && ValueHigh <= MAX_CLIENTS) ) {
+ ;
+ }
+ else {
+ TranslateHigh = FALSE;
+ }
+
+ if ( TranslateLow && TranslateHigh && ValueLow < ValueHigh ) {
+ ClientLow = ValueLow;
+ ClientHigh = ValueHigh;
+ }
+ else {
+ SetDlgItemInt(hwnd, ID_CLIENT_LOW, ClientLow, FALSE);
+ SetDlgItemInt(hwnd, ID_CLIENT_HIGH, ClientHigh, FALSE);
+ }
+
+ EnableWindow(GetDlgItem(hwnd, ID_CLIENT_LOW),FALSE);
+ EnableWindow(GetDlgItem(hwnd, ID_CLIENT_HIGH),FALSE);
+
+ hMonitorThread = CreateThread(
+ NULL,
+ 0L,
+ (PVOID)MonitorThread,
+ NULL,
+ 0,
+ &dwMonitorId
+ );
+ if ( !MonitorThread ) {
+ MessageBox(hwnd,"Error Creating Monitor Thread","FATAL ERROR",MB_ICONSTOP|MB_OK);
+ exit(1);
+ }
+
+ break;
+
+ case IDCANCEL:
+
+ EndDialog(hwnd, id);
+ break;
+ }
+
+ return;
+}
+
+VOID
+MonitorThread(
+ LPVOID ThreadParameter
+ )
+{
+
+ BOOL b;
+ DWORD dw;
+ DWORD ThreadCount;
+ CHAR Buffer[256];
+
+ dw = GetFileAttributes(".\\nbsim");
+ if ( dw == 0xffffffff ) {
+ b = CreateDirectory(".\\nbsim",NULL);
+ }
+ else {
+ b = dw & FILE_ATTRIBUTE_DIRECTORY ? TRUE : FALSE;
+ }
+ if ( !b ) {
+ MessageBox(hwndDlg,"Error establishing NbSim test directory","FATAL ERROR",MB_ICONSTOP|MB_OK);
+ exit(1);
+ }
+
+ StartEvent = CreateEvent(NULL,TRUE,FALSE,NULL);
+ StopEvent = CreateEvent(NULL,TRUE,FALSE,NULL);
+ SendMessage(hwndOutput, LB_RESETCONTENT, 0L, 0L);
+
+ for(ThreadCount = 0; ThreadCount < MAX_CLIENTS; ThreadCount++ ) {
+
+ ReadyDoneEvents[ThreadCount] = CreateEvent(NULL,FALSE,FALSE,NULL);
+ if ( !ReadyDoneEvents[ThreadCount] ) {
+ MessageBox(hwndDlg,"Error creating ReadyDone events","FATAL ERROR",MB_ICONSTOP|MB_OK);
+ exit(1);
+ }
+ }
+ if ( !StartEvent || !StopEvent ) {
+ MessageBox(hwndDlg,"Error creating Start or Stop events","FATAL ERROR",MB_ICONSTOP|MB_OK);
+ exit(1);
+ }
+
+ for(ThreadCount = ClientLow; ThreadCount <= ClientHigh; ThreadCount++ ) {
+
+ StartTestThreads(ThreadCount);
+
+ }
+
+ sprintf(Buffer,"No Active Threads");
+ SetDlgItemText(hwndDlg,ID_STATUS,Buffer);
+}
+
+VOID
+StartTestThreads(
+ DWORD ThreadCount
+ )
+{
+ DWORD i;
+ DWORD StartTick;
+ DWORD EndTick;
+ CHAR Buffer[256];
+ DWORD Transactions;
+
+ //
+ // Setup all of the threads
+ //
+
+ ResetEvent(StartEvent);
+ SetEvent(StopEvent);
+
+ sprintf(Buffer,"%d Initializing Threads",ThreadCount);
+ SetDlgItemText(hwndDlg,ID_STATUS,Buffer);
+
+ for(i=0;i<ThreadCount;i++){
+
+ if ( ThreadData[i].Thread ) {
+
+ //
+ // Thread exists, just reset it's files
+ //
+
+ ResetThreadsFiles(&ThreadData[i]);
+
+ }
+ else {
+
+ ThreadData[i].Index = i;
+ CreateThreadsFiles(&ThreadData[i]);
+
+ ThreadData[i].Thread = CreateThread(
+ NULL,
+ 0L,
+ (PVOID)ClientThread,
+ (LPVOID)&ThreadData[i],
+ 0,
+ &ThreadData[i].Id
+ );
+
+ if ( !ThreadData[i].Thread) {
+ MessageBox(hwndDlg,"Error Creating Client Thread","FATAL ERROR",MB_ICONSTOP|MB_OK);
+ exit(1);
+ }
+ }
+ }
+
+
+ //
+ // Wait for all threads to reach their idle state
+ //
+
+ i = WaitForMultipleObjects(
+ ThreadCount,
+ ReadyDoneEvents,
+ TRUE,
+ INFINITE
+ );
+
+ if ( i == WAIT_FAILED ) {
+ MessageBox(hwndDlg,"Error Waiting on ReadyDone Events (A)","FATAL ERROR",MB_ICONSTOP|MB_OK);
+ exit(1);
+ }
+
+ //
+ // Release the threads
+ //
+
+ sprintf(Buffer,"%d Active Threads",ThreadCount);
+ SetDlgItemText(hwndDlg,ID_STATUS,Buffer);
+ ResetEvent(StopEvent);
+
+ StartTick = GetTickCount();
+
+ SetEvent(StartEvent);
+
+ //
+ // Wait for all the threads to complete the test
+ //
+
+ i = WaitForMultipleObjects(
+ ThreadCount,
+ ReadyDoneEvents,
+ TRUE,
+ INFINITE
+ );
+
+ if ( i == WAIT_FAILED ) {
+ MessageBox(hwndDlg,"Error Waiting on ReadyDone Events (B)","FATAL ERROR",MB_ICONSTOP|MB_OK);
+ exit(1);
+ }
+
+ EndTick = GetTickCount();
+
+ Transactions = 0;
+ for(i=0;i<ThreadCount;i++){
+ Transactions += ThreadData[i].TransactionCount;
+ }
+
+ sprintf(Buffer,"%02d Active Threads: TPS %d",ThreadCount, (Transactions*1000) / (EndTick-StartTick));
+ SendMessage(hwndOutput,LB_ADDSTRING, 0L, (LPARAM)Buffer);
+}
+
+
+VOID
+ResetThreadsFiles(
+ PTHREAD_DATA Thread
+ )
+{
+ CHAR FileName[MAX_PATH];
+
+ return;
+ CloseHandle(Thread->hWriteFile1);
+ sprintf(FileName,".\\nbsim\\wf1_%02d.nbs",Thread->Index);
+ Thread->hWriteFile1 = CreateFile(
+ FileName,
+ GENERIC_READ | GENERIC_WRITE,
+ 0,
+ NULL,
+ CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL
+ );
+
+ if ( Thread->hWriteFile1 == INVALID_HANDLE_VALUE ) {
+ MessageBox(hwndDlg,"Error Creating Write File 1","FATAL ERROR",MB_ICONSTOP|MB_OK);
+ exit(1);
+ }
+ return;
+}
+
+VOID
+CreateThreadsFiles(
+ PTHREAD_DATA Thread
+ )
+{
+ CHAR FileName[MAX_PATH];
+ LPVOID Buffer[INIT_BSIZE];
+ DWORD i;
+ BOOL b;
+ DWORD Written;
+
+ sprintf(FileName,".\\nbsim\\rf1_%02d.nbs",Thread->Index);
+ Thread->hReadFile1 = CreateFile(
+ FileName,
+ GENERIC_READ | GENERIC_WRITE,
+ 0,
+ NULL,
+ CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL
+ );
+
+ if ( Thread->hReadFile1 == INVALID_HANDLE_VALUE ) {
+ MessageBox(hwndDlg,"Error Creating Read File 1","FATAL ERROR",MB_ICONSTOP|MB_OK);
+ exit(1);
+ }
+
+ sprintf(FileName,".\\nbsim\\rf2_%02d.nbs",Thread->Index);
+ Thread->hReadFile2 = CreateFile(
+ FileName,
+ GENERIC_READ | GENERIC_WRITE,
+ 0,
+ NULL,
+ CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL
+ );
+
+ if ( Thread->hReadFile2 == INVALID_HANDLE_VALUE ) {
+ MessageBox(hwndDlg,"Error Creating Read File 2","FATAL ERROR",MB_ICONSTOP|MB_OK);
+ exit(1);
+ }
+
+ sprintf(FileName,".\\nbsim\\wf1_%02d.nbs",Thread->Index);
+ Thread->hWriteFile1 = CreateFile(
+ FileName,
+ GENERIC_READ | GENERIC_WRITE,
+ 0,
+ NULL,
+ CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL
+ );
+
+ if ( Thread->hWriteFile1 == INVALID_HANDLE_VALUE ) {
+ MessageBox(hwndDlg,"Error Creating Write File 1","FATAL ERROR",MB_ICONSTOP|MB_OK);
+ exit(1);
+ }
+
+
+ for (i=0;i<INIT_BSIZE;i++){
+ Buffer[i] = (LPVOID)&Buffer[i];
+ }
+
+ //
+ // Initialize ReadFile 1 and 2
+ //
+
+ for (i=0;i<RF1_SIZE/sizeof(Buffer);i++){
+ b = WriteFile(Thread->hReadFile1,Buffer,sizeof(Buffer),&Written,NULL);
+ if ( !b || Written != sizeof(Buffer) ) {
+ MessageBox(hwndDlg,"Error Writing Read File 1","FATAL ERROR",MB_ICONSTOP|MB_OK);
+ exit(1);
+ }
+ }
+
+ for (i=0;i<RF2_SIZE/sizeof(Buffer);i++){
+ b = WriteFile(Thread->hReadFile2,Buffer,sizeof(Buffer),&Written,NULL);
+ if ( !b || Written != sizeof(Buffer) ) {
+ MessageBox(hwndDlg,"Error Writing Read File 1","FATAL ERROR",MB_ICONSTOP|MB_OK);
+ exit(1);
+ }
+ }
+}
+
+
+VOID
+ClientThread(
+ LPVOID ThreadParameter
+ )
+{
+ PTHREAD_DATA Thread;
+ CHAR Wf1BigData[WF1_BIG_BSIZE];
+ CHAR Wf1Data[WF1_BSIZE];
+ CHAR Rf1Data[RF1_BSIZE];
+ CHAR Rf2Data[RF2_BSIZE];
+ DWORD Wf1Position,SaveWf1Position;
+ DWORD Rf1Position;
+ DWORD Rf2Position;
+ DWORD i;
+ DWORD nBytes;
+ BOOL b;
+ CHAR ErrorText[256];
+
+ Thread = (PTHREAD_DATA)ThreadParameter;
+ Thread->TransactionCount = 0;
+
+ //
+ // Initialize Patter for output file
+ //
+
+ for (i=0;i<WF1_BSIZE;i++){
+ Wf1Data[i] = (UCHAR)i;
+ }
+
+ for (i=0;i<WF1_BIG_BSIZE;i++){
+ Wf1BigData[i] = (UCHAR)i;
+ }
+
+ Rf1Position = SetFilePointer(Thread->hReadFile1,0,NULL,FILE_BEGIN);
+ Rf2Position = SetFilePointer(Thread->hReadFile2,0,NULL,FILE_BEGIN);
+ Wf1Position = SetFilePointer(Thread->hWriteFile1,0,NULL,FILE_BEGIN);
+
+ if ( Rf1Position || Rf2Position || Wf1Position ) {
+ MessageBox(hwndDlg,"Error Setting Up Positions","FATAL ERROR",MB_ICONSTOP|MB_OK);
+ exit(1);
+ }
+
+ for (;;){
+
+ SetEvent(ReadyDoneEvents[Thread->Index]);
+ WaitForSingleObject(StartEvent,INFINITE);
+
+ //
+ // Do NbSim operations
+ //
+
+ for(i=0;i<100;i++) {
+
+ //
+ // Each transaction is:
+ //
+ // read from rf1
+ // write to wf1
+ // read from rf2
+ // big write to wf1
+ // write to wf1
+
+
+
+ //
+ // read from rf1
+ //
+
+ b = ReadFile(Thread->hReadFile1,Rf1Data,sizeof(Rf1Data),&nBytes,NULL);
+ if ( b ) {
+ if ( !nBytes ) {
+ Rf1Position = SetFilePointer(Thread->hReadFile1,0,NULL,FILE_BEGIN);
+ }
+ else {
+ Rf1Position += nBytes;
+ }
+ }
+ else {
+ sprintf(ErrorText,"ReadFile from file 1a failed %d",GetLastError());
+ MessageBox(hwndDlg,ErrorText,"FATAL ERROR",MB_ICONSTOP|MB_OK);
+ exit(1);
+ }
+
+ //
+ // write to wf1
+ //
+
+ b = WriteFile(Thread->hWriteFile1,Wf1Data,sizeof(Wf1Data),&nBytes,NULL);
+ if ( !b || nBytes != sizeof(Wf1Data) ) {
+ sprintf(ErrorText,"Error Writing Write file %d",GetLastError());
+ MessageBox(hwndDlg,ErrorText,"FATAL ERROR",MB_ICONSTOP|MB_OK);
+ exit(1);
+ }
+ else {
+ Wf1Position += nBytes;
+ if ( Wf1Position > WF1_SIZE ) {
+ Wf1Position = SetFilePointer(Thread->hWriteFile1,0,NULL,FILE_BEGIN);
+ if ( Wf1Position ) {
+ MessageBox(hwndDlg,"Reset of Wf1 Position (a) failed","FATAL ERROR",MB_ICONSTOP|MB_OK);
+ exit(1);
+ }
+ }
+ }
+
+
+ //
+ // read from rf2
+ //
+
+ Rf2Position = SetFilePointer(Thread->hReadFile2,sizeof(Rf2Data),NULL,FILE_CURRENT);
+ b = ReadFile(Thread->hReadFile2,Rf2Data,sizeof(Rf2Data),&nBytes,NULL);
+ if ( b ) {
+ if ( !nBytes ) {
+ Rf2Position = SetFilePointer(Thread->hReadFile2,0,NULL,FILE_BEGIN);
+ }
+ else {
+ Rf2Position += nBytes;
+ }
+ }
+ else {
+ sprintf(ErrorText,"ReadFile from file 2 failed %d",GetLastError());
+ MessageBox(hwndDlg,ErrorText,"FATAL ERROR",MB_ICONSTOP|MB_OK);
+ exit(1);
+ }
+
+ //
+ // big write to wf1
+ //
+
+ b = WriteFile(Thread->hWriteFile1,Wf1BigData,sizeof(Wf1BigData),&nBytes,NULL);
+ if ( !b || nBytes != sizeof(Wf1BigData) ) {
+ sprintf(ErrorText,"Error Writing Write file %d",GetLastError());
+ MessageBox(hwndDlg,ErrorText,"FATAL ERROR",MB_ICONSTOP|MB_OK);
+ exit(1);
+ }
+ else {
+ Wf1Position += nBytes;
+ if ( Wf1Position > WF1_SIZE ) {
+ Wf1Position = SetFilePointer(Thread->hWriteFile1,0,NULL,FILE_BEGIN);
+ if ( Wf1Position ) {
+ MessageBox(hwndDlg,"Reset of Wf1 Position (b) failed","FATAL ERROR",MB_ICONSTOP|MB_OK);
+ exit(1);
+ }
+ }
+ }
+
+ SaveWf1Position = Wf1Position;
+
+ Wf1Position = SetFilePointer(Thread->hWriteFile1,i*512,NULL,FILE_BEGIN);
+
+ //
+ // write to wf1
+ //
+
+ b = WriteFile(Thread->hWriteFile1,Wf1Data,sizeof(Wf1Data),&nBytes,NULL);
+ if ( !b || nBytes != sizeof(Wf1Data) ) {
+ sprintf(ErrorText,"Error Writing Write file %d",GetLastError());
+ MessageBox(hwndDlg,ErrorText,"FATAL ERROR",MB_ICONSTOP|MB_OK);
+ exit(1);
+ }
+ else {
+ Wf1Position += nBytes;
+ if ( Wf1Position > WF1_SIZE ) {
+ Wf1Position = SetFilePointer(Thread->hWriteFile1,0,NULL,FILE_BEGIN);
+ if ( Wf1Position ) {
+ MessageBox(hwndDlg,"Reset of Wf1 Position (a) failed","FATAL ERROR",MB_ICONSTOP|MB_OK);
+ exit(1);
+ }
+ }
+ }
+ Wf1Position = SaveWf1Position + nBytes;
+ Wf1Position = SetFilePointer(Thread->hWriteFile1,Wf1Position,NULL,FILE_BEGIN);
+
+ Thread->TransactionCount++;
+ }
+
+ SetEvent(ReadyDoneEvents[Thread->Index]);
+ WaitForSingleObject(StopEvent,INFINITE);
+ }
+}
diff --git a/private/sdktools/nbsim/nbsim.rc b/private/sdktools/nbsim/nbsim.rc
new file mode 100644
index 000000000..9d2943339
--- /dev/null
+++ b/private/sdktools/nbsim/nbsim.rc
@@ -0,0 +1,12 @@
+#include "nbsimp.h"
+#include "dialogs.h"
+#include "dialogs.dlg"
+#include <ntverp.h>
+
+#define VER_FILETYPE VFT_APP
+#define VER_FILESUBTYPE VFT2_UNKNOWN
+#define VER_FILEDESCRIPTION_STR "NetBench Simulator"
+#define VER_INTERNALNAME_STR "NBSIM\0"
+#define VER_ORIGINALFILENAME_STR "NBSIM.EXE"
+
+#include "common.ver"
diff --git a/private/sdktools/nbsim/nbsimp.h b/private/sdktools/nbsim/nbsimp.h
new file mode 100644
index 000000000..ae37bd162
--- /dev/null
+++ b/private/sdktools/nbsim/nbsimp.h
@@ -0,0 +1,120 @@
+/*++
+
+Copyright (c) 1992 Microsoft Corporation
+
+Module Name:
+
+ nbsimp.h
+
+Abstract:
+
+ Main include file for the NetBench Simulator.
+
+Author:
+
+ Mark Lucovsky (markl) 23-May-1995
+
+Revision History:
+
+--*/
+
+#ifdef RC_INVOKED
+#include <windows.h>
+#else
+
+#include <windows.h>
+#include <windowsx.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dialogs.h>
+
+#define MIN_CLIENTS 1
+#define MAX_CLIENTS 32
+
+FILE *LogFile;
+HWND hwndOutput;
+HWND hwndDlg;
+HANDLE hMonitorThread;
+HANDLE dwMonitorId;
+
+DWORD ClientLow;
+DWORD ClientHigh;
+
+VOID
+InitializeNbSim( VOID );
+
+BOOL
+CALLBACK
+NbSimDlgProc(
+ HWND hDlg,
+ UINT uMsg,
+ WPARAM wParam,
+ LPARAM lParam
+ );
+
+BOOL
+NbSimDlgInit(
+ HWND hwnd,
+ HWND hwndFocus,
+ LPARAM lParam
+ );
+
+VOID
+NbSimDlgCommand (
+ HWND hwnd,
+ int id,
+ HWND hwndCtl,
+ UINT codeNotify
+ );
+
+VOID
+MonitorThread(
+ LPVOID ThreadParameter
+ );
+
+VOID
+ClientThread(
+ LPVOID ThreadParameter
+ );
+
+VOID
+StartTestThreads(
+ DWORD ThreadCount
+ );
+
+typedef struct _THREAD_DATA {
+ HANDLE Thread;
+ DWORD Id;
+ DWORD Index;
+ DWORD TransactionCount;
+ HANDLE hReadFile1;
+ HANDLE hReadFile2;
+ HANDLE hWriteFile1;
+} THREAD_DATA, *PTHREAD_DATA;
+
+HANDLE ReadyDoneEvents[MAX_CLIENTS];
+HANDLE StartEvent;
+HANDLE StopEvent;
+THREAD_DATA ThreadData[MAX_CLIENTS];
+
+#define INIT_BSIZE 4096
+#define RF1_SIZE (1024*1024)
+#define RF2_SIZE (3*(1024*1024))
+#define WF1_SIZE (20*(1024*1024))
+#define RF1_BSIZE 1024
+#define RF2_BSIZE 5000
+#define WF1_BSIZE 2048
+#define WF1_BIG_BSIZE 16384
+
+VOID
+CreateThreadsFiles(
+ PTHREAD_DATA Thread
+ );
+
+VOID
+ResetThreadsFiles(
+ PTHREAD_DATA Thread
+ );
+
+#endif // defined( RC_INVOKED )
diff --git a/private/sdktools/nbsim/sources b/private/sdktools/nbsim/sources
new file mode 100644
index 000000000..980342aeb
--- /dev/null
+++ b/private/sdktools/nbsim/sources
@@ -0,0 +1,43 @@
+!IF 0
+
+Copyright (c) 1989 Microsoft Corporation
+
+Module Name:
+
+ sources.
+
+Abstract:
+
+ This file specifies the target component being built and the list of
+ sources files needed to build that component. Also specifies optional
+ compiler switches and libraries that are unique for the component being
+ built.
+
+
+Author:
+
+ Steve Wood (stevewo) 12-Apr-1990
+
+NOTE: Commented description of this file is in \nt\bak\bin\sources.tpl
+
+!ENDIF
+
+MAJORCOMP=sdktools
+MINORCOMP=nbsim
+
+TARGETNAME=nbsim
+TARGETPATH=obj
+TARGETTYPE=PROGRAM
+NTKEEPRESOURCETMPFILES=1
+EXPECTED_WINVER=4.0
+
+SOURCES=nbsim.rc \
+ nbsim.c
+
+UMTYPE=windows
+UMENTRY=winmain
+
+UMLIBS=\nt\public\sdk\lib\*\setargv.obj \
+ \nt\public\sdk\lib\*\libc.lib
+
+NTTARGETFILE0=nbsim.rc