// Making Voice and Data Compatible
//
// by dual_parallel
//
// http://www.oldskoolphreak.com

**************************************************************************
This is a transcription of a CXR Telcom paper, straight from a Qwest 
dumpster.  It teaches the basics of modulation and explains where many 
numbers in networking come from.  I've corrected errors and added a couple
of comments.
**************************************************************************

Digital computer data consists of 1's and 0's, already compatible with T1 
digital format.  Voice signals are complex analog waveforms that must be 
digitized to be compatible with T1.  The analog signal must be sampled often
enough to be recreated at the distant end, producing what sounds like the 
original conversation.  The analog wave is sampled at twice the highest 
frequency on the line.  The human voice produces understandable information
in the range of 300 to 3300Hz.  The phone company allocates 4000Hz (4kHz) 
per analog line, enough to filter crosstalk.  Therefore, 4000 cycle changes
per second (4kHz) x 2 (twice the highest frequency) = 8000 samples per 
second.  For the human voice to be accurately represented a sufficient 
number of bits must be used to create a digital word; 8 bits offers a 
sufficient number of different points.

Pulse Code Modulation (PCM)
---------------------------
PCM is a sampling process that compresses a conversation into a 64kb/s 
standard Digital Signal Level 0 (DS0).  There are 2 steps:

1. The incoming analog signal is sampled at 8000 times a second and converted
   to pulses using Pulse Amplitude Modulation (PAM).  [The amplitude of the 
   pulses conveys the information.]

2. Each pulse is assigned an 8-bit binary value (1 or 0).

64kb/s, DS0 rate is reached by multiplying the number of samplings per second
by the number of bits per sample.

8000 samples/second x 8 bits/sample = 64 kb/s

Once digitized, voice and data can be combined.  Time Division Multiplexing
(TDM) divides the T1 into 24 64kb/s time slots.  An identical number of DS0
signals representing data and voice is assigned to each slot.

Each group of 24 time slots is called a T1 Frame.  Each slot contains 8 bits
(7 bits and a least significant bit for signaling).  8 bits x 24 = 192 bits.
An additional bit is added for framing, for a total of 193 bits.

One Frame = 24 8-bit words (192kb/s) plus one framing bit (8kb/s)

DS0's are sampled at 8000 times/second.  8000 times 193 bits equals 
1.544Mb/s, a Digital Signal Level 1 (DS1).

[So, a T1 frame is sent every 0.000125 seconds, or 125 microseconds.]

AMI Format
----------
In Alternate Mark Inversion (AMI), the binary mark "1" is represented by a 
square wave. "0" is represented by a straight line.  Each pulse alternates 
between positive and negative.  This Bipolar format allows the signal to 
travel farther on a copper pair and offers some built in error detection.
When consecutive pulses with the same polarity are detected, a Bipolar 
Violation is created (BPV).  All DS1 signals must meet certain ones density 
(marks density) standards.  At least one pulse must be transmitted within any
8-bit sequence (12.5%).  Since long strings of 0's can affect timing, 
standards require that in every 24 bits of information, there must be at 
least three pulses and no more than 15 consecutive 0's.  A technique called 
pulse stuffing was used to overcome these conventions where every 8th bit was
stuffed with a 1.  This limited data rates to 56kbps (7 bit word [not 8] x 
8000samples per second per DS0).

B8ZS
----
Bipolar with 8-zero substitution (B8ZS) breaks up long strings of 0's.  The
CSU [Channel Service Unit - think of a CSU as a "modem" between a LAN and
a WAN] reads the 8 bit format, recognizes when a string of 8 zeros will 
cause problems and strips off the 8-bit byte and substitutes a fictitious 
byte.  When receiving equipment receives the DS1 signal, it recognizes the 
B8ZS pulses and replaces them with 0's.

Superframe Framing
------------------
A Superframe is made up of 12 individual frames.  The 193rd framing bit of 
each frame forms a 12-bit word to control frame and signal management.  To 
share the signaling bits in 12 frames, in a Superframe, D-4 framing uses 
Robbed Bit Signaling where the least significant (8th) bit of the DS0's in 
the 6th and 12th frames are used for signaling (on-hook, off-hook states).

ESF Framing
-----------
The Extended Superframe contains 24 193-bit frames.  Three-fourths of the 
control bits are used for evaluating circuit performance.  Six control bits 
are used for a Cyclic Redundancy Check (CRC).  Twelve bits are used as a data
link for communication between transmission and reception.  Six bits are used
to manage signaling and framing.

A CRC-6 is a 6-bit word that detects bit errors.  This 6-bit word is a 
calculation sent by the transmitter and compared with the same calculation at
the receiver.

A 4kbps overhead is set-aside for Facility Data Link (a synchronous 
communications channel).  A set of standard message formats is defined for 
communicating across the data link.  Some of the maintenance messages include
performance data reports, specific error events, historical information and 
error counts.