About Socket Workbench

Sockets are the underling protocol used by the Internet and are found in many computer systems in which there is inter-process communications.  Socket Workbench is a utility designed to test and analyse such communications.

While developing a distributed computer system, developers often need to implement and test both ends of the socket communication channels at the same time.  This often leads to problems where developers at either end suggest that the problems lie with the other end.  Socket Workbench allows developers to test their systems independently of the progress of other team members.

Socket Workbench is also useful in understanding Internet communications.  It contains a library of common requests and responses from Web, E-mail and FTP protocols .

Socket Workbench can be configured as a Socket Client , a Socket Server or in Pass Through mode in which communications between Clients and Servers can be intercepted.


Client Mode

In the Client Mode, Socket Workbench can connect to Socket Servers.  Web Browsers, FTP Clients and e-mail Clients are all examples of socket clients.

As a socket client, you must specify the name of the computer to connect to (the Server) and the port to connect to.  Pressing “Connect” will establish a connection to the socket server.  Once the state of the connection changes to “Connected”, you can send or receive information on the socket.  Press “Send” to send information or select predefined information from the drop-down arrow next to the send button.

You can select from a predefined list of servers and ports by pressing the “…” buttons.  This list can be changed by loading either the “Servers.txt” file or “Ports.txt” file found in the Socket Workbench application directory.


Server Mode

In the Server Mode, socket clients connect to Socket Workbench.  Web Servers, FTP Servers and e-mail Servers are all examples of socket servers.

In server mode, you must select a port number to “listen” on.  It is this port that the clients connect to.  Socket Workbench will allow any number of socket clients to connect.  When information is received from the clients it is displayed in main data window along with the socket on which it was received.

You can select from a predefined list of ports by pressing the “…” buttons. This list can be changed by loading the “ports.txt” file found in the Socket Workbench application directory.

When information is sent through the socket in Server Mode, the same information is sent to all of the clients.


Pass Through Mode

Pass Through mode enables the interception of socket communications between a socket client and its server.  In pass through mode, a socket client instead of connecting directly to its server, connects to Socket Workbench.  Socket Workbench then in turn connects to the intended server.  Communications can then proceed as if Socket Workbench didn’t exist.

In this mode, the user can see exactly what information is being passed back and forth between the client and the server.

(Examples and further information follow graphic)

Example

If you want to see the information flowing between a Web Server and your Browser, place Socket Workbench into Pass Through Mode.  On the Client Side, set the “Connect To”  to the web site you are interested in (eg. “www.microsoft.com”) and enter 80 into the port number.  On the Server Side, listen on port 80.  If you have a personal web server installed on your machine then you will either need to stop it or select a different port number. Select “Start Both” to start listening for your web browser and to connect to the Web Site.

Using your Web Browser go to the URL http://localhost.  The web site you are interested in should then be displayed in the Browser.  If anything goes wrong then be sure to read the notes below.

In Socket Workbench you will be able to see all the information that has flowed between the Browser and the Server.  Since Socket Workbench clears its windows when they contain too much information, it may be wise to enable Logging .

Notes

In most cases, in Pass Through Mode be sure to enable the “Automatically Attempt Reconnection After” in the Options .  Set it to about 1000 mSecs.  This ensures that a socket connection is re-established each time a Web Page is requested.  Also, ensure that “Allow multiple clients to connect to Socket Workbench” is disabled.  This prevents your Web Browser from attempting to retrieve its graphics, which can cause complications.  (See below for more information.)

Also, attempt to delete and disable the caching in your Web Browser or at least force the Browser to request the page on each request.  In Internet Explorer 4.0 this can be done by selecting View | Internet Options | General Tab Page | Settings | Every visit to the page.  In Internet Explorer 5.0, this can be done by going to the Tools menu instead of the View menu.  In Netscape, select Edit | Preferences | Advanced Cache | Every Time

It is best to wait until the page is fully displayed before requesting the next page.  Otherwise, Socket Workbench will get confused.  If for some reason the pages stop being displayed then select “Stop Both” followed by “Start Both” to reset the Browser connection and the connection to the Web Server.

Graphics Aren’t Displayed in Pass Through Mode.

When requesting a web page, most browsers open a single socket connection to retrieve the HTML.  The browser then parses the HTML looking for references to the pictures, sounds, etc.  If 10 pictures are found then an additional 9 socket connections are opened to retrieve these images.  The original socket connection is re-used to get the other image.

In Pass Through mode, Socket Workbench is not designed to handle multiple client requests at once.  (A full blown proxy server is required for this.)  For this reason, no graphics are displayed.  However, it is possible to request a particular image by selecting that image on the Browser and selecting “Show Picture” (for Internet Explorer).  The HTTP request for this picture and the pictures data can then be viewed in the Socket Workbench data window.


Send Screen

Use this screen to send data down the socket.

Description of Data

Type in a description of the data being sent.  When the window is closed, this description will appear in the drop-down list associated with the Send button.

Copies the contents of the data to be sent to the clipboard.

Saves the data to a file.

  Reads data from a file. You are given the option of linking to the file.  If you link to the file you cannot edit the data on the screen but the file is monitored for changes.  If the file were to change, then the next time it is to be sent the file is re-loaded.

Clears the data to be sent.

Shows the details of the data to be sent.

Shows and hides the advanced options.  These options contain the timing information for sending the data at regular intervals.

“Binary Data Preceded By”: Select this check box if binary data is represented by a backslash (“\”) followed by two digit hexadecimal numbers.  To send a backslash send the “\\” string.

“Pause After Every Message”: Select this check box if Socket Workbench is to pause after every message is transmitted.  The characters that define the end of the message are found in the options screen .  Enter the pause period after the check box is selected.

“Send Data Periodically”: Select this check box if Socket Workbench is to send the data periodically.  Enter the period that the data is to be transmitted for.

  This displays the options screen.


Common Protocols

Common Protocols allows the user to send predefined data through the socket.

The information in this window is read from the “Protocols.txt” file found in the Socket Workbench installation directory.  Feel free to modify this file to include your own custom protocols.

Select the protocol type and the particular message from the tree from the left-hand side of the screen.  The information to be sent is displayed in the right-hand side. The information can be edited and then copied and pasted into the Send screen.

“Replace Escaped Characters With Fields From”:  This option allows information to be read from a file containing comma separated fields and automatically inserted into the data.  The data is sent for every line in the file.  The escape sequence uses the format “%n” where “n” is the field number.  The data may contain multiple instances of the one field.  This can be used to further refine test procedures or to send e-mail to a list of people.  Press Preview to see the data that is to be sent down the socket.  This information is displayed in the Send window .

“Reconnect After Each Message Is Sent”: This forces the closure and re-connection of the socket after each message is sent.  This is required for some protocols like sending e-mail.


Sending Data

To send data press the Send button or select predefined data from the drop-down list. Alternatively, select Common Protocols to send messages from a number of well-known protocols.

When data is sent it is displayed in the following format:

The data being sent can be viewed exclusively by selecting “Output Only” from the Show drop down list.  If performance is a consideration, then enable logging and select “Nothing” from the show drop down list.  In this state, Socket Workbench is very efficient and fast.

Select the Details check box to see the information in plain ASCII text.

The data is split into messages and fields depending on the settings configured in the Options screen.

This prevents the data from being sent down the socket.  Rather, the information is displayed on the screen then held in an internal buffer.  Pressing this button again releases the buffer and sends all the information instantly.  This is useful in stress testing applications that lie at the other end of the socket.

This clears the buffers.

This displays details of the data that has been sent in any one of a number of different formats.

This clears the list of data that has been sent.

This indicates that the data has been successfully sent to the server (in Client Mode) or to all the clients (in Server Mode). If there are no clients connected then the tick will still appear.

This indicates that the socket is not in the Connected state and that the data could not be sent.


Receiving Data

When data is received it is displayed in the following format:

The data being received can be viewed exclusively by selecting “Input Only” from the Show drop down list. If performance is a consideration, then enable logging and select “Nothing” from the show drop down list.  In this state, Socket Workbench is very efficient and fast.

Select the Details check box to see the information in plain ASCII text.

The data is split into messages and fields depending on the settings configured in the Options screen.

When selected, the data is read and buffered rather than being displayed straight away.  Pressing this button again releases the buffer and displays the information on the screen.  It may take some time for Socket Workbench to empty and display this buffer.

This clears the Receive Pause buffer.

This displays details of the data that has been sent in any one of a number of different formats.

This clears the list of data that has been received.


Filtering

The Filtering screen allows only certain information to be displayed.  Often, while analysing a protocol, you are only interested in a subset of the messages .  Filtering allows only these messages to be displayed.

Enabled the check box at the top of the screen and type text that occurs in the messages that you are interested in.

When Filtering is enabled, “Filtering On” appears in the status bar of the main window.

The options screen allows the user to set whether the filtering is case sensitive or not.


Details Screen

This Details screen can be accessed through many different areas of Socket Workbench.  It provides detailed information about the data that is being investigated.

WYSIWYG:  “What You See Is What You Get” simply places the raw data into the text window.  Non-printable characters are not displayed.

Chr:  Character mode displays printable characters normally but non-printable characters are represented by a backslash (“\”) followed by their two digit hexadecimal value.  For example, a carriage return and line feed (Asc 13 and 10) is displayed as “\0D\0A”

Decimal:  Decimal mode displays all characters in their decimal representation.

Hex:  Hexadecimal mode displays all characters in their hexadecimal representation.

Bin:  Binary mode displays all characters in their binary representation.

Oct:  Octal mode displays all characters in their octal representation.

Auto-display the latest data: This check box is only visible when viewing data that is either being sent or received on the socket.  Selecting this check box ensures that the data displayed in this window is the latest data that was either sent or received.


Socket State

The socket state window shows a history of the state of the socket.  The state is polled.  It is possible that states may be missed if the state transitions occurred too quickly.

In Server Mode , the “Sock #” field shows the socket number that the state transition referred to.  In Client Mode , this field is set to “NA”.


Socket Workbench Events

The Socket Workbench Events Window is found by selecting View | Events from the main window.

This window contains a description of all users activities performed on Socket Workbench.  Some of the details include:

•	the option settings

•	the mode of the program

•	when sockets were opened and closed and whether it was done automatically and

•	the time when the contents of the windows were cleared .


Options - Appearance

This tab page provides access to some general Socket Workbench settings.

Clear Lists When They Get Larger Than:  All of the lists in Socket Workbench need to be cleared when they get too large.  These settings allow the user to specify how large the lists should grow before they are cleared.  If these values are set too high then the performance of Socket Workbench may degrade.

Note: It is possible to record all of the data to a file via logging (View | Logging from the main screen’s menu)

Case sensitive comparisons: This option declares whether the filtering should be case sensitive or not.

Include Socket Communication Events in the Event Log: Enabling this setting forces Socket Workbench to record each data arrival or transmission in the Event Log .  Depending on the data that is being monitored, the number of these events could be significant.


Options - Details View

This tab page contains options about how the details of the data are displayed.

Message Separator: This setting determines how socket messages are separated.  One message is displayed per line.  Generally, a character return and line feed separate messages. (“\0D\0A”).

Field Separator: Often, the message is split into fields.  A particular character or characters separate each field.  If you are analysing a protocol that contains fields, then set the field separator.  When the data is sent or received, the message is automatically split into its constituent fields.

Ignore Field Separators Between: If messages are split into fields then sometimes a character like a quote may indicate that any field separators should be ignored until the next quote is found.  This enables text to be safely sent through the socket.

Display Message Separator In Details View: If this is selected then the message separators are displayed in the main window.

Display Field Separator In Details View: If this is selected then the field separators are displayed in the main window.  This only applies if the user has requested that the message is split into fields.

Concatenate multiple consecutive message separators to the end of the message: If multiple message separators follow a message, then setting this option concatenates all of these separators to the end of the message instead of displaying them on a line by themselves.


Options - Socket Handling

This tab page contains settings that describe how the sockets should be handled.

Automatically close connection if peer disconnects: In client mode , when the peer (the Server) disconnects or closes the socket, the user explicitly needs to close the connection before another connection can be established. Enabling this option allows the socket to be automatically closed when the server disconnects.

Automatically attempt reconnection after:  If the socket is closed automatically and this setting is enabled then Socket Workbench will automatically attempt to reconnect to the server after the specified period has elapsed. This will continue to happen until the user selects “Disconnect”.

Allow multiple clients to connect to Socket Workbench:  In Pass Through mode, all clients that connect to Socket Workbench will all receive the same information.  When web browsers retrieve a page, they generally attempt to open as many socket connections as pictures on the page.  If this option is selected and Socket Workbench is intercepting Web requests, then all of the pictures on the web page will be identical.  If you are intercepting Web requests, do not enable this option.  In this way, the HTML will be successfully transmitted along with one picture.

Configure for HTTP Pass Through:  If you are intercepting HTTP information (ie the Web) in Pass Through mode then it is important that these options are configured correctly.  Click this button to automatically configure your Socket Handling settings.


Logging

Logging can be found from the main screen by selecting View | Logging.

Logging allows all of the events to be saved to a file.  Whenever Socket Workbench starts, the state of the logging is identical to its state when it closed.  Socket Workbench always appends to the files.  The files are only deleted when requested by the user.

Select the type of logging by selecting the appropriate tab page.  Selecting the Log Data check box enables the logging. A tick appears on all tabs that are being logged.  On the status bar of the main screen, a summary of which events are being logged is displayed.

Space is provided for the name of the file being logged. This file can be deleted or viewed by selecting the command buttons.  When the data is being logged, the name of the file cannot be changed.

If Include date/time at the beginning of the message is selected, then all lines in the log file are preceded with a date/time stamp.

If Log data in hex is selected, then all data is logged in a hexadecimal format just like standard hex editors.  This can be very useful when you are analysing binary based protocols.

All Events logs all Socket Workbench events.  Depending on the data being monitored, this file can grow very large very quickly.

Select Start All or Stop All to start or stop all of the logging.

By default, the log files are creating in the Log directory under the Socket Workbench installation directory.


User Interface

The user interface of Socket Workbench has been designed to be as flexible as possible.  Almost every window is modeless.  This means that the windows “float” around the screen independently of all other windows.  During this time, Socket Workbench continues to process the user’s requests.

In general, the windows can be minimized and maximized independently of each other.  During a socket analysis, it is common to have only one window on the screen with all the other windows minimized.

Where possible the state of Socket Workbench is restored when it is started.  This enables the user to quickly resume the work from the previous session.

Novice users can use the Common Configurations window to help set up the environment in a number of standard ways.


Proxy Servers

Some mention should be made of Proxy Servers and how Socket Workbench needs to interact with them.

Socket Workbench handles proxy servers in the same way as your Web Browser.  Instead of connecting directly to the socket server, you must connect to the proxy.  Once a connection has been established, you can then issue your socket requests.

For example, if you want to connect to the CNN Web Site (www.cnn.com) but you have to go via your proxy http://proxy on port 8080 then do the following:

1.	Put Socket Workbench in Client Mode.

2.	Type “proxy” in the server text field.

3.	Type 8080 in the port text field.

4.	Select “Connect”

5.	Wait for the socket to go into the “Connected” state.

6.	Without a proxy you would need to issue a HTTP request of the following format:

GET / HTTP/1.1

Accept: application/vnd.ms-excel, application/msword, application/vnd.ms-powerpoint, */*

Accept-Language: en-au

Accept-Encoding: gzip, deflate

User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows 98)

Host: localhost

Connection: Keep-Alive

But instead issue the following request…

GET HTTP://www.cnn.com / HTTP/1.1

Accept: application/vnd.ms-excel, application/msword, application/vnd.ms-powerpoint, */*

Accept-Language: en-au

Accept-Encoding: gzip, deflate

User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows 98)

Host: localhost

Connection: Keep-Alive

Note that this later request contains the end point information in it (www.cnn.com).  This is now enough information for the proxy to retrieve the page.

Some Proxies in some configurations require that the Host field is set to the name of the computer that you are trying to connect to.  Microsoft Proxy Server is one example.  For example:

GET HTTP://www.cnn.com / HTTP/1.1

Accept: application/vnd.ms-excel, application/msword, application/vnd.ms-powerpoint, */*

Accept-Language: en-au

Accept-Encoding: gzip, deflate

User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows 98)

Host: www.cnn.com

Connection: Keep-Alive


Registration Information

To register Socket Workbench, go to Sigma Solutions Web site http://www.sigmasolutions.com.au and follow the instructions on the screen.


Common Configurations

Common Configurations helps novice users setup Socket Workbench into a number of different configurations.

Select the type of configuration you would like to setup and then follow the instructions on the screen.