CAN TP Protocol

경로 및 정보 2023. 6. 22. 13:12

https://piembsystech.com/can-tp-protocol

 

CAN-TP Protocol

Table of contentsIntroduction to CAN-TP (ISO 15765) TutorialTypes of Addressing in CAN-TP (ISO 15765) ProtocolBasic Addressing in CAN-TP (ISO

piembsystech.com

 

CAN-TP is a transport protocol that enables large data packets to be transmitted over the CAN bus, which has a limited message size. The protocol allows for the segmentation and reassembly of data packets, so that they can be transmitted in multiple smaller frames over the CAN bus.

Types of Addressing in CAN-TP (ISO 15765) Protocol

The main purpose of addressing in CAN-TP is for how to identify, either it is a non CAN-TP message or CAN-TP message. To identify it, there ae 2 types of addressing defined in the ISO 15765-2 standard.

  1. Basic Addressing.
  2. Extended Addressing.

Basic Addressing in CAN-TP (ISO 15765)

The CAN-TP Protocol basic addressing mode is called a normal addressing mode were to identify the CAN message or CAN-TP, we are using the CAN Identifier. So for this, there will be some identifier will be for CAN-TP, where if any message will receive then the server will understand that this TP message. The advantages of this type of addressing are that full 8 bytes of the data packet can be sent as data.

In basic addressing, each message is addressed to a specific node on the network using a unique identifier called a “Node Address.” Each node on the network is assigned a unique Node Address, which is typically configured by the user or by a configuration tool.

When a node wants to send a message, it includes the destination Node Address in the message header. When the message is received by the other nodes on the network, they compare the destination Node Address in the message header to their own Node Address. If the Node Address matches, the node accepts the message and processes it. If the Node Address does not match, the node ignores the message.

Extended Addressing in CAN-TP (ISO 15765)

Extended Addressing is a feature of the ISO 15765-2 Transport Protocol (CAN-TP) that allows messages to be addressed to a larger number of nodes on a Controller Area Network (CAN) than is possible with Basic Addressing. In Extended Addressing, the identifier field of the CAN message header is used to transmit the destination Node Address, which can be up to 29 bits in length. This allows for a much larger address space, with up to 536,870,912 possible Node Addresses, compared to the 8-bit Node Addresses used in Basic Addressing.

Extended Addressing also allows for dynamic addressing, where nodes can be added or removed from the network without requiring reconfiguration of the Node Addresses. This is accomplished through the use of a “Dynamic Addressing” scheme, where a unique “Arbitration ID” is assigned to each node, and the Node Address is transmitted in the data portion of the message.

When a node sends a message using Extended Addressing, it includes the destination Node Address in the identifier field of the CAN message header. When the message is received by the other nodes on the network, they compare the destination Node Address in the message header to their own Node Address. If the Node Address matches, the node accepts the message and processes it. If the Node Address does not match, the node ignores the message.

This addressing mode is the CAN-TP addressing mode where the 1st byte of the CAN data field will be used for the additional elements of the address whereby it reducing the data payload by one byte. The primary task of the transport protocol is to transfer messages which cannot be transmitted as a single Protocol Data Unit (PDU) due to their length. Messages which contain more data that can be transmitted within a single PDU are segmented by means of the transport protocol and divided into multiple, separate PDUs.

This procedure can also be implemented on the data link layer. The segmentation of the message must then be carried out in PDUs of the corresponding data link protocol. So to send the data like CAN, the CAN-TP Protocol has been designed. Let us discuss how it can send multiple frames.

Different Types of Frames in CAN-TP (ISO 15765)

So to make it possible, the CAN-TP also having 2 types of frames. Single Frame and Multi-Frame. Again the Multi-frame is having 3 types of frames. So total 4-types frames are there in CAN-TP:

  1. Single Frame (0x0).
  2. Multi-Frame.
    • First Frame (0x1).
    • Consecutive Frame (0x2).
    • Flow Control Frame (0x3).

Single Frame (SF – 0x0) in CAN-TP (ISO 15765)

 
NetApp Jumbo Frames All You need T...
 
 
Pause
Unmute
 
Loaded: 40.01%
Remaining Time 6:13
Fullscreen
NetApp Jumbo Frames All You need To Know

In the ISO 15765-2 Transport Protocol (CAN-TP), a Single Frame is a type of message that is used to transmit data that can fit within a single CAN data frame. A Single Frame consists of a header and a data field, where the header contains information about the message, and the data field contains the actual data to be transmitted.

Single Frames are used to transmit small amounts of data, typically up to 7 bytes, that can be sent in a single CAN data frame. Single Frames are the simplest and most efficient way to transmit data in CAN-TP, as they require only one message to be sent and do not require any additional message framing or flow control mechanisms.

CAN-TP: Single Frame Format

If the data payload is 7-bytes or less than that, then the single frame will be used for the data transfer in CAN-TP Protocol. Where the first byte of the data field is used for addressing. Again this byte is divided into two divisions, where the MSB 4-bit is used for addressing of TP frame type called PCI (Protocol Control Information). The LSB 4-bit is used for the DLC (Data Length Code).

Example of Single Frame in CAN-TP (ISO 15765)

The below table shows an example of how the CAN-TP implemented in CAN Data field using Single Frame.

05 01 02 03 04 05 AA AA

CAN Datafield with CAN-TP Using Single Frame (Request: Client –> Server)

  1. PCI Header (0x05): 1 Byte Protocol Control Information Header. Where,
    • Last 4 MSB is “0” and it defines the Frame Type is Single Frame.
    • First 4 bit LSB is “5” and it defines the payload or datalength transmitted in Single Frame.
  2. Payload: Next 5 bytes are the original data (01 – 05) sent by the Transmitter ECU and 2 byte is empty (NULL).

Generally, if you are going to send less than 8 byte, you can use the Single Frame else to send the more than that you have to use the other 3 frames. 0xAA or ox55 is filled for NULL data bytes to make sure that no junk or corrupted data sent by the transmitter.

First Frame (FF – 0x1) in CAN-TP (ISO 15765)

In Controller Area Network – Transport Protocol (CAN-TP) ISO15765-2, the “First Frame” refers to the first message frame in a multi-frame message. This message type is used to initiate the transmission of a large data block. It includes information such as the total size of the data block and the size of each subsequent frame.

When a large message is sent over the CAN bus, it is divided into several smaller frames to ensure reliable and efficient transmission. The First Frame is used to initiate this process and contains important information about the message, such as its total length and the number of frames that will be used to transmit it.

The structure of the First Frame message is defined by the ISO15765-2 standard and includes a header that contains information about the message, such as the message length and a unique identifier (ID) that allows the recipient to associate the message with the correct application. The data field of the First Frame contains the first part of the message data, up to a maximum of 4096 bytes.

Once the First Frame has been successfully transmitted and received, the following frames, known as Consecutive Frames, are sent to transmit the remaining parts of the message data. The use of multiple frames allows for more efficient use of the available bandwidth on the CAN bus and ensures reliable transmission even in noisy environments.

The first frame is an initial message of the multi-frame message packet in CAN-TP Protocol. It is used when more than 6 or 7 bytes of data segmented must be communicated. The first frame contains the length of the full packet, along with the initial data. 

CAN-TP: First Frame Format

In FF, the first 2-bytes are used for the PCI, where the MSB 4-bit of the 1st byte is used for the type of frame and the LSB 4-bit and next 1-byte (total 8+4 = 12 bit)of the CAN data field is used for DLC (2^12 = 4096 data bytes). so in FF, only 6-bytes of the data can be transferred for the first time. This frame is responsible for sending the information to the receiver about the information as to how many total data bytes he is going to send.

Example of First Frame in CAN-TP (ISO 15765)

The below table shows an example of how the CAN-TP implemented in CAN Data field using First Frame.

10 64 01 02 03 04 05 06

CAN Datafield with CAN-TP Using First Frame (Request: Client –> Server)

  • PCI Header (0x1064): In FF, it is 2 byte.
    • Last 4 MSB is “1” is defining the Frame Type is First Frame.
    • First 4 LSB plus next 1 byte (Total = 4 LSB + 1 Byte) is Payload. 0x0 + 0x64 = 0x64 in decimal, it is 100 byte of data.
  • Payload: Next 6 bytes (01 – 06) are the original data that is sending to the receiver from total 100 bytes. So remaining 94 bytes will be sent consicutively by using the Consecutive Frames.

Consecutive Frame (CF) in CAN-TP (ISO 15765)

The Consecutive Frame or message type is used to transmit the data in consecutive segments. Each CF message contains a segment of data, as well as a sequence number that identifies the position of the segment within the larger data block.

The Consecutive Frame (CF) messages are used to transmit the actual data in a large data block. The size of each CF message is typically determined by the underlying CAN bus and network topology. The sequence number included in each CF message is used to ensure that the segments of data are received and reassembled in the correct order.

The primary task of the transport protocol or you can also CAN-TP Protocol is to transfer messages which cannot be transmitted as a single Protocol Data Unit (PDU) due to their length. Messages which contain more data that can be transmitted within a single PDU are segmented by means of the transport protocol and divided into multiple, separate PDUs. This procedure can also be implemented on the data link layer. The segmentation of the message must then be carried out in PDUs of the corresponding data link protocol.

CAN-TP: Consecutive Frame Format

In CF, the 1st byte is used for PCI byte, whereas the MSB 4-bit is defined for the type of frame and the LSB 4-bit is defined for the Sequence number. The sequence number always starts at 1 and increments with each frame sent (like as 1, 2,…, 15, 0, 1,…), with which lost or discarded frames can be detected. Each consecutive frame starts at 0, initially for the first set of the data in the first frame will be considered as 0th data. So the first set of CF(Consecutive frames) starts from “1”. There afterwards when it reaches “15”, it will be started from “0” by resetting the buffer register.

Example of Consecutive Frame in CAN-TP (ISO 15765)

The below table shows an example of how the CAN-TP implemented in CAN Data field using Consecutive Frame.

20 01 02 03 04 05 06 07

CAN Datafield with CAN-TP Using Consecutive Frame (Request: Client –> Server)

  • PCI Header (0x20): Here 20 is the 1 Byte PCI in CF.
    • Last 4 MSB is the Frame Type is “2” that defines the Consecutive Frame.
    • First 4 LSB is the Index of number or counter of blocks data is sends by the Transmitter ECU or node.Here it is “0” for the first consecutive frame.
  • Payload: Next remaining 7 bytes (01 – 07) are the original data to be sent to the receiver ECU or node.

Flow Control (FC) Frame in CAN-TP (ISO 15765)

The FC frame is the third and final message type in a three-frame sequence used for transmitting large data blocks that exceed the maximum size that can be transmitted in a single CAN message. This message type is used to manage the flow of data between the transmitter and the receiver. It includes information such as the number of consecutive frames that can be transmitted before the receiver must send an acknowledgement message.

The FC frame is sent by the receiver after it receives a CF message from the transmitter. The FC frame includes information such as the sequence number of the last received CF message, the status of the flow control mechanism, and the number of consecutive frames that can be transmitted by the transmitter before the receiver must send an acknowledgement message.

The information in the FC frame is used to manage the flow of data between the transmitter and the receiver to ensure that data is transmitted efficiently and reliably. By using flow control, the receiver can indicate to the transmitter how much data it can receive at any given time, preventing the transmitter from overloading the receiver with data and causing buffer overflow or other issues.

In conclusion, the flow control mechanism of the CAN-TP Protocol is used to configure the sender to match the properties of the receiver (timing, available receive buffer, readiness to receive). The FCF is always sent by the receiver so that to inform about the receiver capability of how the transmitter is going to send the data. 

CAN-TP: Flow Control Frame Format

 

The flow control frame contains 3 bytes which together form a PCI in CAN-TP Protocol.

  • The first byte begins in the upper four bits with a value of 3, indicates that there is flow control. In the four least significant bits of the first byte shows a Flow Status (FS). Thus the transmitter to the receiver can signal whether a segmented transmission Clear To Send (CTS), Wait or Overflow.
    • FS = 0: Clear to Send.
    • FS = 1: Wait.
    • FS = 2: Overload.
  • The second byte BS stands for Block Size and shows how many consecutive frames need to be sent. So the Block Size is nothing but the number of Consecutive Frame.
  • The last byte STmin shows the minimum separation time between consecutive frames to be noticed.

Example of Flow Control (FC) Frame in CAN-TP (ISO 15765)

30 0A 14 AA AA AA AA AA

CAN Datafield with CAN-TP Using Consecutive Frame (Request: Server –> Client)

  • PCI Header: The total Flow Control Frame is PCI data and it is 3 byte.
    • 0x30: First 4 MSB is “3” and it defines the Type of Frame that is Flow Control and Last 4 LSB is “0” that defines the Flow Status that is clear to send.
    • 0x0A: This second byte is a 1 byte Block Size (BS) nothing but the number of Consecutive Frames. So here the receiver is informing to transmitter ECU to send the next 0x0A or 10 (in decimal) blocks or consecutive frames.
    • 0x14: This third byte is a 1 byte STmin Time period in milli Second. Here it is 0x14 nothing but the 20 (in decimal). That means the Transmitter ECU will send each CF in the delay of 20 milli second to the receiver ECU or node.

An ISO-TP frame is always 8 bytes long and unneeded bytes filled with the padding byte as 0xAA or 0x55.

Working Principle of CAN-TP (ISO 15765)

There are two types of data transfer methods of CAN-TP Protocol: single-frame data transmission and multiple data transmission. The single-frame data transmission (Unacknowledged Unsegmented Data Transfer) and the Multi-frame Data transmission (Unacknowledged Segmented Data Transfer). In a CAN frame, there is a maximum of 8 data bytes of user data. The data length of the ISO TP message can reach a maximum of 4095 bytes. If an ISO TP message length exceeds the data length of 8 data bytes, the UDS message must be segmented.

The CAN-TP protocol works by dividing large data into smaller packets called Transport Protocol Data Units (TPDUs). These TPDUs are then transmitted over the CAN bus, with each TPDU containing a sequence number and checksum to ensure data integrity. The receiver then reassembles the TPDUs into the original data message.

Single Frame Communication

CAN-TP ISO15765 Single Frame Communication

Multi-Frame Communication

CAN-TP for Multi-Frame Communication

Below is an example of how the CAN-TP protocol could work in a client-server communication scenario:

  1. The client sends a large data message to the server, which exceeds the maximum size of a single CAN message.
  2. The client software breaks the large message into smaller TPDUs, each with its own sequence number and checksum.
  3. The client software sends the TPDUs to the server over the CAN bus by using the First Frame (FF).
  4. The server software receives the TPDUs and verifies the sequence numbers and checksums to ensure that all packets have been received and that the data is intact.
  5. Once all TPDUs have been received and verified, the server software reassembles the TPDUs into the original data message.
  6. The server software then sends an Flow Control message back to the client, indicating that how, when, & How much the data should be send by the Transmitter ECU.
  7. The client software receives the acknowledgement message (FC message) and can continue with its operations by using the Consecutive Frames until the next command from Receiver ECU or as per the Flow Control data or information provided by the Transmitter ECU.

Error Handling in CAN-TP (ISO 15765)

In CAN-TP Protocol, Both the transmitter and receiver monitors the data transmission with a timer. The receiver monitors the time required by the transmitter for sending Consecutive Frames. If this takes a long time, the transmission is aborted and data already transmitted are discarded. Similarly, the transmitter monitors the time for the receiver to send the flow control frame. Again the transmission is aborted and data already transmitted are discarded if a timeout is detected. The maximum waiting time for a frame is one second.

Generally, In addition to timing errors, errors in the message structure must be recognized. If an erroneous PDU is detected the frame is ignored or if a transmission is in progress, canceled it. Possible errors in the message structure are incorrect sequence numbers in consecutive frames, invalid message length, and invalid flow status in the flow control frames or an invalid PDU type. Unexpectedly arriving frames are always ignored, with the exception of a single frame and physically addressed the first frame. Functionally addressed first frame, consecutive frame, and flow control are always ignored.

How to send 100 bytes of data using CAN-TP Protocol?

I hope after learning this tutorial, you will be able to write this answer in below comments. Thank you everyone for giving your time to learn step by step about the CAN-TP Tutorial.

'경로 및 정보' 카테고리의 다른 글

임베디드 레시피 Debug  (0) 2023.07.18
Content-Type 이란  (0) 2023.06.27
source insight 메뉴얼 등  (0) 2023.06.20
ELF 파일 포맷  (0) 2023.05.30
솔라나 스마트 컨트랙트 만들어보기  (1) 2023.05.08
블로그 이미지

wtdsoul

,