Professional Documents
Culture Documents
21-2006
American National Standard
--`,,```,,,,````-`-`,,`,,`,`,,`---
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^
--`,,```,,,,````-`-`,,`,,`,`,,`---
ANSI C12.21-2006
Revision of
C12.21-1999
Secretariat:
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
ANSI C12.21-2006
NEMA has no power, nor does it undertake to police or enforce compliance with the contents of this
document. NEMA does not certify, test, or inspect products, designs, or installations for safety or health
purposes. Any certification or other statement of compliance with any health or safetyrelated
information in this document shall not be attributable to NEMA and is solely the responsibility of the
certifier or maker of the statement.
ANSI C12.21-2006
AMERICAN
NATIONAL
STANDARD
Published by
--`,,```,,,,````-`-`,,`,,`,`,,`---
i
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
ANSI C12.21-2006
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
--`,,```,,,,````-`-`,,`,,`,`,,`---
ii
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
ANSI C12.21-2006
Contents
Page
1
2
3
Scope...................................................................................................................................................... 1
References ............................................................................................................................................. 1
Definitions and Syntax............................................................................................................................ 1
3.1 Definitions ....................................................................................................................................... 1
3.1.1 C12.21 Client.......................................................................................................................... 1
3.1.2 C12.21 Device........................................................................................................................ 2
3.1.3 Table....................................................................................................................................... 2
3.2 Document Syntax ........................................................................................................................... 2
4 Protocol Details ...................................................................................................................................... 2
4.1 Order of Transmission .................................................................................................................... 2
4.2 Layer 7 - Application Layer............................................................................................................. 3
4.2.1 Data Structure ........................................................................................................................ 3
4.2.2 Protocol Specification for Electric Metering ........................................................................... 3
4.2.2.1 Request Codes ......................................................................................................... 3
4.2.2.2 Response Codes....................................................................................................... 4
4.2.2.3 Identification Service ................................................................................................. 5
4.2.2.4 Read Service............................................................................................................. 9
4.2.2.5 Write Service ............................................................................................................. 9
4.2.2.6 Logon Service ........................................................................................................... 9
4.2.2.7 Security Service ........................................................................................................ 9
4.2.2.8 Logoff Service ........................................................................................................... 9
4.2.2.9 Authenticate Service ............................................................................................... 10
4.2.2.10 Negotiate Service .................................................................................................... 11
4.2.2.11 Wait Service ............................................................................................................ 11
4.2.2.12 Terminate Service ................................................................................................... 11
4.2.2.13 Timing Setup Service .............................................................................................. 11
4.2.2.14 Disconnect Service ................................................................................................. 12
4.3 Layer 6 - Presentation Layer ........................................................................................................ 12
4.4 Layer 5 - Session Layer................................................................................................................ 12
4.5 Layer 4 - Transport Layer ............................................................................................................. 12
4.6 Layer 3 - Network Layer ............................................................................................................... 12
4.7 Layer 2 - Data Link Layer ............................................................................................................. 13
4.7.1 Basic Data Information ......................................................................................................... 13
4.7.1.1 Fixed Settings.......................................................................................................... 13
4.7.1.2 Variable Settings ..................................................................................................... 13
4.7.2 Packet Definition .................................................................................................................. 13
4.7.3 Duplicate Packets................................................................................................................. 15
4.7.4 CRC Selection...................................................................................................................... 15
4.7.5 Acknowledgment .................................................................................................................. 15
4.7.6 Retransmission..................................................................................................................... 16
4.7.7 Time-out ............................................................................................................................... 16
4.7.7.1 Channel Traffic Time-out......................................................................................... 16
4.7.7.2 Inter-Character Time-out......................................................................................... 16
4.7.7.3 Response Time-out................................................................................................. 16
4.7.8 Turn-around Delay ............................................................................................................... 16
4.7.9 Collision................................................................................................................................ 16
4.8 Layer 1 - Physical Layer ............................................................................................................... 16
5 Compliance........................................................................................................................................... 16
Annex A - Communication Example (Layer 7 and Layer 2) ....................................................................... 18
Annex B - Packet Transmission Example................................................................................................... 20
Annex C - Service Sequence State Control................................................................................................ 22
Annex D - Modifications and Extensions to C12.19- 1997 ......................................................................... 24
--`,,```,,,,````-`-`,,`,,`,`,,`---
iii
Not for Resale
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
ANSI C12.21-2006
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
--`,,```,,,,````-`-`,,`,,`,`,,`---
iv
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
ANSI C12.21-2006
It is expected that the Logoff Service will become mandatory in the next revision of this Standard.
Implementers are strongly encouraged to support this service to comply with this change.
Suggestions for improvement to this Standard are welcome. They should be sent to:
National Electrical Manufacturers Association
Vice President of Engineering
1300 North 17th Street
Suite 1752
Rosslyn, VA 22209
This Standard was processed and approved for submittal to ANSI by Accredited Standards Committee
for Electricity Metering C12. At the time the committee approved this Standard, the C12 Committee had
the following members:
Tom Nelson, Chairman
Paul Orr, Secretary
Michael Anderson
Ed Beroset
Ron Breschini
Curt Crittenden
David Ellis
Cruz Gomez
Bob Hughes
Lawrence Kotewa
Francis Marta
John McEvoy
Herman Millican
James Mining
Avygdor Moise
Tim Morgan
Roy Moxley
D. Young Nguyen
Lauren Pananen
Aaron Snyder
Richard Tucker
Scott Weikel
v
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
ANSI C12.21-2006
vi
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
--`,,```,,,,````-`-`,,`,,`,`,,`---
ANSI C12.21-2006
2 References
ANSI C12.18, Protocol Specification for ANSI Type 2 Optical Port
ANSI C12.19, Utility Industry End Device Data Tables
ANSI INCITS 92-1981 (R2003), Data Encryption Algorithm
ISO/IEC 7498-1 (1994), Information Technology - Open Systems Interconnection - Basic Reference
Model: The Basic Model
ISO/IEC 8825-1 (2002), Information Technology - ASN.1 Encoding Rules: Specification Of Basic
Encoding Rules (BER), Canonical Encoding Rules (CER) And Distinguished Encoding Rules (DER)
ISO/IEC 13239 (2002), Information Technology - Telecommunications And Information Exchange
Between Systems - High-Level Data Link Control (HDLC) Procedures
3.1 Definitions
For the purposes of this Standard, the following definitions are made.
3.1.1
C12.21 Client
An electronic communication apparatus that connects to a C12.21 Device via a modem and implements
communication according to the protocol specification of this Standard. This was implicitly defined in
previous versions as utility host.
--`,,```,,,,````-`-`,,`,,`,`,,`---
ANSI C12.21-2006
3.1.2
C12.21 Device
An electronic communication apparatus (e.g., a meter plus an internal or external modem) that
implements communication according to the protocol specification of this Standard. This was implicitly
defined in previous versions as meter.
3.1.3
Table
Functionally related data elements, grouped together into a single data structure for transport as defined
by ANSI C12.19.
3.2 Document Syntax
Document syntax is identical to that of ANSI C12.18.
4 Protocol Details
Following the guidelines established by the OSI seven-layer model, the protocol described in this
Standard provides three (3) functions:
1) Establishment and modification of the communication channel
2) The transport of information to and from the C12.21 Device
3) Orderly closure of the communication channel when communications are complete
This Standard does not specify the implementation requirements of the telephone switched network to
the modem, nor does it include definitions for the establishment of the communication channel. The
communication channel is considered available once the telephone connection has been successfully
established and modems have synchronized. The PSEM Identification Service is required to establish
the protocol version and revision in use. Certain communication parameters may be modified through the
use of the PSEM Negotiate and Timing Setup services in the Application Layer. These services are
optional, and if not implemented in the C12.21 Device or not used during actual communications, the
communication channel parameters will remain at the default settings specified by this Standard.
Implementers are strongly encouraged to implement these optional Application Layer services.
Once the data link is established, the Application Layer provides:
Logon, Security and Logoff services for session activation, access control and deactivation
Read Service and Write Service for issuing data transmission requests
Authenticate Service for two way authentication with playback rejection
Terminate Service for returning to the Base State
Disconnect Service for shutdown of the communication channel
A response structure that provides information regarding the success or failure of the service
requests.
An example of a typical communications session would consist of the following services with appropriate
responses, in the order listed: Identification, Negotiate, Logon, Authenticate, Security, Reads or Writes,
Logoff and Disconnect. Note that this brief example does not detail the packet structure or other aspects
of the protocol. A more detailed example of a typical communications session is given in Annex A,
Communication Example.
4.1 Order of Transmission
Order of transmission is identical to that specified in ANSI C12.18.
2
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
--`,,```,,,,````-`-`,,`,,`,`,,`---
Three (3) layers are used to provide these communication capabilities, the Physical, Data Link and
Application layers.
ANSI C12.21-2006
--`,,```,,,,````-`-`,,`,,`,`,,`---
Data Structure
This protocol shall transport Table structures. The Table specifications this Standard was designed to
transport are referenced in Section 2, References, and Annex D Modifications and Extensions to
C12.19-1997, of this document.
4.2.2
This Standard defines twelve (12) Protocol Specification for Electric Metering (PSEM) services. Each
service consists of a request and a response. Each of these requests and responses is described in the
following service sections.
::= <ident> |
<read> |
<write> |
<logon> |
<security> |
<logoff> |
<negotiate> |
<wait> |
<terminate> |
<timing-setup> |
<disconnect> |
<authenticate>
<responses>
::= <ident-r> |
{*
<read-r > |
{
<write-r > |
{
<logon-r > |
{
<security-r> |
{
<logoff-r > |
{*
<negotiate-r > | {
<wait-r > |
{
<terminate-r > | {*
<timing-setup-r> |{**
<disconnect-r> | {**
<authenticate-r> {**
Note:
4.2.2.1
*
**
{
{
{
{
{
{*
{
{
{*
{**
{**
{**
PSEM requests always include a one-byte request code. Code numbers are represented in hexadecimal
format as follows:
00H-1FH
20H-7FH
3
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
<requests>
ANSI C12.21-2006
80H-FFH
4.2.2.2
Response Codes
PSEM responses always include a one-byte response code. Response codes are identical to those
specified in ANSI C12.18. These codes are listed below in a suggested order of priority. When more
than one (1) response code is capable of indicating the error response condition of a C12.21 Device or a
C12.21 Client, the response code having the highest priority (from left to right) is as follows:
<nok>
::= <sns>|<isss>|<iar>|<isc>|<onp>|<bsy>|<dlk>|<dnr>|<rno>|<err>
For example, if Standard Table 05 of a C12.21 Device is read-only and it is encoded in non-volatile
memory then a Write Service request to Table 05 would fail. The C12.21 Device may consider the
following codes as suitable responses: <err> to indicate an error condition or <dlk> to indicate that the
data is locked in memory and cannot be changed, <iar> to indicate that the action requested was not
appropriate for this device design or <isc> to indicate that the table access permission are read-only
under the current security policy. The correct response would be <iar> as it is the highest priority among
<iar>, <isc>, <dlk> and <err>. However, if there is a mechanism for providing write access to Table 05,
then <iar> should not be considered. Therefore, the response code becomes <isc>.
<ok>
::=
00H
{Acknowledge
Application Layer response
indicating no problems, request
accepted.}
<err>
::=
01H
{Error
This Application Layer error code is
used to indicate rejection of the
received service request. The
reason for the rejection is not
provided.}
<sns>
::=
02H
<isc>
::=
03H
<onp>
::=
04H
<iar>
::=
05H
--`,,```,,,,````-`-`,,`,,`,`,,`---
ANSI C12.21-2006
--`,,```,,,,````-`-`,,`,,`,`,,`---
<bsy>
::=
06H
{Device Busy
This Application Layer error
indicates that the request was not
acted upon because the device was
busy doing something else.}
<dnr>
::=
07H
<dlk>
::=
08H
{Data Locked
This Application Layer error
indicates that the request was
unsuccessful because the data cannot
be accessed.}
<rno>
::=
09H
{Renegotiate Request
This Application Layer error
indicates that the responding device
wishes to return to the ID or base
state and renegotiate communication
parameters.}
<isss>
::=
0AH
0BH-1FH
20H-7FH
80H-FFH
4.2.2.3
Identification Service
The Identification Service shall be the first service issued upon C12.21 Device power-up, following a
PSEM Terminate Service response, or Channel Traffic Time-out. The Identification Service returns a
code identifying the reference standard, the version and revision of the reference standard implemented,
and an optional feature list. Since the Identification Service is always issued prior to the Negotiate
Service, the size of the returned response shall never exceed the default packet size.
The Identification Service is a required service.
The Identification Service shall be initiated only by a C12.21 Client.
5
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
ANSI C12.21-2006
Request:
<ident>
::= 20H
Response:
The responses <isss>, <bsy>, and <err> indicate a problem with the received service request.
The response <ok> indicates the identification service request was accepted and the standard, version,
revision and optional feature list are included in the response.
<ident-r>
<std>
::= <byte>
<ver>
::= <byte>
<rev>
::= <byte>
<feature>
<end-of-list>
::= 00H
<auth-ser>
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
<auth-type>
::= <byte>
<auth-alg-id>
::= <byte>
6
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
--`,,```,,,,````-`-`,,`,,`,`,,`---
ANSI C12.21-2006
<ticket>
::= <byte>+
<device-class>
<universal-id>
7
--`,,```,,,,````-`-`,,`,,`,`,,`---
ANSI C12.21-2006
<uid-length>
::= <byte>
<absolute-uid>
::= <byte>+
<relative-uid>
::= <byte>+
<identity>
::= <char-format><identification>
{Provides for disclosure of the
C12.19 Device identification.}
<char-format>
::= <byte>
8
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
--`,,```,,,,````-`-`,,`,,`,`,,`---
<identity-length>
ANSI C12.21-2006
<identification>::= <byte>*
4.2.2.4
Read Service
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
Write Service
Logon Service
Security Service
Logoff Service
The Logoff Service provides for an orderly shutdown of the session established by the Logon Service.
The Logoff Service is a required service.
--`,,```,,,,````-`-`,,`,,`,`,,`---
ANSI C12.21-2006
Request:
Following a Logoff Service request, the communication channel will return to the ID State, retaining the
parameters previously established.
<logoff>
::= 52H
Response:
The responses <isss>, <bsy>, and <err> indicate a problem with the received Logoff Service request.
The response <ok> indicates the acceptance of the Logoff Service and the cessation of the session
established by the Logon Service. Prior to further data transfers with the C12.21 Device, the Logon
Service must be reissued.
<logoff-r>
4.2.2.9
::=
Authenticate Service
The Authenticate Service is used to provide a two-way authentication with playback rejection during a
session. It is recommended that the Authentication Service be used to complement the Security Service,
not be used exclusively. The contents of the <auth-request> and <auth-response> fields are a function of
the authentication algorithm used. This algorithm is returned by the Identification Service response.
The Authenticate Service is an optional service.
<authenticate>
<auth-req-length>
::= <byte>
<auth-request>
::= <byte>+
Response:
The responses <sns>, <isss>, <bsy>, and <err> indicate a problem with the received Authenticate
Service request.
The response <isc> indicates the authentication failure of the requester.
The response <ok> indicates the Authenticate Service was successfully completed and the access
permission associated with the <auth-request> field was granted.
<authenticate-r>
<auth-res-length>
::= <byte>
<auth-response>
::= <byte>+
10
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
--`,,```,,,,````-`-`,,`,,`,`,,`---
Request:
ANSI C12.21-2006
4.2.2.10
Negotiate Service
The Negotiate Service is identical to that in ANSI C12.18. However, the <baud-rate> field of the request
shall be ignored because in this Standard the data rate is established by the modem.
The Negotiate Service is an optional service.
4.2.2.11
Wait Service
Terminate Service
The Terminate Service provides for immediate transfer to the Base State. All parameters return to their
default values.
The Terminate Service is an optional service.
Request:
<terminate>
::= 21H
The responses <sns> and <err> indicate a problem with the received Terminate Service request and the
channel retains its negotiated settings.
The response <ok> indicates the Terminate Service request was accepted and the channel will return to
default settings as stated in Section 4.7.1.2, Variable Settings, upon receipt of a positive
acknowledgment.
<terminate-r>
The Timing Setup Service provides the mechanism for reconfiguring time-outs, delays and retry attempts
from the default values specified in this Standard.
The Timing Setup Service is an optional service.
The Timing Setup Service is initiated by the C12.21 Client.
Request:
<timing-setup>
<traffic>
::= <byte>
<inter-char>
::= <byte>
{Inter-character time-out in
seconds}
<resp-to>
::= <byte>
11
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
4.2.2.13
--`,,```,,,,````-`-`,,`,,`,`,,`---
Response:
ANSI C12.21-2006
<nbr-retries>
::= <byte>
Response:
The responses <sns>, <isss>, <bsy>, and <err> indicate a problem with the received Timing Setup
Service request and the timer parameters will maintain their current settings.
The response <ok> indicates the Timing Setup Service request was accepted and the new settings now
apply. The data following the <ok> indicates the setting that will apply upon positive acknowledgment.
<timing-setup-r> ::= <sns> | <isss> | <bsy> | <err> |
<ok><traffic><inter-char><resp-to><nbr-retries>
4.2.2.14
Disconnect Service
The Disconnect Service is used for immediate disconnection of the communication channel.
Request:
The Disconnect Service should be used for reasons such as excessive errors, security issues, internal
error conditions, end of session, or other reasons.
<disconnect>
::= 22H
Response:
The responses <sns> and <err> indicate a problem with the received Disconnect Service request and the
channel remains open.
The response <ok> indicates the Disconnect Service request was accepted and the channel will be
disconnected.
<disconnect-r>
--`,,```,,,,````-`-`,,`,,`,`,,`---
12
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
ANSI C12.21-2006
--`,,```,,,,````-`-`,,`,,`,`,,`---
For each packet received, a positive or negative acknowledgment is sent by the target. This
acknowledgment consists of a single byte transmitted outside of the packet structure. If the requester
does not receive an acknowledgment before the Response Timeout, or a negative acknowledgment is
received, the same packet is retransmitted up to the current maximum number of negotiated retry
attempts. After the final retry attempt, the requester should assume termination has occurred.
4.7.1
Fixed Settings
DATA TYPE
DATA RATE
4.7.1.2
Variable Settings
Default settings apply at the initiation of communication. Most settings may be changed through the
Negotiate Service and the Timing Service. Channel settings will return to defaults as a result of the
Terminate Service or Channel Traffic Time-out.
Setting
Default Value
Changed by
NUMBER OF PACKETS
Negotiate Service
PACKET SIZE
64 bytes
Negotiate Service
30 seconds
INTER-CHARACTER TIMEOUT
1 second
RESPONSE TIMEOUT
4 seconds
RETRY ATTEMPTS
Packet Definition
<packet>
::= <stp><identity><ctrl><seq-nbr><length><data><crc>
<stp>
::= EEH
<identity>
::= <byte>
13
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
4.7.2
ANSI C12.21-2006
::= <byte>
{Control field.
Bit 7. If true (01H) then this
packet is part of a multiple packet
transmission.
Bit 6. If true (01H) then this
packet is the first packet of a
multiple packet transmission, and
Bit 7 shall also be true.
Bit 5. Represents a toggle bit to
reject duplicate packets. This bit
shall be toggled for each new packet
sent. Retransmitted packets keep
the same state as the original
packet sent. It should be noted
that the initial state of the toggle
bit is not specified and could
initially be zero (0) or one (1).
--`,,```,,,,````-`-`,,`,,`,`,,`---
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
0 to 1: DATA_FORMAT
C12.18 or C12.21
C12.22
Reserved
Reserved
::= <byte>
14
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
ANSI C12.21-2006
::= <word16>
<data>
::= <byte>*
<crc>
::= <lsbyte><msbyte>
4.7.3
Duplicate Packets
A duplicate packet is defined as a packet whose identity, toggle bit and valid CRC are identical to those of
the immediate previous packet. If a duplicate packet is received by the target device, the target shall
disregard the duplicate packet and return an <ack>. At the start of session, the toggle bit in the first
packet may assume either state.
4.7.4
CRC Selection
16
12
5
The CRC selected for implementation is the CCITT CRC standard polynomial X + X + X + 1. The
method for calculation and insertion is the HDLC standard per ISO/IEC 13239 (2002) Annex A.
In the PSEM frame, there is no opening flag as referenced in ISO/IEC 13239 (2002) Annex A. The PSEM
start of packet character EEH is included in the CRC calculation. The result of the CRC calculation shall
be transmitted least significant byte first per the ISO/IEC 13239 Annex A. See Annex E - CRC Examples
for examples of computation and coding.
4.7.5
Acknowledgment
::= 06H
A <nak> shall be issued by the receiving device to the transmitting device for each packet received that
(1)
begins with <stp>, and
(2)
must be followed by five additional bytes followed by <length> bytes followed by two (2)
additional bytes, and
(3)
is completely received without any intervening inter-character time-outs, and
(4)
contains some other error.
<nak>
::= 15H
--`,,```,,,,````-`-`,,`,,`,`,,`---
15
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
ANSI C12.21-2006
4.7.6
Retransmission
The same packet shall be retransmitted if a <nak> is received, an invalid character is received (neither an
<ack> nor a <nak>), or the Response Time-out occurs.
After the failure of the final retry attempt, the following actions will occur:
If the C12.21 Client is the requestor, then the C12.21 Client returns to the Base State but may or
may not terminate the call.
If the C12.21 Device is the requestor, the C12.21 Device may terminate the call.
4.7.7
4.7.7.1
Time-out
Channel Traffic Time-out
The C12.21 Device shall terminate communications after waiting some period of time for a valid PSEM
Request or PSEM Response. This period of time is defined as the Channel Traffic Time-out.
4.7.7.2
Inter-Character Time-out
The recipient of the packet shall handle the case when the end of a packet is lost. Inter-Character Timeout is defined as the minimum amount of time the recipient shall wait between bytes within a packet when
receiving data over the communication channel. The recipient shall wait at least this amount of time
before it ceases to wait for the remaining bytes of the packet and sends a <nak>.
4.7.7.3
Response Time-out
The sender of the packet shall handle the condition when the <ack> or <nak> is lost. Response Time-out
is defined as the minimum amount of time the sender shall wait after a packet is sent to receive an <ack>
or <nak> over the communication channel. If this amount of time elapses, the sender will send the
packet again.
4.7.8
Turn-around Delay
The Turn-around Delay is the minimum delay the recipient must wait after receiving a packet and before
sending a positive or negative acknowledgement.
4.7.9
Collision
If the C12.21 Device detects a collision (C12.21 Client and C12.21 Device are transmitting at the same
time), the C12.21 Device shall cease transmission and wait for the transmission from the C12.21 Client.
4.8 Layer 1 - Physical Layer
The Physical Layer is not defined in this Standard.
5 Compliance
1. The C12.21 Device shall accept and act upon all required service requests defined in Section
4.2, Layer 7 - Application Layer. If an optional service is not supported, the C12.21 Device shall
respond with an <sns>. The minimum services supported shall include Identification, Logon,
16
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
--`,,```,,,,````-`-`,,`,,`,`,,`---
A device is considered to be in compliance with this Standard if all of the following conditions are met:
ANSI C12.21-2006
Logoff and at least one (1) form of Read. Any service mentioned in this document, if
implemented, must comply with the C12.21 service description.
2. The C12.21 Device is compliant with ANSI C12.19 with respect to content and transmission of
Table data.
3. Layer 2 must be adhered to in its entirety.
--`,,```,,,,````-`-`,,`,,`,`,,`---
4. A C12.21 Device is compliant with this Standard if zero (0) features (<feature>) are supported in
the Identification Service.
17
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
ANSI C12.21-2006
--`,,```,,,,````-`-`,,`,,`,`,,`---
LAYER 7
LAYER 2
PACKET 1
INDEX
AND
CHANNEL
DIRECTION
LAYER 2
LAYER 7
ACK
IDENTIFICATION REQUEST IN
PACKET 1
ACK
NEGOTIATE REQUEST IN
PACKET 1
10
ACK
11
PACKET 1
14
ACK
LOGON REQUEST IN
15
PACKET 1
18
ACK
AUTHENTICATE REQUEST IN
19
PACKET 1
22
ACK
READ REQUEST IN
23
PACKET 1
IDENTIFICATION RESPONSE IN
ACK
PACKET 1
NEGOTIATE RESONSE IN
ACK
PACKET 1
ACK
12
PACKET 1
13
LOGON RESPONSE IN
ACK
16
PACKET 1
17
AUTHENTICATE RESPONSE IN
ACK
20
PACKET 1
21
ACK
24
ACK
26
ACK
28
25
27
READ RESPONSE IN
PACKET 2
PACKET 3
18
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
ANSI C12.21-2006
LAYER 2
PACKET 1
INDEX
AND
CHANNEL
DIRECTION
LAYER 2
LAYER 7
30
ACK
LOGOFF REQUEST IN
21
PACKET 1
34
ACK
TERMINATE REQUEST IN
35
PACKET 1
38
ACK
DISCONNECT REQUEST IN
39
PACKET 1
29
LOGOFF RESPONSE IN
ACK
32
PACKET 1
33
TERMINATE RESPONSE IN
ACK
36
PACKET 1
37
DISCONNECT RESPONSE IN
ACK
40
--`,,```,,,,````-`-`,,`,,`,`,,`---
19
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
ANSI C12.21-2006
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
Figure B-1: Packet Transmission Example, shows the actual packet data being transmitted in Figures A1: Communication Example, and A-2: Communication Example Continued, in ANNEX A - Communication
Example (Layer 7 and Layer 2). Numbers 1) - 40) refer to the numbers in Figures A-1: Communication
Example, and A-2: Communication Example Continued. All values are specified in hexadecimal format.
The following arbitrary information was used.
The data returned from the partial Table read in step 21 does not represent C12.19 Table 01.
<std>
<ver>
<rev>
<ticket>
::=
::=
::=
::=
<packet-size>
<nbr-packet>
<baud-rate>
<traffic>
<inter-char>
<resp-to>
<nbr-retries>
::=
::=
::=
::=
<user-id>
<username>
::= 0002
::= 41 42 43 44 45 46 47 48 49 4A (ABCDEFGHIJ)
<table-id>
<offset>
<count>
<data>
1E
04
04
03
(30 sec)
(4 sec)
(4 sec)
(3 times)
::= 00
::= DF A9 10 4C 37 BC 1E 26
::= CC C8 09 95 63 9E B3 2C
06
16
26
36
46
56
66
76
86
96
20
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
07
17
27
37
47
57
67
77
87
08
18
28
38
48
58
68
78
88
09
19
29
39
49
59
69
79
89
0A
1A
2A
3A
4A
5A
6A
7A
8A
0B
1B
2B
3B
4B
5B
6B
7B
8B
0C
1C
2C
3C
4C
5C
6C
7C
8C
0D
1D
2D
3D
4D
5D
6D
7D
8D
0E
1E
2E
3E
4E
5E
6E
7E
8E
0F
1F
2F
3F
4F
5F
6F
7F
8F
--`,,```,,,,````-`-`,,`,,`,`,,`---
<key-id>
<ini-auth-vector>
<tar-auth-vector>
02
02
00
30 36 31 37 34 30 33 30
ANSI C12.21-2006
--`,,```,,,,````-`-`,,`,,`,`,,`---
4)
5)
6)
7)
8)
9)
10)
11)
12)
13)
14)
15)
16)
17)
18)
19)
20)
21)
22)
23)
24)
25)
26)
27)
28)
29)
30)
31)
32)
33)
34)
35)
36)
37)
38)
39)
40)
EE 00
06
EE 00
C5 6A
06
EE 00
06
EE 00
06
EE 00
06
EE 00
06
EE 00
06
EE 00
06
EE 00
06
EE 00
06
EE 00
06
EE 00
10 11
28 29
06
EE 00
48 49
60 61
06
EE 00
80 81
1C 9E
06
EE 00
06
EE 00
06
EE 00
06
EE 00
06
EE 00
06
EE 00
06
00 00 00 01 20 13 10
00 00 00 11 00 02 01 00 02 01 00 08 30 36 31 37 34 30 33 30 00
20 00 00 04 60 00 40 04 FD BF
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
1)
2)
3)
20 00 00 05 00 00 40 04 06 03 1C
00 00 00 05 71 1E 04 04 03 D4 AA
00 00 00 05 00 1E 04 04 03 63 B4
20 00 00 0D 50 00 00 41 42 43 44 45 46 47 48 49 4A EE 54
20 00 00 01 00 80 51
00 00 00 0B 53 09 00 DF A9 10 4C 37 BC 1E 26 AC BC
00 00 00 0B 00 09 00 CC C8 09 95 63 9E B3 2C 93 7C
20 00 00 08 3F 00 01 00 00 10 00 96 2B 50
E0 02 00 38 00 00 96 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27
2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 09 F0
80 01 00 38 36 37 38 39 3A 3B 3C 3D 3E 3F 40 41 42 43 44 45 46 47
4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
62 63 64 65 66 67 68 69 6A 6B 6C 6D 43 39
A0 00 00 2A 6E 6F 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F
82 83 84 85 86 87 88 98 A8 B8 C8 D8 E8 F0 90 91 92 93 94 95 96 27
00 00 00 01 52 86 40
00 00 00 01 00 11 31
20 00 00 01 21 0B 61
20 00 00 01 00 80 51
00 00 00 01 22 01 33
00 00 00 01 00 11 31
21
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
ANSI C12.21-2006
This is the state of the telephone modem being on hook or being off
hook with a data carrier signal absent. This state is entered upon
power-up, data line hang-up and terminate service.
Base State:
This is the state at which communication begins. At this point the default
data transmission parameters apply.
ID State:
Once the C12.21 Device has been identified, this is the state that is
entered.
Session State:
When a successful logon has been completed, this is the state achieved.
The relationship between PSEM services and service sequence states is defined below.
Identification Service requests are accepted at the Base State only. Acceptance of an Identification
Service response <ok> transitions communications to the ID State. The Identification Service cannot
originate from the C12.21 Device.
Wait Service requests are accepted in the ID and Session States. Acceptance of these requests does
NOT result in any sequence state changes. The Wait Service can originate from either end of the
communication channel.
Negotiate Service and Timing Setup Service requests are accepted in the ID State only. Acceptance of
these requests does NOT result in any sequence state changes. Negotiated services are NOT
implemented until after acceptance. These services cannot originate from the C12.21 Device.
Security Service and Authenticate Service requests are accepted in the Session State only. Acceptance
of these requests does NOT result in any sequence state changes. These services cannot originate from
the C12.21 Device.
Read Service and Write Service requests are accepted in the Session State only. Acceptance of these
requests does NOT result in any sequence state changes. These services can originate from either end
of the communication channel.
Logoff Service requests are accepted in the Session State only. Acceptance of a Logoff Service request
transitions communications to the ID State. This service can originate from either end of the
communication channel.
Terminate Service requests are accepted in all states. Acceptance of a Terminate Service request
transitions communications to the Base State. This service can originate from either end of the
communication channel.
Disconnect Service requests are accepted in all states. Acceptance of a Disconnect Service request
disconnects the communication channel. This service can originate from either end of the communication
channel.
22
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
--`,,```,,,,````-`-`,,`,,`,`,,`---
Logon Service requests are accepted in the ID State only. Acceptance of a Logon Service request
transitions communications to the Session State. The Logon Service cannot originate from the C12.21
Device.
ANSI C12.21-2006
Establish
Channel
(Offline State)
Base state
Terminate
Base state
Disconnect
Establish
Channel
Identification
ID state
Timing Setup
Negotiate
Wait
Terminate
Base state
Disconnect
Establish
Channel
Logon
Session state
Read
Write
--`,,```,,,,````-`-`,,`,,`,`,,`---
Security
Authenticate
Wait
Terminate
Base state
Disconnect
Establish
Channel
Logoff
23
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
ANSI C12.21-2006
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
Note: In ANSI C12.21 -1999, this annex was Normative as the Tables contained herein had not yet been
introduced into ANSI C12.191997 Utility End Device Data Tables, nor had the RDATE data type. They
were included in subsequent updates. If using ANSI C12.19 1997 in conjunction with telephone
modems, the RDATE data type and tables presented in ANNEX D Modifications and Extensions to
C12.19-1997 of this Standard should be used. If using a later release of C12.19, then the information in
Annex D Modifications and Extensions to C12.19-1997 of this Standard should not be used.
--`,,```,,,,````-`-`,,`,,`,`,,`---
24
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
ANSI C12.21-2006
D.1
RDATE Type
This type defines a recurrent date. This recurrence can be yearly, monthly, weekly, based on a constant
cycle of days or minutes.
: UINT(0..3);
: UINT(4..15);
: UINT(4..7);
: UINT(8..10);
: UINT(11..15);
: FILL(4..7);
: UINT(8..10);
: FILL(11..15);
: UINT(4..9);
: UINT(10..15);
Identifier
Value
Definition
MONTH
1..12
13
14
15
OFFSET
0
1
2
3
4
5
6
7
8
9
10
11
12
13
No offset
Advance to WEEKDAY before date entered.
Postpone to the first WEEKDAY on or after date
entered.
Postpone to the second WEEKDAY on or after
date entered.
Postpone to the third WEEKDAY on or after
date entered.
Postpone to the fourth WEEKDAY on or after
date entered.
Postpone to the last WEEKDAY of the MONTH
on or after date entered.
Observe on date entered as well as day
following date entered.
Postpone to Monday if Sunday.
Advance to Friday if Sunday.
Postpone to Monday if Saturday.
Advance to Friday if Saturday.
Postpone to Monday if Sunday or Saturday.
Advance to Friday if Sunday or Saturday.
--`,,```,,,,````-`-`,,`,,`,`,,`---
25
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
ANSI C12.21-2006
14
15
WEEKDAY
0..6
7
Sunday to Saturday.
Unassigned
PERIOD_IN_ MINS
0..4095
PERIOD_IN_DAYS
0..63
0 to 63 days.
DELTA
0..63
0 to 63 days.
26
--`,,```,,,,````-`-`,,`,,`,`,,`---
ANSI C12.21-2006
D.2
--`,,```,,,,````-`-`,,`,,`,`,,`---
27
Not for Resale
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
ANSI C12.21-2006
Identifier
Value
Definition
ED_MODE_BFLD
METERING_FLAG
FALSE
TRUE
TEST_MODE_FLAG
FALSE
TRUE
METER_SHOP_MODE_FLAG FALSE
TRUE
ED_STD_STATUS1_BFLD
UNPROGRAMMED_FLAG
FALSE
TRUE
--`,,```,,,,````-`-`,,`,,`,`,,`---
CONFIGURATION_ERROR_FLAG
FALSE
TRUE
SELF_CHK_ERROR_FLAG
FALSE
TRUE
RAM_FAILURE_FLAG
FALSE
TRUE
ROM_FAILURE_FLAG
FALSE
TRUE
NONVOL_MEM_FAILURE_FLAG
FALSE
TRUE
CLOCK_ERROR_FLAG
FALSE
TRUE
MEASUREMENT_ERROR_FLAG
FALSE
TRUE
LOW_BATTERY_FLAG
FALSE
TRUE
28
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
ANSI C12.21-2006
LOW_LOSS_POTENTIAL_FLAG
FALSE
TRUE
DEMAND_OVERLOAD_FLAG FALSE
TRUE
POWER_FAILURE_FLAG
FALSE
TRUE
TAMPER_DETECT_FLAG
FALSE
TRUE
--`,,```,,,,````-`-`,,`,,`,`,,`---
REVERSE_ROTATION_FLAG FALSE
TRUE
ED_STD_STATUS2_BFLD
ED_MFG_STATUS_RCD
ED_MODE_STATUS_RCD
ED_MODE
ED_STD_STATUS1
ED_STD_STATUS2
ED_MFG_STATUS
See ED_MODE_BFLD.
See ED_STD_STATUS1_BFLD.
See ED_STD_STATUS2_BFLD.
See ED_MFG_STATUS_RCD.
29
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
ANSI C12.21-2006
D.3
Note: This Annex describes an additional standard procedure that is not defined in ANSI C12.19-1997,
Table 07.
PROCEDURE 20 Initiate an Immediate Call
This procedure causes the End Device to immediately initiate a call with the phone number specified. Call
windows are ignored.
TBL_PROC_NBR
PARM_RCD
RESP_DATA_RCD
20
Procedure number.
Defined below.
Not used.
Parameters
TYPE PARM_RCD = PACKED RECORD
PHONE_NUMBER_INDEX
: UINT8;
END;
Value
PARM_RCD
PHONE_NUMBER_INDEX
0..6
Definition
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
Identifier
--`,,```,,,,````-`-`,,`,,`,`,,`---
30
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
ANSI C12.21-2006
D.4
This decade contains Tables associated with the use of a telephone modem.
Table 90 Dimension Telephone Table
Table 90 Data Description
DIM_TELEPHONE_TBL (Table 90) specifies the maximum dimensional values for this decade.
TYPE TELEPHONE_FLAGS_BFLD = BIT FIELD OF UINT8
ANSWER_FLAG
: BOOL(0);
S_ANCHOR_DATE_FLAG
: BOOL(1);
OFFHOOK_DETECT_FLAG
: BOOL(2);
BIT_RATE
: UINT(3..4);
ID_IN_PURPOSE
: BOOL(5);
NO_LOCKOUT_PARM
: BOOL(6);
FILLER
: FILL(7..7);
END;
TYPE TELEPHONE_RCD = PACKED RECORD
TELEPHONE_FLAGS
: TELEPHONE_FLAGS_BFLD;
NBR_ORIGINATE_WINDOWS
: UINT8;
NBR_SETUP_STRINGS
: UINT8;
SETUP_STRING_LENGTH
: UINT8;
PREFIX_LENGTH
: UINT8;
NBR_ORIGINATE_NUMBERS
: UINT8;
PHONE_NUMBER_LENGTH
: UINT8;
NBR_RECURRING_DATES
: UINT8;
NBR_NON_RECURRRING_DATES
: UINT8;
NBR_EVENTS
: UINT8;
NBR_WEEKLY_SCHEDULES
: UINT8;
NBR_ANSWER_WINDOWS
: UINT8;
NBR_CALLER_IDS
: UINT8;
CALLER_ID_LENGTH
: UINT8;
END;
Identifier
Value
Definition
TELEPHONE_FLAGS_BFLD
ANSWER_FLAG
FALSE
TRUE
S_ANCHOR_DATE_FLAG
FALSE
TRUE
31
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
--`,,```,,,,````-`-`,,`,,`,`,,`---
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
ANSI C12.21-2006
FALSE
TRUE
BIT_RATE
0
1
2
3
ID_IN_PURPOSE
FALSE
TRUE
NO_LOCKOUT_PARM
FALSE
TRUE
TELEPHONE_RCD
TELEPHONE_FLAGS
NBR_ORIGINATE_WINDOWS 0..255
NBR_SETUP_STRINGS
0..255
SETUP_STRING_LENGTH
0..255
PREFIX_LENGTH
0..255
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
NBR_ORIGINATE_NUMBERS 0..255
PHONE_NUMBER_LENGTH
0..255
NBR_RECURRING_DATES
0..255
NBR_NON_RECURRRING_DATES
0..255
NBR_EVENTS
0..255
32
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
--`,,```,,,,````-`-`,,`,,`,`,,`---
OFFHOOK_DETECT_FLAG
ANSI C12.21-2006
NBR_WEEKLY_SCHEDULES 0..255
NBR_ANSWER_WINDOWS
0..255
NBR_CALLER_IDS
0..255
CALLER_ID_LENGTH
0..255
--`,,```,,,,````-`-`,,`,,`,`,,`---
33
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
ANSI C12.21-2006
S_ANCHOR_DATE_FLAG
Value
Definition
FALSE
TRUE
FALSE
TRUE
OFFHOOK_DETECT_FLAG
FALSE
TRUE
BIT_RATE
0
1
3
ID_IN_PURPOSE
FALSE
TRUE
NO_LOCKOUT_PARM
FALSE
TRUE
TELEPHONE_RCD
TELEPHONE_FLAGS
NBR_ORIGINATE_WINDOWS 0..255
34
--`,,```,,,,````-`-`,,`,,`,`,,`---
ANSI C12.21-2006
NBR_SETUP_STRINGS
0..255
SETUP_STRING_LENGTH
0..255
PREFIX_LENGTH
0..255
NBR_ORIGINATE_NUMBERS 0..7
PHONE_NUMBER_LENGTH
0..255
NBR_RECURRING_DATES
0..255
NBR_NON_RECURRRING_DATES
0..255
NBR_EVENTS
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
0..255
NBR_WEEKLY_SCHEDULES 0..255
NBR_ANSWER_WINDOWS
0..255
NBR_CALLER_IDS
0..255
CALLER_ID_LENGTH
0..255
--`,,```,,,,````-`-`,,`,,`,`,,`---
35
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
ANSI C12.21-2006
Identifier
SETUP_STRING_RCD
SETUP_STRING
GLOBAL_PARAMETERS_RCD
PSEM_IDENTITY
BIT_RATE
MODEM_SETUP_STRINGS
36
Definition
0..255
--`,,```,,,,````-`-`,,`,,`,`,,`---
ANSI C12.21-2006
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
--`,,```,,,,````-`-`,,`,,`,`,,`---
37
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
ANSI C12.21-2006
WINDOWS
:
ARRAY[ACT_TELEPHONE_TBL.NBR_ORIGINATE_WINDOWS]
OF WINDOW_RCD;
END;
TABLE ORIGINATE_PARAMETERS_TBL = ORIGINATE_PARAMETERS_RCD;
Value
Definition
HOUR
0..23
24..31
MINUTE
0..59
60..63
Minute of hour.
Unassigned.
Identifier
STIME
DAYS_BFLD
SUNDAY
--`,,```,,,,````-`-`,,`,,`,`,,`---
FALSE
TRUE
MONDAY
FALSE
TRUE
TUESDAY
FALSE
TRUE
WEDNESDAY
FALSE
TRUE
THURSDAY
FALSE
TRUE
FRIDAY
FALSE
TRUE
SATURDAY
FALSE
TRUE
WINDOW_RCD
BEGIN_WINDOW_TIME
WINDOW_DURATION
WINDOW_DAYS
PHONE_NUMBER_RCD
PHONE_NUMBER
PHONE_NUMBERS_RCD
PREFIX
38
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
D_TIME
ANSI C12.21-2006
PHONE_NUMBERS
ORIGINATE_PARAMETERS_RCD
ORIGINATE_BIT_RATE
DIAL_DELAY
ORIGINATE_PHONE_NUMBERS
WINDOWS
--`,,```,,,,````-`-`,,`,,`,`,,`---
39
ANSI C12.21-2006
40
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
ANSI C12.21-2006
OF WEEKLY_SCHEDULE_RCD;
END;
TABLE ORIGINATE_SCHEDULE_TBL = ORIGINATE_SCHEDULE_RCD;
Value
CTRL_BFLD
PRIMARY_PHONE_NUMBER 0..7
Definition
SECONDARY_PHONE_NUMBER
0..7
Selection of the secondary phone
number to use to originate a call. This value is
an index into the PHONE_NUMBERS array in
the ORIGINATE_PARAMETERS_TBL (Table
93). Seven (7) indicates that no secondary
number is provided.
USE_WINDOWS
FALSE
TRUE
RECURRING_DATES_RCD
ORIGINATE_DATE
--`,,```,,,,````-`-`,,`,,`,`,,`---
START_TIME
ORIGINATE_CTRL
NON_RECURRRING_DATES_RCD
ORIGINATE_DATE
START_TIME
ORIGINATE_CTRL
EVENTS_RCD
ED_STD_STATUS1
FALSE
TRUE
41
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
Identifier
ANSI C12.21-2006
ED_STD_STATUS2
FALSE
TRUE
ED_MFG_STATUS
FALSE
TRUE
ORIGINATE_CTRL
WEEKLY_SCHEDULE_RCD
DAYS
START_TIME
ORIGINATE_CTRL
ORIGINATE_SCHEDULE_RCD
S_ANCHOR_DATE
RECURRING_DATES
NON_RECURING_DATES
EVENTS
WEEKLY_SCHEDULES
42
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
--`,,```,,,,````-`-`,,`,,`,`,,`---
ANSI C12.21-2006
: ARRAY[ACT_TELEPHONE_TBL.NBR_CALLER_ID]
OF CALLER_ID_RCD;
WINDOWS
:
ARRAY[ACT_TELEPHONE_TBL.NBR_ANSWER_WINDOWS]
OF ORIGINATE_PARAMETERS_TBL.WINDOW_RCD;
END;
TABLE ANSWER_PARAMETERS_TBL = ANSWER_PARAMETERS_RCD;
Identifier
Value
CALLER_ID_RCD
CALLER_ID
ANSWER_PARAMETERS_RCD
ANSWER_BIT_RATE
Definition
LOCKOUT_DELAY
0..255
RETRY_ATTEMPTS
0..255
43
--`,,```,,,,````-`-`,,`,,`,`,,`---
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
ANSWER_PARAMETERS_TBL (Table 95) defines the answer configuration for receiving calls placed by
a utility host.
ANSI C12.21-2006
RETRY_LOCKOUT_TIME
0..255
NBR_RINGS
0..255
NBR_RINGS_OUTSIDE
0..255
WINDOWS
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
--`,,```,,,,````-`-`,,`,,`,`,,`---
CALLER_IDS
44
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
ANSI C12.21-2006
CALL_PURPOSE_BFLD
POWER_OUTAGE
Definition
POWER_RESTORAL
SCHEDULED_CALL
STATUS_CALL
IMMEDIATE_CALL
MANUFACTURER_PURPOSES
CALL_PURPOSE_RCD
CALL_PURPOSE
IDENT
45
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
--`,,```,,,,````-`-`,,`,,`,`,,`---
Identifier
ANSI C12.21-2006
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
CALL_TRIGGER_STATUS
46
--`,,```,,,,````-`-`,,`,,`,`,,`---
ANSI C12.21-2006
CALL_STATUS_TBL (Table 97) indicates the status of the most recent call to each defined phone
number.
TYPE CALL_STATUS_RCD = PACKED RECORD
CALL_STATUS_ARRAY
:
ARRAY[ACT_TELEPHONE_TBL.NBR_ORIGINATE_NUMBERS]
OF UINT8;
END;
TABLE CALL_STATUS_TBL = CALL_STATUS_RCD;
Identifier
Value
Definition
0
1
2
3
4
5
6
7
8
9
10
11
CALL_STATUS__RCD
CALL_STATUS_ARRAY
--`,,```,,,,````-`-`,,`,,`,`,,`---
47
ANSI C12.21-2006
D.5
The following codes extend those already defined in ANNEX B HISTORY & EVENT LOG CODES of
ANSI C12.19.
Event
Argument
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
--`,,```,,,,````-`-`,,`,,`,`,,`---
Code
48
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
ANSI C12.21-2006
D.6
DEFAULT_SET_USED
1
ANSWER_FLAG
S_ANCHOR_DATE_FLAG
OFFHOOK_DETECT_FLAG
BIT_RATE
ID_IN_PURPOSE
NO_LOCKOUT_PARM
NBR_ORIGINATE_WINDOWS
NBR_SETUP_STRINGS
SETUP_STRING_LENGTH
30
30
30
30
PREFIX_LENGTH
NBR_ORIGINATE_NUMBERS
PHONE_NUMBER_LENGTH
30
30
30
30
NBR_RECURRING_DATES
NBR_NON_RECURRING_DATES
NBR_EVENTS
NBR_WEEKLY_SCHEDULES
NBR_ANSWER_WINDOWS
NBR_CALLER_IDS
CALLER_ID_LENGTH
--`,,```,,,,````-`-`,,`,,`,`,,`---
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
Table 91
49
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
ANSI C12.21-2006
D.7
For purposes of this standard the indices for PARTIAL TABLE ACCESS defined in C12.19-1997 are
considered informative only. The following values are for use with the partial table access method
identified as index-count.
--`,,```,,,,````-`-`,,`,,`,`,,`---
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
TABLE 90 - DIM_TELEPHONE_TBL
TELEPHONE_FLAGS
NBR_ORIGINATE_WINDOWS
NBR_SETUP_STRINGS
SETUP_STRING_LENGTH
PREFIX_LENGTH
NBR_ORIGINATE_NUMBERS
PHONE_NUMBER_LENGTH
NBR_RECURRING_DATES
NBR_NON_RECURRING_DATES
NBR_EVENTS
NBR_WEEKLY_SCHEDULES
10
NBR_ANSWER_WINDOWS
11
NBR_CALLER_IDS
12
CALLER_ID_LENGTH
13
TABLE 91 - ACT_TELEPHONE_TBL
TELEPHONE_FLAGS
NBR_ORIGINATE_WINDOWS
NBR_SETUP_STRINGS
SETUP_STRING_LENGTH
PREFIX_LENGTH
NBR_ORIGINATE_NUMBERS
PHONE_NUMBER_LENGTH
NBR_RECURRING_DATES
NBR_NON_RECURRING_DATES
NBR_EVENTS
NBR_WEEKLY_SCHEDULES
10
NBR_ANSWER_WINDOWS
11
NBR_CALLER_IDS
12
CALLER_ID_LENGTH
13
Table 92 - GLOBAL_PARAMETERS_TBL
50
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
ANSI C12.21-2006
PSEM_IDENTITY
BIT_RATE
MODEM_SETUP_STRINGS
SETUP_STRING
[n]
Table 93 - ORIGINATE_PARAMETERS_TBL
ORIGINATE_BIT_RATE
DIAL_DELAY
ORIGINATE_PHONE_NUMBERS
PREFIX
PHONE_NUMBERS
PHONE_NUMBER
[n]
WINDOWS
BEGIN_WINDOW_TIME
[n]
WINDOW_DURATION
[n]
WINDOW_DAYS
[n]
S_ANCHOR_DATE
RECURRING_DATES
RECURRING_DATES (Item)
[n]
ORIGINATE_DATE
[n]
START_TIME
[n]
ORIGINATE_CTRL
[n]
NON_RECURRING_DATES
NON_RECURRING_DATES (Item)
[n]
ORIGINATE_DATE
[n]
START_TIME
[n]
ORIGINATE_CTRL
[n]
EVENTS
EVENTS (Item)
[n]
ED_STD_STATUS1
[n]
ED_STD_STATUS2
[n]
ED_MFG_STATUS
[n]
ORIGINATE_CTRL
[n]
WEEKLY_SCHEDULES
WEEKLY_SCHEDULES (Item)
--`,,```,,,,````-`-`,,`,,`,`,,`---
Table 94 - ORIGINATE_SCHEDULING_TBL
[n]
51
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
--`,,```,,,,````-`-`,,`,,`,`,,`---
DAYS
[n]
START_TIME
[n]
ORIGINATE_CTRL
[n]
Table 95 - ANSWER_PARAMETERS_TBL
ANSWER_BIT_RATE
LOCKOUT_DELAY
RETRY_ATTEMPTS
RETRY_LOCKOUT_TIME
NBR_RINGS
NBR_RINGS_OUTSIDE
CALLER_IDS
CALLER_ID
WINDOWS
WINDOWS (Item)
[n]
BEGIN_WINDOW_TIME
[n]
WINDOW_DURATION
[n]
WINDOW_DAYS
[n]
[n]
Table 96 - CALL_PURPOSE_TBL
CALL_PURPOSE
CALL_TRIGGER_STATUS
ED_MODE
ED_STD_STATUS1
ED_STD_STATUS2
ED_MFG_STATUS
IDENTIFICATION (BCD)
IDENTIFICATION (CHAR)
Table 97 - CALL_STATUS_TBL
CALL_STATUS_ARRAY
CALL_STATUS_ARRAY
0
(Item)
52
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
[n]
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
ANSI C12.21-2006
ANSI C12.21-2006
Start Tx
Apply P(x)
Apply P(x)
Apply P(x)
Apply P(x)
Apply P(x)
Apply P(x)
Apply P(x)
Apply P(x)
Apply P(x)
Apply P(x)
= ee 00 00 00 00 01 20
00000000 00000000 00000000 00000000 00000001 00100000 00000000 00000000
00000000 00000000 00000000 00000000 10000000 00000100 00000000 00000000
11111111
00000000
1
10000000
01
11000000
001
11100000
00100001
11000001
00010000
11010001
01000000
10010001
10001000
00000000 00000000 00000000 00011001
10001
00000000 00000000 00000000 00001000
1000
00000000 00000000 00000000 00000000
00000000 00000000
00000000
Apply P(x)
Apply P(x)
00000000 00000000 00000000 00000000
Apply P(x)
00000000 00000000 00000000 00000000
Apply P(x)
00000000 00000000 00000000 00000000
Apply P(x)
00000000 00000000 00000000 00000000
Apply P(x)
Apply P(x)
Apply P(x)
00000000 00000000 00000000 00000000 00000000 00000000
Apply P(x)
00000000 00000000 00000000 00000000 00000000 00000000
Apply P(x)
00000000 00000000 00000000 00000000 00000000 00000000
Apply P(x)
00000000 00000000 00000000 00000000 00000000 00000000
XOR FF
MSBit First
crc
00000000 00000000
00000000 00000000
00000000 00000000
00000000 00000000
00000000
1
10000000
01
11000000
001
11100000
100001
01100100
00100001
01000101
00000010
01000111
01000000
00000111
00100000
00100111
00010000
00110111
11001000
00010011
= 1310
00000000
00000000
00000000
00000000
00000000
0001
00010000
100001
10010100
0100001
11010110
00100001
11110111
00001000
00010000
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
53
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
--`,,```,,,,````-`-`,,`,,`,`,,`---
ANSI C12.21-2006
E.2
C Code Example
The following is an example of C code which calculates the <crc> field in a manner compliant with C12.18
Section 4.7, Layer 2 Data Link Layer, and Figure C-1: Communication State Diagram. This code is
provided as an example only.
#include <stdio.h>
unsigned short crc16(unsigned char octet, unsigned short crc);
unsigned short crc(int size, unsigned char *packet);
unsigned short crc16(unsigned char octet, unsigned short crc)
{
int i;
for (i = 8; i; i--)
{
if (crc & 0x0001)
{
crc >>= 1;
if (octet & 0x01)
crc |= 0x8000;
crc = crc ^ 0x8408;
octet >>= 1;
}
else
{
crc >>= 1;
if (octet & 0x01)
crc |= 0x8000;
octet >>= 1;
}
}
return crc;
}
unsigned short crc(int size, unsigned char *packet)
{
int i;
unsigned short crc;
crc = (~packet[1] << 8) | (~packet[0] & 0xFF);
for (i=2 ; i<size; i++)
crc = crc16(packet[i], crc);
--`,,```,,,,````-`-`,,`,,`,`,,`---
crc
crc
crc
crc
=
=
=
=
crc16(0x00, crc);
crc16(0x00, crc);
~crc;
crc >> 8 | crc << 8;
return crc;
}
int main()
{
unsigned char packet[] =
printf("Crc
return 0;
54
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
ANSI C12.21-2006
Traffic
Receiver
Send Packet
Packet Lost
Response Timeout
Retry 1
Packet Received
Ack Received
Send ACK
Traffic
Receiver
Send Packet
Packet Lost
Response Timeout
Retry 1
Packet Lost
Response Timeout
Retry 2
Packet Lost
Response Timeout
Retry 3
Packet Lost
Go to Base State
Traffic
Receiver
Send Packet
Packet Corrupted
NAK received
Send NAK
Retry 1
Packet Received
ACK received
Send ACK
--`,,```,,,,````-`-`,,`,,`,`,,`---
55
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
ANSI C12.21-2006
Traffic
Receiver
Send Packet
Packet Corrupted
NAK received
Send NAK
Retry 1
Packet Corrupted
NAK received
Send NAK
Retry 2
Packet Corrupted
NAK received
Send NAK
Retry 3
Packet Corrupted
NAK received
Send NAK
Go to Base State
Sender
Send Packet
ACK Lost
Traffic
Response Timeout
Retry 1
Ack Received
Receiver
Packet Received
Send ACK
Duplicate Packet Received
Discard Packet
Send ACK
56
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
--`,,```,,,,````-`-`,,`,,`,`,,`---
ANSI C12.21-2006
Usage
The Identification Service is used to notify the initiator of the communication of the usage of
authentication algorithm. The first step done by the initiator is the transmission of an Identification
request to the target. The target responds with zero (0) as <auth-alg-id> and a random value as <ticket>.
To be authenticated, the initiator transmits an Authenticate Service request with the key id selected and
an encrypted value. This value is the result of applying the DES algorithm to the <ticket> and the
selected key.
The target will decrypt this value with its own key and validate the result. If this validation fails, an <isc> is
returned in the Authenticate Service response. Otherwise this encrypted value is used as a ticket to
authenticate itself. This ticket is encrypted to produce an other encrypt value. The result is then
transmitted back to the initiator in the Authenticate Service response.
The following definitions clarify the use of the Identification Service and Authenticate Service.
In Identification Service response
<auth_-algm-id> ::= 00
<ticket>
::= <byte>*
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
Identification Response
<key_id> <ini_auth_vector>
<key_id> <tar_auth_vector>
Authentication Response
Legal Issues
Cryptographic devices implementing this standard may be covered by U.S. and foreign patents issued to
the International Business Machines Corporation. However, IBM has granted nonexclusive, royalty-free
licenses under the patents to make, use and sell apparatus which complies with the standard. The terms,
--`,,```,,,,````-`-`,,`,,`,`,,`---
57
ANSI C12.21-2006
conditions and scope of the license are set out in notices published in the May 13, 1975 and August 31,
1976 issues of the Official Gazette of the United States Patent and Trademark Office (9434 O"G" 452 and
949 O.G. 1717).
G.3
Implementation
The Data Encryption Standard (DES) algorithm, adopted by the U.S. government in 1977, is a block
cipher that transforms 64-bit data blocks under a 56-bit secret key, by means of permutation and
substitution. The following is a description of how to use the DES algorithm to encrypt one 64-bit block.
Step 1
Get a 64-bit key.
Step 2
Perform the following permutation on the 64-bit key. The most significant bit of each bytes is discarded,
reducing the key to 56 bits. Bit 1 of the permuted block is bit 57 of the original key, bit 2 is bit 49, and so
on with bit 56 being bit 4 of the original key.
57 49 41 33 25
10 2 59 51 43
63 55 47 39 31
14 6 61 53 45
17 9 1
35 27 19
23 15 7
37 29 21
58 50 42 34 26 18
11 3 60 52 44 36
62 54 46 38 30 22
13 5 28 20 12 4
Split the permuted key into two (2) halves. The first 28 bits are called C[0] and the last 28 bits are called
D[0].
Start with i = 1.
Step 3, 4
Iteration # 1
Left Shifts 1
2
1
3
2
4
2
5
2
6
2
7
2
8
2
9 10 11 12 13 14 15 16
1 2 2 2 2 2 2 1
Step 5
Permute the concatenation C[i]D[i] as indicated below. This will yield K[i], which is 48 bits long.
14
23
41
44
17
19
52
49
11 24 1 5 3 28 15 6 21 10
12 4 26 8 16 7 27 20 13 2
31 37 47 55 30 40 51 45 33 48
39 56 34 53 46 42 50 36 29 32
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
Get a 64-bit data block. If the block is shorter than 64 bits, it should be padded as appropriate for the
application.
Step 7
58
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
--`,,```,,,,````-`-`,,`,,`,`,,`---
Perform one (1) or two (2) circular left shifts on both C[i-1] and D[i-1] to get C[i] and D[i], respectively.
The number of shifts per iteration are given in the table below.
50
54
49
53
42
46
41
45
34
38
33
37
26
30
25
29
18 10 2 60 52
22 14 6 64 56
17 9 1 59 51
21 13 5 63 55
44
48
43
47
36
40
35
39
28
32
27
31
20
24
19
23
12
16
11
15
4
8
3
7
Split the block into two (2) halves. The first 32 bits are called L[0], and the last 32 bits are called R[0].
Start with i = 1.
Step 8
Expand the 32-bit R[i-1] into 48 bits according to the bit-selection function below.
32 1 2 3 4 5 4 5 6 7 8 9
8 9 10 11 12 13 12 13 14 15 16 17
16 17 18 19 20 21 20 21 22 23 24 25
24 25 26 27 28 29 28 29 30 31 32 1
Step 9
Exclusive-or E(R[i-1]) with K[i].
Step 10
Break E(R[i-1]) xor K[i] into eight (8) 6-bit blocks. Bits 1-6 are B[1], bits 7-12 are B[2], and so on with bits
43-48 being B[8].
Substitute the values found in the S-boxes for all B[j]. Start with j = 1. All values in the S-boxes should be
considered 4 bits wide. Take the 1st and 6th bits of B[j] together as a 2-bit value indicating the row in S[j].
Take the 2nd through 5th bits of B[j] together as a 4-bit value indicating the column in S[j].
S[1]
14 4 13
0 15 7
4 1 14
15 12 8
1 2 15 11 8 3 10 6 12 5 9
4 14 2 13 1 10 6 12 11 9 5
8 13 6 2 11 15 12 9 7 3 10
2 4 9 1 7 5 11 3 14 10 0
S[2]
15 1 8 14 6 11 3 4 9
3 13 4 7 15 2 8 14 12
0 14 7 11 10 4 13 1 5
13 8 10 1 3 15 4 2 11
S[3]
10 0 9 14
13 7 0 9
13 6 4 9
1 10 13 0
S[4]
7 13 14
13 8 11
10 6 9
3 15 0
7 2 13 12
0 1 10 6
8 12 6 9
6 7 12 0
0 7
3 8
5 0
6 13
0 5 10
9 11 5
3 2 15
5 14 9
6 3 15 5 1 13 12 7 11 4 2 8
3 4 6 10 2 8 5 14 12 11 15 1
8 15 3 0 11 1 2 12 5 10 14 7
6 9 8 7 4 15 14 3 11 5 2 12
3 0 6 9 10 1
5 6 15 0 3 4
0 12 11 7 13 15
6 10 1 13 8 9
2
7
1
4
8 5 11 12 4 15
2 12 1 10 14 9
3 14 5 2 8 4
5 11 12 7 2 14
--`,,```,,,,````-`-`,,`,,`,`,,`---
59
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
ANSI C12.21-2006
ANSI C12.21-2006
S[5]
2 12 4 1 7 10 11 6 8 5 3 15 13
14 11 2 12 4 7 13 1 5 0 15 10 3
4 2 1 11 10 13 7 8 15 9 12 5 6
11 8 12 7 1 14 2 13 6 15 0 9 10
S[6]
12 1 10 15
10 15 4 2
9 14 15 5
4 3 2 12
9 2 6 8 0 13 3 4 14 7 5 11
7 12 9 5 6 1 13 14 0 11 3 8
2 8 12 3 7 0 4 10 1 13 11 6
9 5 15 10 11 14 1 7 6 0 8 13
S[7]
4 11 2 14 15
13 0 11 7 4
1 4 11 13 12
6 11 13 8 1
S[8]
13 2 8
1 15 13
7 11 4
2 1 14
0 14 9
9 8 6
3 0 14
4 5 3
0 8 13 3 12
9 1 10 14 3
3 7 14 10 15
4 10 7 9 5
9 7 5 10
5 12 2 15
6 8 0 5
0 15 14 2
6 1
8 6
9 2
3 12
4 6 15 11 1 10 9 3 14 5 0 12 7
8 10 3 7 4 12 5 6 11 0 14 9 2
1 9 12 14 2 0 6 10 13 15 3 5 8
7 4 10 8 13 15 12 9 0 3 5 6 11
Step 11
Permute the concatenation of B[1] through B[8] as indicated below.
16 7 20 21 29 12 28 17
1 15 23 26 5 18 31 10
2 8 24 14 32 27 3 9
19 13 30 6 22 11 4 25
Step 12
your
R[i]
L[i-1]
xor
Step 13
L[i] = R[i-1].
Loop back to Step 8 until K[16] has been applied.
Step 14
Perform the following permutation on the block R[16]L[16].
40
38
36
34
8
6
4
2
48
46
44
42
16
14
12
10
56
54
52
50
24
22
20
18
64
62
60
58
32
30
28
26
39
37
35
33
7
5
3
1
47 15 55 23 63
45 13 53 21 61
43 11 51 19 59
41 9 49 17 57
31
29
27
25
To decrypt, use the same process, but just use the keys K[i] in reverse order. That is, instead of applying
K[1] for the first iteration, apply K[16], and then K[15] for the second, on down to K[1].
--`,,```,,,,````-`-`,,`,,`,`,,`---
60
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
ANSI C12.21-2006
G.4
Code Example
The following is an example of C code which encrypts a data block of 64 bits using a key of 56 bits. This
code is provided as an example only, and is not required for compliance with the Data Encryption
Standard.
#include <stdio.h>
typedef unsigned char uint8;
static uint8
key[64] = {
1,1,0,0,1,1,0,1,0,0,1,1,1,0,0,0,1,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,
1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,1,0,0,0,1,1,0,0,0,0,1,1,1,0
};
static uint8
data[64] = {
1,1,0,0,1,1,0,1,0,0,1,1,1,0,0,0,1,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,
1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,1,0,0,0,1,1,0,0,0,0,1,1,1,0
};
--`,,```,,,,````-`-`,,`,,`,`,,`---
static uint8
57, 49, 41,
10, 2, 59,
63, 55, 47,
14, 6, 61,
};
perm1[56] =
33, 25, 17,
51, 43, 35,
39, 31, 23,
53, 45, 37,
static uint8
2, 3, 4,
16, 17, 18,
30, 31, 32,
44, 45, 46,
};
perm2[56] =
5, 6, 7,
19, 20, 21,
33, 34, 35,
47, 48, 49,
8, 9, 10, 11,
22, 23, 24, 25,
36, 37, 38, 39,
50, 51, 52, 53,
12,
26,
40,
54,
13,
27,
41,
55,
18,
36,
22,
4
14, 15,
28, 1,
42, 43,
56, 29
static uint8
perm3[48] = {
14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21, 10, 23, 19, 12, 4,
26, 8, 16, 7, 27, 20, 13, 2, 41, 52, 31, 37, 47, 55, 30, 40,
51, 45, 33, 48, 44, 49, 39, 56, 34, 53, 46, 42, 50, 36, 29, 32
};
static uint8
58, 50, 42,
62, 54, 46,
57, 49, 41,
61, 53, 45,
};
perm4[64] =
34, 26, 18,
38, 30, 22,
33, 25, 17,
37, 29, 21,
{
10,
14,
9,
13,
2,
6,
1,
5,
60,
64,
59,
63,
52,
56,
51,
55,
44,
48,
43,
47,
36,
40,
35,
39,
28,
32,
27,
31,
20,
24,
19,
23,
12,
16,
11,
15,
4,
8,
3,
7,
static uint8
perm5[48] = {
32, 1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 8, 9, 10, 11,
12, 13, 12, 13, 14, 15, 16, 17, 16, 17, 18, 19, 20, 21, 20, 21,
22, 23, 24, 25, 24, 25, 26, 27, 28, 29, 28, 29, 30, 31, 32, 1,
};
static uint8
perm6[32] = {
16, 7, 20, 21, 29, 12, 28, 17, 1, 15, 23, 26, 5, 18, 31, 10,
2, 8, 24, 14, 32, 27, 3, 9, 19, 13, 30, 6, 22, 11, 4, 25,
};
static uint8
40, 8, 48,
38, 6, 46,
36, 4, 44,
34, 2, 42,
};
perm7[64] =
16, 56, 24,
14, 54, 22,
12, 52, 20,
10, 50, 18,
{
64,
62,
60,
58,
32,
30,
28,
26,
39,
37,
35,
33,
7,
5,
3,
1,
31,
29,
27,
25,
static uint8
sboxes[8][64] = {
{
14,4,13,1,2,15,11,8,3,10,6,12,5,9,0,7,0,15,7,4,14,2,13,1,10,6,12,11,9,5,3,8,
4,1,14,8,13,6,2,11,15,12,9,7,3,10,5,0,15,12,8,2,4,9,1,7,5,11,3,14,10,0,6,13,
},{
15,1,8,14,6,11,3,4,9,7,2,13,12,0,5,10,3,13,4,7,15,2,8,14,12,0,1,10,6,9,11,5,
0,14,7,11,10,4,13,1,5,8,12,6,9,3,2,15,13,8,10,1,3,15,4,2,11,6,7,12,0,5,14,9,
},{
10,0,9,14,6,3,15,5,1,13,12,7,11,4,2,8,13,7,0,9,3,4,6,10,2,8,5,14,12,11,15,1,
61
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
ANSI C12.21-2006
13,6,4,9,8,15,3,0,11,1,2,12,5,10,14,7,1,10,13,0,6,9,8,7,4,15,14,3,11,5,2,12,
},{
7,13,14,3,0,6,9,10,1,2,8,5,11,12,4,15,13,8,11,5,6,15,0,3,4,7,2,12,1,10,14,9,
10,6,9,0,12,11,7,13,15,1,3,14,5,2,8,4,3,15,0,6,10,1,13,8,9,4,5,11,12,7,2,14,
},{
2,12,4,1,7,10,11,6,8,5,3,15,13,0,14,9,14,11,2,12,4,7,13,1,5,0,15,10,3,9,8,6,
4,2,1,11,10,13,7,8,15,9,12,5,6,3,0,14,11,8,12,7,1,14,2,13,6,15,0,9,10,4,5,3,
},{
12,1,10,15,9,2,6,8,0,13,3,4,14,7,5,11,10,15,4,2,7,12,9,5,6,1,13,14,0,11,3,8,
9,14,15,5,2,8,12,3,7,0,4,10,1,13,11,6,4,3,2,12,9,5,15,10,11,14,1,7,6,0,8,13,
},{
4,11,2,14,15,0,8,13,3,12,9,7,5,10,6,1,13,0,11,7,4,9,1,10,14,3,5,12,2,15,8,6,
1,4,11,13,12,3,7,14,10,15,6,8,0,5,9,2,6,11,13,8,1,4,10,7,9,5,0,15,14,2,3,12,
},{
13,2,8,4,6,15,11,1,10,9,3,14,5,0,12,7,1,15,13,8,10,3,7,4,12,5,6,11,0,14,9,2,
7,11,4,1,9,12,14,2,0,6,10,13,15,3,5,8,2,1,14,7,4,10,8,13,15,12,9,0,3,5,6,11,
}};
static uint8
keys[16][48];
/**************************************************************************/
void
Permutation(uint8 *dst, uint8 *src, uint8 lgn, uint8 *perm_table)
{
uint8
tmp[64];
if (src == NULL)
{
src = tmp;
memcpy(src, dst, 64);
}
for (; lgn > 0; lgn--, dst++, perm_table++)
*dst = src[*perm_table - 1];
}
/**************************************************************************/
void
Xor(uint8 *dst, uint8 *src, uint8 lgn)
{
for (; lgn > 0; lgn--, dst++, src++)
*dst ^= *src;
}
/**************************************************************************/
void
Copy(uint8 *dst, uint8 *src, uint8 lgn)
{
for (; lgn > 0; lgn--, dst++, src++)
*dst = *src;
}
= src[4];
|= src[3]
|= src[2]
|= src[1]
|= src[5]
|= src[0]
<<
<<
<<
<<
<<
1;
2;
3;
4;
5;
--`,,```,,,,````-`-`,,`,,`,`,,`---
i
i
i
i
i
i
i = sbox[i];
dst[3]
dst[2]
dst[1]
dst[0]
=
=
=
=
i
i
i
i
& 1;
>> 1 & 1;
>> 2 & 1;
>> 3 & 1;
}
/**************************************************************************/
void
des(uint8 *_key, uint8 *_data, int _encrypt)
{
uint8
key[64], data[64], right[48];
int
i, j;
62
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
/**************************************************************************/
void
SBoxes(uint8 *dst, uint8 *src, uint8 *sbox)
{
int
i;
ANSI C12.21-2006
/**************************************************************************/
int main()
{
des(key, data, 1);
des(key, data, 0);
return 0;
}
G.5
Trace Example
This example shows the bit manipulations performed in each step in compliance with the Data Encryption
Standard.
=
=
=
=
=
=
=
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
Initialize keys
Step 1: Key = 1100110100111000111110000001111110000000111111100010001100001110
Step 2: Permutation = 00110101001001010110011000101110100010101001101011111110
Step 3: Rotation = 01101010010010101100110001001101000101010011010111111101
Step 5: keys[1] = 010001101011000010010011010000111001110101101111
Step 3: Rotation = 11010100100101011001100010001010001010100110101111111011
Step 5: keys[2] = 110010000110001100100101011111001101011101011010
Step 3: Rotation = 10101001001010110011000100010100010101001101011111110111
Step 4: Rotation = 01010010010101100110001000111000101010011010111111101110
Step 5: keys[3] = 100000011001111100011001100111011111010001101010
Step 3: Rotation = 10100100101011001100010001100001010100110101111111011101
Step 4: Rotation = 01001001010110011000100011010010101001101011111110111010
Step 5: keys[4] = 010001010011001011100011111011001111111001100000
...
Skipping keys[5] to keys[15]
...
Step 3: Rotation = 00110101001001010110011000101110100010101001101011111110
Step 5: keys[16] = 101000100100110101101000111111101110111001001010
1100110100111000111110000001111110000000111111100010001100001110
0010010100101110101010010100100100110101011001101010111111101000
000110101010101100001101010101011111111101010000
010111000001101110011110000101100110001000111111
10110011000011110010010111111011
11001010110100100111111011001011
11101111111111001101011110000010
63
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
ANSI C12.21-2006
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
--`,,```,,,,````-`-`,,`,,`,`,,`---
64
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
ANSI C12.21-2006
This annex describes the "I command" currently used in many heterogeneous protocol environments.
This annex is informative and is up to each manufacturer to implement or not.
The Problem
C12.21 Devices that are calling into a C12.21 Client may not all support the ANSI C12.21 protocol. This
makes it extremely difficult for the C12.21 Client to initiate a communication session with the C12.21
Device if the protocol is not known.
The Solution
When a C12.21 Device calls into a C12.21 Client and the communication channel is established, the
C12.21 Client will transmit a single ASCII uppercase I. The C12.21 Device will respond with a 15character ASCII string that identifies the protocol. This string may be followed by an optional carriage
return. From this information, the C12.21 Client will be able to properly perform a communication session
with the C12.21 Device.
The I command does not use the data link layer as described in this standard. The C12.21 Device will
only recognize this command during the initial portion of a call-originate procedure. It will not respond to
the I command after an ANSI C12.21 session is established.
Request:
<I-command>
::= 49H
Response:
<I-command-r>
::= <byte>+15[0DH]
--`,,```,,,,````-`-`,,`,,`,`,,`---
65
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
ANSI C12.21-2006
Annex I - Compatibility
(informative)
1999
2006
1
2
--`,,```,,,,````-`-`,,`,,`,`,,`---
1999
2006
Backward compatible for the Reader; Forward compatible for the Device.
Forward compatible for the Reader; Backward compatible for the Device.
Any future revision of this Standard shall be backward compatible with the previous two (2) revisions of
the Standard as defined by the 5-year ANSI revision cycle requirement.
I.2
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
The following forward compatibility criteria shall be used when extending this standard:
1. The following forward compatibility criteria shall be used when extending this Standard. Services
may be:
1. defined as new;
2. omitted;
3. required where it had been optional;
4. optional where it had been required.
66
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
ANSI C12.21-2006
For cases 2 and 4, the response code <sns> shall be generated for any service that is not supported.
For case 3, the response code <sns> shall not be generated for any required service.
Example of case 4
Assume that the Security Service is defined as follows:
4.2.2.7 Security Service
The Security Service is identical to that in C12.18-1996.
Also assume that ANSI C12.18-1996 states:
<security>
::=
51H <password>
The response <ok> indicates the security service was successfully completed and the access
permissions associated with the password were granted.
<security-r> ::=
This enables this Standard to extend another or be modified consistently where some required
services in one (1) revision or referenced standard become inoperative or optional in other.
2. No tables, procedures or data types shall be introduced or modified by this Standard. These items
are to be instead proposed for ANSI C12.19.
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
67
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
--`,,```,,,,````-`-`,,`,,`,`,,`---
It is clear that the change fails to allow for the response code <sns> (Service Not Supported), then
any implementation of <security> may respond with <security-r> if and only if there is a condition that
can successfully generate an <ok> response for a given <security> request. If there is no possibility
for the <security> service to operate or be made to operate correctly for this device then the <sns>
shall be generated.
ANSI C12.21-2006
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
J.1
Foreword of C12.21-1999
(This foreword is not part of ANSI C12.21)
This American National Standard establishes acceptable performance criteria for electricity meters.
Accuracy class designations, current class designations, voltage and frequency ratings, test current
values, service connection arrangements, pertinent dimensions, form designations, and environmental
tests are covered.
Suggestions for improvement to this standard are welcome. They should be sent to:
National Electrical Manufacturers Association
Vice President of Engineering
1300 North 17th Street
Suite 1847
Rosslyn, VA 22209
At the time this standard was completed, Subcommittee 17 of ANSI Committee C12, which developed
and revised this standard, had the following membership:
--`,,```,,,,````-`-`,,`,,`,`,,`---
Cruz R. Gomez
68
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS
Brad Johnson
James Mining (Alternate)
John McEvoy
ANSI C12.21-2006
Lauren Pananen
Tim Morgan
Tim Vahlstrom
Wesley Ray (Alternate)
National Electrical Manufacturers Association .
Ed Beroset (Alternate)
Francis A. Marta
Jack Pazdon (Alternate)
Michael Anderson
Ronald Shaw (Alternate)
Scott Weikel (Alternate)
Tom C. Drew
Warren Germer
Herman M. Millican
Richard Tucker
William J. Buckley
Nile Oldham
James Ruehl
Stephen Jones
Ron Breschini
//^:^^#^~^^""@:~"^$$"@#~"#:$@^#$"*@^*:~~^"^~^~~^^:^~~\\
--`,,```,,,,````-`-`,,`,,`,`,,`---
69
Copyright National Electrical Manufacturers Association
Provided by IHS under license with NEMA
No reproduction or networking permitted without license from IHS