You are on page 1of 5

Connectivity:Overview

Understanding TCP/IP
TCP/IP, the ubiquitous network protocol, is actually a four-layer suite of protocols and is well
worth gaining an understanding of. The third instalment of our four-part article.

By Julian Moss

I n the previous instalment of this


article [PCNA 88, File C04100] we
looked at the transport layer pro-
tocols of the TCP/IP suite: User Data-
pens many time servers do support
connections using TCP as well. TCP’s
built in reliability is of little use in this
application, because by the time the
communicate with each other. Com-
munication may be infrequent and
sporadic, and the amount of informa-
tion exchanged small. Usually a com-
gram Protocol (UDP) and Transmi- protocol decides that the message may mand sent by the manager will
ssion Control Protocol (TCP). We saw have been lost and re-sends it, the in- generate just a single response.
that UDP is an unreliable, connection- formation it contained will be out of SNMP uses UDP. This avoids the
less protocol suitable for transferring date. UDP is the most suitable protocol overhead of having to maintain con-
small amounts of data and for broad- for real-time applications like this, and nections between the SNMP manager
cast and multicast applications, and others like audio, video and network and each agent. Because the communi-
we saw that TCP implements reliabil- gaming. cation protocol consists essentially of a
ity mechanisms and requires clients to request for data and a reply containing
establish a connection with a server SNMP the data requested, UDP’s lack of reli-
before data can be transferred. This ability is not a problem. Reliability is
month we will examine some of the A slightly more complex UDP ap- easily implemented within the SNMP
application-layer protocols, how they plication is Simple Network Manage- manager by re-sending a request if no
work, and how they exploit the char- ment Protocol (SNMP). It allows response is received within a certain
acteristics of UDP and TCP. applications to glean information period.
about how various elements of the net- The main function of SNMP is to al-
Time work are performing, and to control low the manager to get information from
the network by means of commands tables maintained by the agents. The ta-
A network time service is one of the sent over it rather than by physical bles are known as the Management In-
simplest possible Internet applica- configuration of equipment. formation Base (MIB). The MIB is
tions. It tells you the time as a 32-bit In SNMP there are two distinct com- divided into groups, each containing in-
value, giving the number of seconds ponents, the SNMP manager and formation about a different aspect of the
that have elapsed since midnight on SNMP agents. A manager can commu- network. Examples of the information
1st January 1900. nicate with many agents. Typically, the that the MIB may contain include the
Time servers use the well-known SNMP manager would be an applica- name, type and speed of a network in-
port number 37. When your time client tion running on the network man- terface, a component’s physical location
opens UDP port 37 on the server, the ager’s console, and agents will run on and the contact person for it, and statis-
server responds by sending the four user workstations, in hubs, routers and tics such as the number of packets sent
bytes of time information. other pieces of network hardware. and the number that wereundeliverable.
For such a simple transaction UDP All communication is between the
is perfectly adequate, though as it hap- manager and an agent. Agents don’t Object IDs
Data is addressed using object IDs.
These are written as sequences of num-
“A network time service is one of the bers separated by periods, rather like
long IP addresses. Each number going
simplest possible Internet applications. It from left to right represents a node in
a tree structure, with related informa-
tells you the time as a 32-bit value, giving tion being grouped in one branch of the
tree. There are standardised object IDs
the number of seconds that have elapsed for commonly used items of informa-
tion, and also a section for vendor-spe-
since midnight on 1st January 1900.” cific information. The assignment of
object IDs is controlled by the Internet
Assigned Numbers Authority (IANA).

Issue 91 (January 1998) Page 13


PC Network Advisor File: C04100.9
Connectivity:Overview

connected terminal. It is a client/serv-


er application. The server runs on a
“Most SNMP messages have a fixed host on which applications are run-
ning, and passes information between
format. In a typical transaction, the applications and the Telnet clients.
The well-known port number for Tel-
an SNMP manager will send a UDP net servers is TCP port 23.
Telnet clients must convert the user
datagram to port 161 on a host running data between the form in which it is
transmitted and the form in which it is
an SNMP agent.” displayed. This is the difficult part of
the application, the terminal emula-
tion, and has little to do with the Telnet
protocol itself. Telnet protocol com-
Most SNMP messages have a fixed Message Types mands are principally used to allow
format. In a typical transaction, an the client and server to negotiate the
SNMP manager will send a UDP data- One problem with SNMP version 1 display options, because Telnet clients
gram to port 161 on a host running an is that the maximum size of a message and servers don’t make assumptions
SNMP agent. The datagram has fields is 512 bytes. This limit was chosen so about each other’s capabilities.
for the type of message (in this case a that the UDP datagram in which it is TCP provides the reliability for Tel-
get-request message), the transaction sent falls within the limit (576 bytes) net, so neither the client nor the server
ID (which will be echoed in the re- that all TCP/IP transports are guaran- need be concerned about re-sending
sponse so that the manager can match teed to pass. The error status value will data that is lost, nor about error check-
up requests with the data received), indicate if the information requested is ing. This makes the Telnet protocol
and a list of object ID/value pairs. In too big. Typically, this can occur when very simple. There is no special format
the get-request message the object IDs asking for text-based information, for TCP segments that contain com-
specify the information requested and which is returned as strings of up to mands - they simply form part of the
the value fields are empty. 255 characters in length. data stream.
The agent will respond with a data- SNMP version 2 adds two new mes- Data is sent, usually as 7-bit ASCII,
gram in which the message type field sage types. Get-bulk-request provides in TCP packets (which you may recall
is get-response. An error status field a way to retrieve larger amounts of are called segments). A byte value of
will indicate whether the request has data than version 1 can handle, and 255, “interpret as command” (IAC),
been fulfilled, or whether an error such inform-request allows SNMP manag- means that the bytes which follow are
as a request for a non-existent object ID ers to communicate with one another. to be treated as Telnet commands and
occurred. The same list of object ID / SNMP 2 also adds security features not user data. This is immediately fol-
value pairs as in the get-request mes- which can be used to help ensure that lowed by a byte that identifies the com-
sage will be returned, but with the information is passed only to agents mand itself, and then a value. Many
value fields filled in. authorised to receive it. commands are fixed length, so the byte
There are five types of message in after that, if not another IAC, would be
SNMP version 1. Apart from get-re- Telnet treated as user data. To send the byte
quest and get-response there is set-re- 255 as data, two consecutive bytes of
quest, used by the SNMP manager to Telnet is a terminal emulation ap- value 255 are used.
initialise a value, and get-next-request. plication that enables a workstation to Some commands, such as those that
The latter is a bit like listing a directory connect to a host using a TCP/IP link include text values, are variable length.
with a wildcard file spec, in that it and interact with it as if it was a directly These are implemented using the sub-
returns a list of all the available object
IDs in a particular group.
The fifth message type, trap, is used
by SNMP agents to signal events to the
SNMP manager. These messages are
“Telnet clients must convert the user
sent to UDP port 162. Trap messages
have a format of their own. This in-
data between the form in which it is
cludes a trap type field which indicates
the type of event being signalled: for
transmitted and the form in which it
example, the agent initialising itself or
the network device being turned off.
is displayed. This is the difficult part
There is a vendor-specific trap type
which allows vendors to define traps
of the application.”
for events of their own choosing.

File: C04100.10
PC Network Advisor Issue 91 (January 1998) Page 14
Connectivity:Overview

TCP/IP

responds to single keystrokes rather


than whole lines of input.
“Telnet allows you to interact with an The urgent flag and urgent pointer
in a TCP segment come into use when
application running on a remote a Telnet terminal user presses the
Break key to interrupt a process on the
computer, but it has no facility for host. Break is converted by the Telnet
client into two Telnet commands
enabling you to copy a file from that which are sent to the server: IP (inter-
rupt process) followed by DO <timing
computer’s hard disk to yours.” mark> (again, we use angle brackets to
indicate a byte representing an option).
The server responds to the latter with
WILL <timing mark> followed by a
option begin (SB) and sub-option end the host application the Telnet server DM (data mark) command. The urgent
(SE) command bytes. These command will send WILL <echo> to the client, pointer is set to point to the DM com-
bytes enclose the variable length data which will agree to this by sending DO mand byte, so even if flow control has
like parentheses. <echo>. This option can be changed halted the transmission of normal data
The principal Telnet commands during a session to suppress the dis- this command will still be received.
used to negotiate the display options play of password characters. Data mark is a synchronisation marker
when a client connects to a server are Another Telnet option to be negoti- which causes any queued data up to
WILL (sender wants to enable this op- ated is the transmission mode. The that point to be discarded.
tion), WONT (sender wants to disable usual mode is character-at-a-time Most of the data that passes be-
this option), DO (sender wants the re- mode, where each character typed at tween client and server during a Telnet
ceiver to enable this option) and DONT the terminal is echoed back by the serv- session is user input and application
(sender wants the receiver to disable er unless the host application specifi- data. The important thing to realise is
this option). cally turns echoing off. You can tell that Telnet does not package up this
To see how this works, consider an when character-at-a-time mode is be- data with additional headers or control
example. You start your Telnet client, ing used because there is a delay be- information: it is simply passed di-
which is configured to emulate a VT tween a key being pressed and a rectly to TCP. One side effect of this is
220 terminal, and connect to a host. The character appearing in the terminal that you can use a Telnet client to talk
client sends WILL <terminal-type> window. to other TCP applications that use AS-
(where <terminal-type> is the byte The main alternative to character- CII-based protocols simply by con-
value representing the terminal type at-a-time mode is line mode. In this necting to the appropriate port.
display option) to say that it wants to mode, the client displays the charac- Though it might not normally be sen-
control what terminal type to use. The ters typed and provides line editing sible to do this, it can be a useful trou-
server will respond with DO <termi- capabilities for the user. Only com- bleshooting tool.
nal-type> to show that it is happy for pleted lines are sent to the server. Line
the client to control this option. mode is used by some mainframe ter- Finger
Next the server will send SB <termi- minal emulations. Again, it is possible
nal-type> <send> SE. This is an invita- to switch modes during a Telnet ses- Finger is a simple example of a
tion to the client to tell the server what sion if it is required to interact with an TCP/IP application that uses an AS-
its terminal type is: <send> is a byte application running on the host that CII-based protocol. A Finger server is
that means “send the information”.
The client responds with SB <terminal-
type> <is> VT 220 SE (<is> is a byte
that indicates that the requested infor- “The well-known Finger port is TCP
mation follows) and so the server is
informed of the terminal emulation port 79. A Finger client opens this port
that the client will be using.
Client and server will negotiate and then sends a request, which is
various other options at the start of a
connection. Certain options may also either a null string or a user name.
be changed during the Telnet session.
The echo option determines whether The server responds by sending some
or not characters that are sent by the
client are echoed on the display, and by text and closing the connection.”
which end. If characters that are typed
at the terminal are to be echoed back by

Issue 91 (January 1998) Page 15


PC Network Advisor File: C04100.11
Connectivity:Overview

a program that supplies information to FTP is unusual compared to other second, LIST, causes the server to open
a requesting client. The information sup- TCP applications in that it uses two the specified port, send the directory
plied usually relates to the user accounts TCP connections. A control connection list, and close it again.
on a host, though many ISPs use Finger is made to the well-known FTP port The sequence for downloading a
servers to provide status information. number 21, and this is used to send FTP file is very similar to that for obtaining
The well-known Finger port is TCP commands and receive replies. A sepa- a directory list. First, a PORT com-
port 79. A Finger client opens this port rate data connection is established mand is used to specify the data con-
and then sends a request, which is whenever a file or other information is nection port, and then the command
either a null string or a user name. The to be transferred, and closed when the “RETR filename” is sent to specify the
server responds by sending some text data transfer has finished. Keeping file to be retrieved. The server opens
and closing the connection. If a null data and commands separate makes the data port and sends the data, which
string was sent you may receive infor- life easier for the client software, and the client writes to the hard disk. The
mation about all users known to the means that the control connection is server closes the TCP connection to the
system; a user name will return infor- always free to send an ABOR (abort) data port when the file transfer has
mation about that specific user. command to terminate a lengthy data finished, which is the signal to the cli-
For security reasons many organi- transfer. ent to close the newly-created file.
sations do not run Finger servers, or FTP commands are sent in plain 7-
have them reply with a standard mes- bit ASCII, and consist of a command of Conclusion
sage whatever the request. From our up to 4 characters followed by zero or
perspective the point of interest is that more parameters (those familiar with Since you are unlikely to be asked
the protocol is pure ASCII text, as you text mode FTP clients like that sup- to write your own client or server there
can verify by connecting to a Finger plied with Microsoft TCP/IP may find is little to be gained from looking at
server using a Telnet client. it curious that FTP commands are not these application protocols in more de-
the same as the commands given to the tail. However, it is hoped that some
File Transfer Protocol FTP client). The replies consist of a useful insights into the working of In-
three digit number followed by an op- ternet applications can be gained from
Telnet allows you to interact with tional text explanation, for example, these brief descriptions of how a few of
an application running on a remote “250 CWD command successful”. The them work.
computer, but it has no facility for ena- numbers are for easy interpretation by Perhaps the most striking thing
bling you to copy a file from that com- FTP client software, the explanations about the protocols that use TCP is
puter’s hard disk to yours, nor for you are for the benefit of the user. how simple they are. Because the
to upload files to the remote system. It is instructive to see what happens lower protocol levels take care of reli-
That function is carried out using File during a simple FTP session. When ability, routing and physical transfer
Transfer Protocol (FTP). you connect to the FTP server (TCP matters, the application protocol need
The FTP specification caters for sev- port 21) it sends its welcome message concern itself only with things relating
eral different file types, structures and prefixed by the numeric code 220. The to the application. This, of course, is the
transfer modes, but in practice FTP im- FTP client prompts you for your user- whole point of using a layered protocol
plementations recognise either text files name, which it then sends using the stack.
or binary files. Text files are converted FTP command “USER username”. The
from their native format to 7-bit ASCII server may respond with “331 Need Click here for the final part
with each line terminated by a car- password for username”. The client of this article
riage-return, line-feed pair for trans- detects this, prompts you for the pass-
mission. They are converted back to word and sends this to the server using
the native text file format by the FTP the command “PASS password”. If the
client. FTP therefore provides a cross- password is correct the client will re-
platform transfer mechanism for text ceive the response “230 Access
files. Binary files are transmitted ex- granted”. PCNA
actly as-is. The next thing you might do is type
Data is transferred as a continuous DIR, to list the current directory on the
stream of bytes. The TCP transport server. This command to the client re-
protocol provides all the reliability, sults in two FTP commands being is-
making sure that data that is lost is sued to the server. The first, “PORT
re-sent and checking that it is received x,x,x,x,y1,y2” tells the server the IP ad-
correctly. It is worth noting that error dress (x.x.x.x) and port number (y1 * The Author
detection uses a simple 16-bit check- 256 + y2) to use for the data connection. Julian Moss is a freelance writer
sum so the probability of undetected The port number is one in the range and software developer. The URL
errors is high compared to a file trans- 1024 to 4999, a range used for ephem- of his Web site is http://www.jm-
fer protocol like Zmodem which uses eral connections (those that are used tech.com/.
a 32-bit CRC. briefly for some specific purpose). The

File: C04100.12
PC Network Advisor Issue 91 (January 1998) Page 16
Recent Reviews from Tech Support Alert

Reviews of the Best Windows Backup Software


In this detailed comparative review, we checked out eighteen backup software
utilities designed for home or SOHO use. Many of the products reviewed
were disappointing. However 6 products passed our tests with flying colors
and 2 of these were so impressive, they were awarded our “Editor’s Choice.”

Suppliers of Cheap Inkjet Printer Cartridges Reviewed and Rated


With hundreds of companies all claiming to have the “cheapest and best inkjet
printer cartridges,” our editors decided to put their claims to the test. Not
unexpectedly, many suppliers flunked but we did manage to come up with a
number of web sites that sell good quality inkjet printer cartridges at heavily
discounted prices.

The Best Anti Trojan Software


Our editors took a close look at the 6 leading anti-trojan/trojan remover
software utilities. Unfortunately, they found only 2 products that were effective
in their ability to detect and remove dangerous modern polymorphic and
process injecting trojans.

The 46 Best Ever Freeware Utilities


This is our Editor, Ian “Gizmo” Richards, personal selection of the best
freeware utilities. He’s hunted down some real gems, many of which perform
better than expensive commercial products.

Tech Support Alert


http://www.techsupportalert.com

You might also like