Transferred from: Http://bbs.ednchina.com/BLOG_ARTICLE_172024.HTM
2.4-Block Transport protocol T=1
In the T=1 protocol, commands, R-APDU, and Transmission control information (such as acknowledgment information) transmitted between the TAL and IC cards are made up of blocks.
The following defines the block frame structure of the data link layer, special options for the Protocol, and protocol operations (including error handling).
(1) Block frame structure
The definition of the word frame is described in the previous article. T=1 protocol, there is no need for character-by-letter verification. The structure of the block is as follows, including the header field, data field, and 3 parts of the tail field, all of which are optional.
The header field consists of 3 required bytes:
* The source address and destination address for identifying the data block and the 1Byte node address (NAD) that provides VPP state control
* 1Byte Protocol Control byte (PCB) for control data transmission
*1byte Optional data field length (LEN)
> Node address (NAD)
The node address, referred to as NAD, 1th through 3rd indicates the source node address of the block (source address, or sad), and the 5th to 7th bits indicate the destination address of the block (Destination, referred to as dad), 4th and 8th digits are not used, set to 0.
The node address used by the terminal is optional, but the IC card that supports the T=1 protocol should support the node address method as specified in this section. Follow the rules below.
* If the node address is not used, the sad and dad values for the first data block destined for the IC card should be set to 0.
* If a node address is used, sad and dad should be set to a different value (one of which can be 0) for the first block of data sent by the terminal to the IC card.
* If using the node address, in the card operation process, the IC card receives the first valid I block and the s block nad, used to establish the entire card operation process terminal and the IC card node address, in the same process terminal sends the IC card the subsequent block uses the same NAD, The node address so established applies to all types of blocks.
* During the card operation, any data block from the IC card to the terminal will use the node address established when the first block issued by the terminal to the IC card is used in the process (the terminal is sent to the IC card and the source address and destination address used by the IC card to the terminal are the exact opposite).
* In the process of card operation, if the IC card receives the data block NAD and the transaction at the beginning of the establishment of the NAD is different, then the IC card should be opened to the beginning of the transaction of the Dad to reply to an R block.
> Protocol Control byte
The Protocol control byte (Protocol control Byte, or PCB) indicates the type of transmission block, which has the following 3 types.
* Transmit APDU information block (I block).
* A Receive Ready block (R Block) for transmitting acknowledgment ack (acknowledgment) or NAK (negative acknowledge).
* Management Module (s block) for exchanging control information.
Different types of PCBs have different encoding formats.
PCB Code for Block I
byte bit meaning
B8 0
B7 Serial Number
B6 links (multiple data)
B5~B1 reserved
PCB coding for R blocks
byte bit meaning
B8 1
B7 0
B6 0
B5 Serial number
B4~B1 0 = Fault tolerant 1=EDC or checksum error 2 = other error other: Reserved
PCB code for S block
byte bit meaning
B8 1
B7 1
B6 0 = Request 1 = reply
B5~B1 0 = in sync request 1 = information domain Size Request 2 = Abort Request 3=BWT Extension Request 4=VPP error other: Reserved
> Length
Length (length, short len) indicates the length of the INF portion of the block, and the range of values from 1~254.
Data fields include: 0~254byte's APDU or control information (INF)
Information domain INF is conditional, when it appears in block I, it transmits the application data, when it appears in the S block, it transmits the control information. The R Block does not appear in the Iinf.
Tail fields include: 1Byte error check code (EDC)
The trailing field contains the error detection code for the transferred block (error Detection code, or EDC), and the block is invalid when the checksum error and/or EDC error occurs. Redundancy Checks (longitudinal redundancy check, or LRC) are usually used as EDC. The length of the LRC is 1Byte, and its value is obtained by making an XOR operation of all bytes starting with NAD to the INF (if any).
Block number
Block I is encoded in one of the upper modulus 2 digital encoding, IC card and terminal as the sender of the respective numbering system processing. After the reset answer, the sender sends the first block of I number zero, after each send an I block, the number value increases by 1. When synchronizing again, the sender resets the number value to zero.
The R Block is numbered in one of the upper modulus 2 numbers, and when it is used to confirm block I in the link process, the R Block carries the next desired I block number. When a block is required to be re-sent, the R Block carries the received I block number.
s block does not carry a number.
(2) Special options
This section defines the size and time of the information domain used for the T=1 transport protocol.
* Information Field Size
IFSC refers to the IC card can receive the maximum length of the information domain, which is defined as: During the reset response, IC card in the TA3 back IFSI indicates the IC card can accommodate the size of the IFSI, IFSI the value range is 0x10~0xfe, the corresponding IFSC size 16~254byte. So the maximum data length that the IC card can receive is (IFSI+3+1) Byte, which includes the head and tail domains. The value established during the reset response is used during the entire card operation, or continues until the new IFSC value is obtained as a result of the IC card sending S block (IFS request) to the terminal.
The terminal packet size (information field, size for the Terminal, abbreviated as IFSD) refers to the maximum length of the data block that the terminal can receive, immediately after the reset answer, the initial size is 32Byte. This length applies to the entire card operation process or until a new IFSC value is obtained due to the terminal transmitting S block (IFS request) to the IC card.
In order to avoid slow communication between IC card and terminal, the terminal supports 254Byte IFSD.
Period of *t=1 Agreement
The shortest interval between the rising edge of the starting bit of the two consecutive characters that the terminal sends to the IC card is 11~266 ETU, which is determined by the TC1 value returned after the reset response.
The minimum time interval between the two-character rising edge of the IC card destined for the terminal should be 11 ETU. The maximum time interval between the rising edge of the starting bit of two consecutive characters in the same piece cwt should not exceed (2 of CWT's +11) ETU, where the byte wait time integer CWI takes value between 0~5, and cwt's value is 12~43 ETU.
The maximum time interval between the starting bit of the last character of the terminal sent to the IC card and the rising edge of the first character from the IC card BWT should not exceed [(2 cwt x960) +11] ETU. The value range of block wait time integer BWI is 0~4, so the BWT value range is 971~15371 ETU.
The minimum time interval between the starting bits of two consecutive characters transmitted in the opposite direction (block guard time, or BGT) for 22 ETU.
Transfer Protocol for IC Card (2)-Block Transfer Protocol T=1 "Go"