|
|
Clock Your Connection SpeedBy Mark Sweeney, PC Magazine Clock Your Connection Speed Find out how fast your Internet connection really is. By Mark Sweeney How fast is your Internet connection, really? Providers of the various types of connections promise different communication speeds, but are you actually getting what you've been promised? Depending on network traffic, actual speeds can be slower. Cable modems are fast-as long as not too many of your neighbors are sharing the line-but can slow considerably with a heavy load. How do you know if you should switch to DSL? This issue's utility, NetPerSec, lets you check your connection speed in real time. NetPerSec monitors all TCP/IP activity to and from the Internet or other networks, and graphs the communication speed. The utility's dynamic tray icon can show send and receive activity with a bar graph or a histogram. For a detailed report, you can open the program's main window to view current and average send and receive speeds in a configurable, graphical display. You can adjust the sampling rate and the amount of data used to compute the average. NetPerSec runs under Microsoft Windows 95, 98, Me, NT 4.0, and 2000. The Visual C/C++ 6.0 source code is provided with the utility for those interested in seeing how the program works. Note that PC Magazine programs are copyrighted and cannot be distributed, whether modified or unmodified. Use is subject to the terms and conditions of the license agreement distributed with the programs. Using NetPerSec NetPerSec does not require any changes to your network or dial-up networking settings. The utility automatically detects your Internet access method: modem, network interface card, or both. You can start and stop NetPerSec at any time without losing your Internet connection. NetPerSec monitors all TCP/IP network activity and works with any type of connection, including modem, cable, DSL, and T1. The utility monitors your activity over an Internet connection and over a local or wide area network. NetPerSec'S Tray Icons The histogram icon displays the last 14 samples of network activity collected by NetPerSec and is divided into two areas. The top half of the icon shows received data, and the bottom shows sent data. The bar graph icon works in a similar fashion; the left half shows sent data and the right half shows received data. The bar graph, however, displays only the current sample. In addition to alerting you whenever data is transmitted or received, the icons provide a visual indication of your current data throughput. Throughput is the amount of data that has been sent or received within a given time period. The greater the throughput, the faster your Internet connection. NetPerSec depicts throughput using colored bars in its icon. Taller bars indicate faster throughput. Holding the mouse cursor over NetPerSec's tray icon displays the current and average data throughput in numerical form inside a ToolTip window. Configuring NetPerSec The Graph Tab The current and average values reflect data throughputin either bits per second or bytes per second. By convention, bits per second, abbreviated as bps, is used for devices and systems that transmit data such as modems and networks. Throughput for data storage devices, such as hard drives and memory, is measured in bytes per second, abbreviated as Bps. Distinguishing between bits and bytes using only the case of the letter b is quite subtle and may be unfamiliar to some users, so NetPerSec uses the entire word-as in Bytes/sec and bits/sec-when displaying values. Also, values may be combined with the standard metric prefixes kilo, mega, and giga. These prefixes are abbreviated using the single letters k or K, M, and G, respectively. The lowercase k indicates decimal kilobytes (1,000), and the uppercase K indicates binary kilobytes (1,024). Please refer to NetPerSec's online help for a full description of metric prefixes and the exact interpretations of their values as displayed by NetPerSec. When viewing data transmission rates in bits per second (bps), you are comparing the efficiency of your modem or network interface to the actual data throughput of your Internet connection. For example, if you want to see how well your 56-Kbps modem is performing, use the bits per second option in NetPerSec. Displaying bits per second is also helpful when playing streaming content over the Internet. If your cable connection averages about 150 Kbps you'll know beforehand that selecting the high bandwidth 300 Kbps movie will result in long pauses and dropped frames. You'll get better results with the smaller 100 Kbps version. When displaying bytes per second (Bps), you are measuring efficiency in terms of data storage and the calculations are performed in binary format. You will want to use this option when downloading files from the Internet or moving files across a network. The values displayed in NetPerSec will be consistent with those reported by your browser or FTP utility when indicating the bytes received per second. You have a choice of graph types to be displayed in the dialog-either bar graphs or line graphs. You may also choose to view current or average throughput, or both. Each of the graphs provides an Auto scale option that dynamically adjusts the range so the maximum is just large enough to contain the largest value. You should use Auto scale if you are using a high-bandwidth connection such as cable, DSL, or T1. Even with Auto scale enabled, if the throughput is very high at its peak, you'll see nothing on the graph when throughput is low. And if you manually set the scale low enough to see the low values, the peaks will spike off the top of the graph. With a relatively slow connection, you can set a fixed scale that fits the theoretical maximum, and you'll still be able to see results when the average throughput is low. Modem users may wish to manually configure the range of the graph to match the rated speed of their modems. For example, if you have a 56- Kbps modem, set the graph display mode to bps and adjust the slider control so that the topmost value in the graph displays 56k bits/sec. This will let you see how close you are to the theoretical maximum. The Options Tab With faster sampling rates, you get greater accuracy when calculating data throughput; with slower sampling rates, you can view historical information covering a greater period of time. Under low or moderate traffic conditions, I have found that a sample rate of 1 second provides accurate statistics and sufficient detail for the icons and graphs. Under high-traffic conditions, when you're running on a network server, for instance, a sample rate of more than 3 seconds provides sufficient accuracy and prevents historical data from scrolling off the graph too quickly. The second option, Averaging Window, specifies the time span (or window) used when calculating the average data throughput. This is important, because most systems are not sending and receiving data continuously. When viewing a Web page, for example, the data transfer might last only a few seconds. When sending an e-mail, it may last a minute or two. If NetPerSec calculated averages based on your entire session, the values would gradually diminish to zero and remain there. With a sampling rate of 1 second (the default), a window set from 10 to 30 seconds will yield accurate results for the average. If you are downloading lots of files and have a fast Internet connection, you may wish to use higher values, such as 60 seconds, for even greater accuracy. The Display Tab Windows limits icons displayed in the system tray to 16 predefined colors. NetPerSec allows you to select among these 16 colors for the receiving, sending, and background colors of the icon. All changes take effect immediately. You can observe the results in NetPerSec's tray icon and in the sample icon contained in the dialog. An Undo button lets you revert back to your saved color settings, and a Default button restores NetPerSec's default color scheme. There are two additional color settings that are not used for NetPerSec's icon: the color for the average text and the background color for the graph. Because these items are not limited to the 16 colors used in an icon, you may select any color that is available from the standard Window's color dialog. You must be using High Color or True Color mode for certain colors to appear correctly. The dialog also contains options to configure the display and start-up behavior of NetPerSec. You can opt to display the NetPerSec dialog on top of all other windows and to have the utility launch itself automatically with each Windows session. Inside NetPerSec SNMP was developed by the Internet Engineering Task Force (IETF) as a standard for exchanging network management information over TCP/IP as well as other types of networks. With SNMP, a network administrator can monitor and control various devices-such as routers, repeaters, bridges, PCs, and printers-that are attached to the network. Details on the SNMP specification can be found in the Request for Comments (RFCs) 1155, 1157, and 1213, which can be found at www.ietf.org. SNMP is based on a client/server model. The client in this case, NetPerSec, is called the SNMP manager and connects to a server program called the SNMP agent. The agent is responsible for maintaining the Management Information Base (MIB) database. MIBs contain standard sets of statistical and control objects that can be accessed by an SNMP manager. For example, one MIB object may represent the number of bytes that have been transmitted by the network; another may represent the total time the network has been running. In addition to the standard MIBs, SNMP allows the use of private MIBs that contain information specific to a device. A router manufacturer, for example, may supply a private MIB along with a router that shows the throughput for that particular device. RFC 1213, which defines the current Internet standard of MIB-II, lists 190 different objects. These are arranged hierarchically in a tree. To identify an object, you give its address in the tree using dot notation. As with an IP address, nodes can be identified by their names or by their associated numbers. As you can see, iso.org.dod.internet is equivalent to 1.3.6.1. All of the objects within MIB-II start with these four nodes. The numeric addressing scheme is called Abstract Syntax Notation, and each numeric address is called an object identifier or OID. There are two OIDs utilized by NetPerSec: ifInOctets and ifOutOctets. The OID ifInOctets has an identifier of 1.3.6.1.2.1.2.2.1.10 and specifies the number of octets, or bytes, received by the interface. The OID ifOutOctets specifies the number of bytes that have been sent out by the interface and has an OID of 1.3.6.1.2.1.2.2.1.16. The SNMP services and extensions implemented in Windows encompass a broad range of executable and DLL components. NetPerSec utilizes three DLLs: SNMPAPI (SNMP Utility Library), INETMIB1 (SNMP Internet MIB), and IPHLPAPI (IP Helper API). Systems running Windows 95 may not have the required DLLs installed, so in order to prevent run-time errors, NetPerSec dynamically loads each DLL and reports when an essential interface is not found. To retrieve statistical information from the SNMP agent, NetPerSec calls the function SnmpExtensionQuery(), passing it the identifiers for the ifInOctets and ifOutOctets objects. The function returns a structure containing the number of bytes that have been sent and received by the interface. NetPerSec repeats this process for all network devices, modems, and network cards contained in the system. In SNMP, this is accomplished using the command ASN_RFC1157_GETNEXTREQUEST, and is sometimes referred to as "walking the tree." You can then calculate data throughput by dividing the deltas for the received and transmitted values by the number of milliseconds that have elapsed between SNMP queries. Although the concept of MIBs and OIDs may appear impenetrable at first, the interface is actually quite easy to use. To retrieve a particular network statistic, you simply specify the desired OID and call the SNMP agent. SNMP saves you the hassle of dealing with low-level interfaces such as Winsock and TCP/IP. You may find the OIDs defined in RFC 1213 the most interesting, because these identifiers are Internet related. IP Helper API To solve this problem, NetPerSec uses the IP Helper API, which is exposed through IPHLPAPI.DLL. The headers and libraries for this interface are available in the Microsoft Platform SDK and are documented under the Network and Directory Services folder. IP Helper provides much of the same information as SNMP and is even easier to use. You don't need to specify OIDs or manage the allocation and de-allocation of SNMP memory blocks. All the information needed by NetPerSec is returned in a single IP Helper function call named GetIfEntry(). Unfortunately, the IP Helper API interface is not supported under Windows 95. And, according to the Microsoft Developer Network, the IPHLPAPI.DLL does not work under Windows 98 when Internet Explorer 5.0 is installed. To minimize the requirements for the utility and keep things simple, NetPerSec uses the SNMP interface for systems running on the Win 9x and Me platforms, and IP Helper for Windows NT 4.0 and Windows 2000. Dynamic Icons Rather than pre-creating a matrix of 14 by 14 icons (with half of the icon for received data and the other half for transmitted data), NetPerSec uses only two skeleton icons, which constitute the outline for the icons. One icon is for the bar graph and the other for the histogram icon. When NetPerSec needs to update its icon, it converts the skeleton icon into bitmapped images using the GetIconInfo() API function. This function returns two bitmaps for the icon, one containing color information and the other for the icon's mask. NetPerSec scales and renders the throughputmeasurement into the device context of the color bitmap using the FillRect() API function. The icon is then reassembled using the CreateIconIndirect() API function and sent to the system tray for display. I found that it was important to de-select and delete the two bitmaps returned from the GetIconInfo() API function to prevent resource leaks. The SNMP interface and IP Helper API provide easy mechanisms to collect network statistics. NetPerSec could be further enhanced to include technical information available only in non-graphical utilities such as NETSTAT or IPCONFIG. For casual users, NetPerSec provides graphical and instantaneous feedback on the performance of their Internet connections. Mark Sweeney, the author of NetPerSec, is vice president of Software at Clearview Software International, a company that specializes in Windows-based client/server applications. Sheryl Canter is the editor of the Utilities column and a contributing editor of PC Magazine.
|