(1)  Extended note on the scope of Chapter 6

This chapter is only concerned with faxes transmitted over the PSTN
using the protocol as specified in ITU T.30.  Faxes sent in other
ways (notably using ISDN) are outside the scope of this book. The
terminology and abbreviations used in this chapter correspond almost
exactly to that used in the original T.30 document, and are accepted
worldwide as the jargon to be used when the fax session protocol is
being talked about.  It isn't to everyone's taste, but as this isn't
really a matter of choice, there's no point in apologising for it. We
cover here those portions of the recommendation that are common to
all fax machines.

However, the various additions and extensions (such as those that
deal with error correction) will be held over till the next chapter.

Inevitably, there are some areas where T.4 and T.30 overlap in a
somewhat arbitrary manner.  For instance, the range of speeds and
modulations which can be used to send a fax is defined in T.4, while
the procedures used to decide which of those available options is
actually going to be used in any particular session is part of T.30.
It is probably best to regard the division between the two as a
simple matter of convenience. Originally, the procedures defined in
T.30 were part of the T.4 recommendation, but the Series T
recommendations were renumbered during the 1970s.

It is worth pointing that although the T.30 protocol is something
that fax modem users can properly regard as simply a mechanism for
sending T.4 digital data, it also covers sending of Group 1 and Group
2 faxes.  Using these methods the fax data isn't digitally encoded at
all, but is sent in analogue form according to recommendations ITU
T.2 and T.3, Unlike Group 3 T.4 data, which can be seen as simply an
image broken down into dots which are either black or white, Group 1
and Group 2 faxes were able to transmit the level of blackness of an
image by varying the frequency of the tones transmitted.  These
techniques are mostly of historic interest today, and those parts of
the T.30 document that relate to them won't be discussed here.

Most of the T.30 specification relates to digital Group 3
transmissions.  It is quite a complicated document which is being
continually extended, and from its earliest days it has been
implemented in different ways by different companies.  It would be a
mistake to think that problems arising from conflicting
interpretations of a common document are restricted to manufacturers
of computer-based fax modems.  For example, manufacturers of switches
that automatically attempt to distinguish voice from fax on a shared
telephone line often look for the distinctive calling tone that fax
machines begin to send after they have dialled.  They have problems
with models that send so- called "silent" faxes that don't bother
with the calling tone.  Whether such machines conform to T.30 is
arguable.  The fact is that autodialling and autoanswering as a
standard feature on fax machines (and on data modems for that matter)
is something relatively new, and early models were only capable of
manual operation.  T.30 recognises this and allows for all possible
combinations of interworking between manual and automatic senders and
receivers.  While automatic machines are supposed to identify
themselves to human operators by means of the transmission of tones
with distinctive frequencies and cadence, these tones were not
conceived of as being essential to fax operation, but merely designed
"to clearly indicate to a normal telephone user that he is
inadvertently connected".  What is more, the ITU allowed for local
alternatives to these distinctive tones (T.30 section 3.1.4),
presumably for use in countries where their transmission might cause
problems with the telephone network.

Consequently, a number of manufacturers presumably decided to play
safe and brought out models that didn't send calling tones after
dialling.  These machines work perfectly well when sending to other
fax machines on dedicated lines, but sometime fail to work when
sending to fax machines connected to shared voice lines with
automatic switches.  The switch manufacturers would naturally blame
the fax manufacturer for making a machine that failed to implement
everything in the T.30 standard.  The fax manufacturer would equally
naturally retort that their machine was quite happy when sending to
other fax machines.  They would say that the fault must lie in
relying on a feature which was designed for use with manual operators
rather than automatic switches, and which in any case was a procedure
that that local telephone authorities were free to ignore.

The lesson to be learnt from all this is that you cannot please all of
the people all of the time.  It is natural to try and produce
software that will work with the widest possible range of equipment.
The most obvious strategy for doing this is to rely on backward
compatibility.  The assumption is that if you leave out all the non-
essential features you are bound to cater for the lowest common
denominator and your product will interwork with everything else.
However, where a particular non- essential feature comes to be one
that is relied on, this strategy falls over.  It is possible that if
you include the feature then your product will fail to work under one
set of conditions, while if you leave it out then your product will
fail to work with a different set.  A designer has to rely on his or
her judgement in such circumstances and hope that the buyer of the
product won't ever need to question what their decision happened to
be.

For instance, the T.30 recommendation not only includes the procedures
for sending Group 3 digital faxes using apparatus designed to conform
to T.4 specifications, but also covers faxes sent using the old
analogue methods used by Group 1 and Group 2 equipment, and fallback
from Group 3 to those earlier methods is a recognised T.30 option. In
the early days of Group 3 fax machines, backward compatibility was an
issue, and the publicity literature for machine which did implement
fallback to the earlier standard used to stress this fact.  However,
no fax modem with such facilities has ever been introduced, and its
lack of support has never been much of an issue.

A similar situation occurs with regard to the automatic operation of
faxes.  Early model fax machines often had no autodialling
facilities, and calls had to be set up by hand, with complicated
voice negotiations as to who would press which buttons at what time.
It is usual now for a fax machine to operate completely unattended,
and many machines don't even have telephone handsets any more.
Nevertheless, the T.30 recommendation includes a number of features
which are explicitly designed for using a fax machine with a human
operator rather than simply starting a fax off and leaving it to run
under microprocessor control.  Not only are such features not needed
with modern fax systems, but they are also completely inappropriate
when applied to faxes sent or received with a fax modem, where faxes
can be sent and received inaudibly and invisibly and then re-routed
over a network without any possibility of operator intervention.

For reasons such as these, only certain portions of the T.30
recommendation, notably those dealing with automated Group 3 fax, are
of real interest to us here, and coverage of other portions is
reduced to the bare minimum and is in some cases omitted altogether.

(2)  Short note on phase C1 and phase C2

The T.30 recommendation sometimes splits phase C into two
concurrent procedures, which is also an approach that might be found
in manufacturers' technical manuals.  The first of these is referred
to as phase C1 and concerns itself with in-message procedures such as
error detection and line supervision.  These activities are performed
concurrently with phase C2, which is solely concerned with the
transmission of the message data.  This distinction is one that is
difficult to see much use for, and in some respects it only serves to
confuse matters.  For instance, the use of the EOL code both as part
of message data and as a means of error detection is easy to
understand if phase C is seen as a unified whole, while it is
difficult to see exactly where it belongs if phase C is split.
Consequently, we will approach phase C here as one procedure rather
than two.

(3)  Short note on sending bits and sending characters

The essential difference between a character protocol and a bit
oriented one is best illustrated by considering the different ways
that they treat the bit pattern 01111110.  This is seen by HDLC as a
flag sequence no matter where it occurs in a data stream.  By
contrast, it is unlikely that any character based protocol would
bother to detect the pattern at all unless it happened to coincide
with a byte boundary.  If it did occur on a byte boundary it would
most commonly be interpreted as the tilde character ~, as 01111110 is
the binary representation of the decimal number 127, and the tilde is
character 127 in the standard ASCII character set.  However it would
be quite misleading to say that HDLC uses the ~ character as a flag,
or as any sort of control sequence, simply because it consists of the
same bit pattern that happens to match that character on an ASCII
chart.  When the ~ character is sent using a bit oriented protocol
(for instance as part of the information field within an HDLC frame)
it would have to be sent with bit stuffing, as the bit pattern
011111010.  The zero bit inserted on sending would be removed on
reception.  So while an application expecting the HDLC information
field to contain ASCII characters would be able to see the ~
character in its proper place, it would have been sent in a
completely different way to that which a character protocol would have
used.

(4)  Short note on the details of modulation schemes and of HDLC

Both the T.30 preamble and the T.30 frames are normally sent using
V.21 channel 2 modulation at a speed of 300 bps. 

However, the exact details of this modulation scheme, as well as all
the other modulations that can be used in fax transmissions, is
beyond the scope of this book, and knowledge of them doesn't really
help in understanding how to write fax software and control fax
modems.  

In contrast to this, while knowledge of the inner workings
of HDLC is not strictly necessary to program all fax modems, the type
of background in HDLC which we present here is a great help in
following the functioning of this part of the T.30 fax protocol, and
is especially helpful if class 1 modems are to be used.  In the years
since the first version of the T.30 fax session protocol newer
modulation schemes have emerged and there have been many improvements
in telecommunications.  Future versions of T.30 may well take the
opportunities offered by these developments to reduce substantially
the time taken preambling.  An option already exists to send faxes
using a full duplex modulation scheme.  Meanwhile, the half duplex
line turnaround is a phenomenon which people brought up on full
duplex data communications often find disconcerting.  While it may be
alarming to see NO CARRIER messages appear on a screen, or to see a
modem carrier detect light go off in the middle of a session, that's
the way that half duplex communications work.  Only one side of the
link can transmit at any one time, and in order to switch between
receive and transmit modes, the connection needs to be broken and
then re-established with the roles of each station reversed.  The
first frame transmitted after this line turnaround must always be
preceded by the same preamble used at the start of a fax session.

For our purposes, it is fortunate that the preamble and most of the
routine parts of HDLC are now looked after by dedicated synchronous
communications chips.  In much the same way as modern asynchronous
components take care of the details such as timings and the insertion
of start and stop bits, programmers today don't need to program their
own flags, or handle bit stuffing and zero-bit deletion, or calculate
their own CRCs.  Most of this is handled by the synchronous
communications hardware even in data-only modems, not just in fax
ones.

Users of class 1 fax modems have things even easier, as all anyone who
want to send a frame needs to do is tell the modem what the contents
should be using normal 8-bit asynchronous bytes.  Conversion to
synchronous format by deletion of start and stop bits as well as
zero-bit insertion, the addition of flags, and CRC calculations, are
all handled by the firmware in the modem.  In a similar fashion, to
receive a frame all one needs to do is to tell the modem to wait for
one.  Not only will it detect the opening and closing flag and
deliver the data in between, but the class 1 firmware will even
calculate its own CRC, compare it with the FCS field at the end of
the frame, and tell you with a standard OK modem result code if the
two matched or if there was an error.

Users of class 2 and similar modems can operate at an even higher
level, where even the fact that HDLC frames are being exchanged is
hidden from the applications software (unless the modem is forced
into a debug mode).  If everything always worked perfectly then it
might be reasonable to question the need for knowing about the
structure of an HDLC frame.  However, the devil is in the detail.  A
manual analysis of the frames sent as part of the T.30 negotiations
is one of the first things th0at you need to look in situations
whenever a fax session keeps on failing at a particular point.

(5)  Short note the HDLC address octet, for pedants.

Since all frames are sent with the flags protected by bit stuffing,
this 8-bit address field is always sent as the 9-bit sequence
11111011, with the receiver discarding the 0 bit.

(6)  Short note on CRCs

The frame checking used in HDLC frames is a form of cyclic
redundancy checking, commonly known as a CRC.  This type of check is
a highly accurate way of detecting whether there was any corruption
in the frame.  The HDLC version has a good claim to be one of the
grandparents of all CRCs, and uses the generator polynomial
X16+X12+X5+1, which is part of yet another standard.  The theory of
CRC calculations is an area that is beyond the scope of this book. It
isn't necessary to know anything about them to program a fax modem
properly.  Even if you wanted to, checking the accuracy of a CRC
calculation is not something that can be done with a pocket
calculator in any case.  Though it's quite common for communications
books like this one to include pages after page of learned
discussions on CRCs and polynomials, most programmers who need to use
them are quite happy to use a working chunk of code from a reliable
source and get on with the job.  The important facts are firstly, that
the FCS is the last field in the frame, secondly, that it is used to
ensure the integrity of all the data in the frame, and thirdly, that
it must always be followed by the final flag.

(7)  Extended note on timeout T1

The references to timer T1 and its relationship to phases A and B in
the in the original documentation are far from clear.  The T.30 flow
charts indicate that the CNG tone should be being repeated until
timer T1 elapses as described above, and the recommendation is clear
that transmission of the CNG and CED tones are part of phase A.  This
would seem to imply that T1 is a phase A timeout.  However, a
different part of the text is equally clear that T1 begins counting
down only on entry to phase B, and affects how long two stations will
continue to try and identify each other.

The explanation of this apparent contradiction is that phase B is
defined as beginning once capability identification passes from the
answering station to the calling station.  Therefore, the situation
in which we would want to apply timeout T1 is one in which the
answering station is sending out its capabilities, but the caller
isn't receiving them.  In this situation, the caller would still be
sending out its CNG tones in phase A, while the receiver would have
been going back to phase A and repeating its entry to phase B in the
hope of a response.  This is why timer T1 can be referred to as
applying both to phase A and to phase B, since in the first case it
applies to a caller and in the second case it applies to an answerer.

There is no clear statement in the T.30 recommendation of the maximum
time allowed for phase A to complete.  A common belief is that a fax
session must begin within approximately 35 seconds of dialling, and
if this time limit is exceeded then the caller must hang up.  Since
some international calls can take well in excess of 40 seconds to
connect to their destination, this interpretation can severely
restrict the places to which a fax can be sent.  It appears to be
based on a misapplication of the T1 timer which we have just
described.  However, T1 is only one of the timeouts that might be
needed for controlling the start of a fax session.  There are at
least four of these that might be set.

i.  A time-out defining the maximum time from dialling to a telephone
network connection being made.  This is reset when the phone at the
remote end begins to ring.  On a local call this time will be short,
but on an intercontinental call it can be quite long.  However, if no
ringing tone is detectable at all, at some point a decision must be
made to cancel the attempt and try again.

ii.  A time-out used to control the time taken from the remote phone
beginning to ring to the call to being answered.  The point at which
this is reset can vary with the settings used on any particular fax
machine for the number of rings allowed before answering.  However,
some provision needs to be made for the case where the fax machine
isn't working, when the phone will just carry on ringing.

iii.  A time-out is needed to limit the time taken from the call being
answered to the two fax machines beginning their negotiations.

iv.  A maximum time might also be defined for the completion of the
T.30 negotiations.  The last of these would clearly be part of Phase
B and need not concern us right now.  It is equally clear that the
third one is the 35 - 40 second timer T1.  However, this should not
be used until the call has actually been answered and is not supposed
to include the first two timeouts we have identified.  This presents
us with a problem.  On virtually all AT compatible modems, including
all class 1 and class 2 fax modems, the total time from the end of
dialling to the return of a response code indicating that a
connection of some sort has been established is controlled by a
single timer.  This is set from register S7 and its value can be from
1 - 255 seconds, with a common default of 50 seconds.  Once this
period of time has elapsed the modem responds with either "NO ANSWER"
or "NO CARRIER", depending on the model and the way the result codes
have been set up.  There is consequently no way of setting three
different timers, one to operate from dialling to hearing a ring, one
from ring to call answer and the last one to be equivalent to the T1
timer and to operate from call answer to the modem telling us that a
connection has been made.

We therefore have to use one combined timer for all these phases, and
it should clearly not be set as short as 35  5 seconds. However,
while the first two timeouts are quite definitely part of phase A,
there is no official statement of how they should be set. The ITU now
informally recommend that the first of these timers, used to
determine at what point we decide a call isn't going to be answered,
should allow for dialling delays of up to 90 seconds.  My own
experience indicates that once a phone starts to ring, a fax machine
that hasn't picked up the line inside 5 seconds is unlikely to do so
at all.  Therefore the combined timer in register S7 on a fax modem
should be set at around 135 seconds.

Obviously this figure is a maximum for international calls using
complex routes over multiple satellites, microwave links and cables.
A wait of over two minutes to detect that a call from one side of a
city to another had failed would be rather excessive.  Indeed,
waiting for that length of time is a good enough reason for a modem
to fail the approvals test procedures in some European countries.  In
the United Kingdom modems are prohibited for use on the PSTN if they
allow register S7 to be set to a value greater than 58 seconds.  This
is a good example of the mess that arises when local regulatory
authorities fail to keep their requirements in touch with ongoing
developments in telecommunications.  In the absence of a specified
timeout from the ITU, implementors should use their own judgement
wherever possible.

(8)  Short note on deliberately sending ASCII data backwards

Of course, while asynchronous data usually is transmitted LSB
first, this process is something that is usually transparent to use,
and it therefore seems distinctly odd to have to reverse an ASCII
byte before sending it as part of a frame.  It seems even odder to
have to send the character string itself backwards, and this
procedure would only be familiar to ancient programmers who used to
have to reverse all the characters in alternate lines that they were
sending to a printer when they wanted to make it print
bidirectionally.

(9)  Extended note with the complete list of NSF current country codes

To date, 197 out of the 256 possible codes in one single octet have
already been defined.  The following is the current list of country
codes.  It has clearly not kept up with recent political
developments.  You may also notice the political content of the list.
There is something surreal about the concept of British and French
Antarctica having codes reserved for their domestic fax machine
manufacturers.  Presumably, code 255 is reserved for expansion when
the number of ITU members entitled to a code exceeds the number
available.

Ŀ
0  Japan                                                 
1  Albania                                               
2  Algeria                                               
3  American Samoa                                        
4  Germany (formerly FDR)                                
5  Anguilla                                              
6  Antigua and Barbuda                                   
7  Argentina                                             
8  Ascension (see S. Helena)                             
9  Australia                                             
10 Austria                                               
11 Bahamas                                               
12 Bahrain                                               
13 Bangladesh                                            
14 Barbados                                              
15 Belgium                                               
16 Belize                                                
17 Benin                                                 
18 Bermudas                                              
19 Bhutan                                                
20 Bolivia                                               
21 Botswana                                              
22 Brazil                                                
23 British Antarctic Territory                           
24 British Indian Ocean Territory                        
25 British Virgin Islands                                
26 Brunei Darussalam                                     
27 Bulgaria                                              
28 Myanmar                                               
29 Burundi                                               
30 Byelorussia                                           
31 Cameroon                                              
32 Canada                                                
33 Cape Verde                                            
34 Cayman Islands                                        
35 Central African Republic                              
36 Chad                                                  
37 Chile                                                 
38 China                                                 
39 Colombia                                              
40 Comoros                                               
41 Congo                                                 
42 Cook Islands                                          
43 Costa Rica                                            
44 Cuba                                                  
45 Cyprus                                                
46 Czech and Slovak Federal Republic                     
47 Cambodia                                              
48 Korea (North)                                         
49 Denmark                                               
50 Djibouti                                              
51 Dominican Republic                                    
52 Dominica                                              
53 Ecuador                                               
54 Egypt                                                 
55 El Salvador                                           
56 Equatorial Guinea                                     
57 Ethiopia                                              
58 Falkland Islands                                      
59 Fiji                                                  
60 Finland                                               
61 France                                                
62 French Polynesia                                      
63 French Southern and Antarctic Lands                   
64 Gabon                                                 
65 Gambia                                                
66 Germany (formerly DDR)                                
67 Angola                                                
68 Ghana                                                 
69 Gibraltar                                             
70 Greece                                                
71 Grenada                                               
72 Guam                                                  
73 Guatemala                                             
74 Guernsey                                              
75 Guinea                                                
76 Guinea-Bissau                                         
77 Guayana                                               
78 Haiti                                                 
79 Honduras                                              
80 Hongkong                                              
81 Hungary                                               
82 Iceland                                               
83 India                                                 
84 Indonesia                                             
85 Iran                                                  
86 Iraq                                                  
87 Ireland                                               
88 Israel                                                
89 Italy                                                 
90 Ivory Coast                                           
91 Jamaica                                               
92 Afghanistan                                           
93 Jersey                                                
94 Jordan                                                
95 Kenya                                                 
96 Kiribati                                              
97 Korea (South)                                         
98 Kuwait                                                
99 Lao                                                   
100Lebanon                                               
101Lesotho                                               
102Liberia                                               
103Libya                                                 
104Liechtenstein                                         
105Luxemborg                                             
106Macao                                                 
107Madagascar                                            
108Malaysia                                              
109Malawi                                                
110Maldives                                              
111Mali                                                  
112Malta                                                 
113Mauritania                                            
114Mauritius                                             
115Mexico                                                
116Monaco                                                
117Mongolia                                              
118Montserrat                                            
119Morocco                                               
120Mozambique                                            
121Nauru                                                 
122Nepal                                                 
123Netherlands                                           
124Netherlands Antilles                                  
125New Caledonia                                         
126New Zealand                                           
127Nicaragua                                             
128Niger                                                 
129Nigeria                                               
130Norway                                                
131Oman                                                  
132Pakistan                                              
133Panama                                                
134Papua New Guinea                                      
135Paraguay                                              
136Peru                                                  
137Philippines                                           
138Poland                                                
139Portugal                                              
140Puerto Rico                                           
141Qatar                                                 
142Romania                                               
143Rwanda                                                
144Saint Kitts and Nevis                                 
145Saint Croix                                           
146Saint Helena and Ascension                            
147Saint Lucia                                           
148San Marino                                            
149Saint Thomas                                          
150Sao Tome and Principe                                 
151Saint Vicent and the Grenadines                       
152Saudi Arabia                                          
153Senegal                                               
154Seychelles                                            
155Sierra Leone                                          
156Singapore                                             
157Solomon Islands                                       
158Somalia                                               
159South Africa                                          
160Spain                                                 
161Sri Lanka                                             
162Sudan                                                 
163Suriname                                              
164Swaziland                                             
165Sweden                                                
166Switzerland                                           
167Syria                                                 
168Tanzania                                              
169Thailand                                              
170Togo                                                  
171Tonga                                                 
172Trinidad and Tobago                                   
173Tunisia                                               
174Turkey                                                
175Turks and Caicos Islands                              
176Tuvalu                                                
177Uganda                                                
178Ukraine                                               
179United Arab Emirates                                  
180United Kingdom                                        
181United States                                         
182Burkina Faso                                          
183Uruguay                                               
184U.S.S.R.                                              
185Vanuatu                                               
186Vatican City State                                    
187Venezuela                                             
188Viet Nam                                              
189Wallis and Futuna                                     
190Western Samoa                                         
191Yemen (formerly Yemen Arab Republic)                  
192Yemen (formerly People's Democratic Republic of Yemen)
193Yugoslavia                                            
194Zaire                                                 
195Zambia                                                
196Zimbabwe                                              
255Reserved for further study                            


(10)  Short note on allowing for 28800 bps fax

The recent V.34 standard for 28800 bps data transmission includes a
half duplex version of the standard for fax.  The T.30 recommendation
will certainly be revised to take account of the new standard, but it
is not yet decided which of the unused combinations in the above
table it will use.

(11)  Short note on the frames in the initial identification sequence

If you look closely at the command to receive and the command to send,
it is clear that they all share a common format.  They all have a
compulsory capability frame using virtually the same bit fields to
identify which of the T.4 options will be used in the session.  This
can be preceded by two optional frames, one carrying an
identification string in backwards ASCII with the other reserved for
non-standard extensions.  The similarity extends to the FCFs that
accompany the frames.  All three of the frames carrying capabilities
and options have the last four bits of the FCF set to 0001. All the
frames carrying identification strings all have their FCFs ending in
0010, while all the frames which relate to non-standard extensions
use 0100 as the last four bits in their facsimile control field.

(12)  Short note on timeout T4

The timeout used to ensure that all responses to commands must be
received within 3 sec  15% is occasionally referred to as T4 in the
T.30 recommendation, as on the 5.2E/T.30 flowchart and figure
A-6/T.30.  I once found out the perils of ignoring this, when testing
out sending to a receiver with a slow printing mechanism.  I knew it
had properly received a fax page together with a post-page message
command, but it kept on disconnecting.  What was happening was that
it had not been acknowledging immediately because it was busy feeding
the paper and cutting it off the roll.  However, once it has done
this and got round to servicing the post-page command, it noticed
that although a post-message command was received, it was more than
three seconds ago, and I had not repeated it. The receiver was
therefore quite entitled to disconnect the line on the grounds that
the transmitter should have repeated it.

(13)  Short note on setting apparently non-optimized parameters

It is usual to allow a user to opt to do this.  For example, they
should be allowed to send or receive only normal resolution faxes
even when both they and the station to which they are connected both
have the capability for high resolution. This recognizes that there
is always a trade-off between the time taken to send a fax and the
resolution of the output.  While the benefits from faxing a page from
a newspaper at high resolution generally outweigh the extra
transmission costs, this isn't necessarily the case when faxing a
handwritten memo scrawled on a sheet of paper.

