My CAN bus is running at 125 kbit/s and is using extended frame format exclusively. I would like to know what's the maximum rate of CAN frame I can send out. Suppose the data length is always eight bytes.

According to this Wikipedia page, each frame has a maximum frame length of (1+11+1+1+18+1+2+4+64+15+1+1+1+7) = 128 bits:

Enter image description here

Taking into account of a minimum three bits interframe spacing, the maximum packet rate under 125 kbit/s should be: 125000 / ( 128 + 3) = 954 frames per second.

But in my test, I couldn't get that high. The maximum frame rate I can achieve (with all eight bytes data) is around 850 frames per second.

What's wrong here - my calculation, or my test method?

  • \$\begingroup\$ Look at it with a scope and see what you are actually getting. Perhaps your hardware isn't ready to transmit a new frame after immediately after having sent one. Also, are you taking the ACK time into account? Your unlabeled sum of bits is not helpful in telling us what exactly you are counting. \$\endgroup\$ Jul 15 '14 at 16:34
  • \$\begingroup\$ In practice, it's hard to get 100% bus utilisation for any extended time over a CAN bus, due to the need for ACK times and interframe spacing. Your CAN controller may not be able to support 100% bus utilisation for any extended length of time. \$\endgroup\$
    – Tristan
    Jul 15 '14 at 16:49
  • 2
    \$\begingroup\$ Depending on exactly what data you're sending, bit stuffing can increase your frame size by up to 10%. \$\endgroup\$ Jul 15 '14 at 17:06
  • 1
    \$\begingroup\$ @xiaobai - No, the length of the data field changes. As for a link, you already provided it. Read the entire page. If your tests are sending all zeroes or all ones, that would explain a lot. \$\endgroup\$ Jul 16 '14 at 11:23
  • 2
    \$\begingroup\$ ACK can effect the transmission time if you're not accounting for it. Again, your unlabeled mess of summed numbers doesn't tell us what you are really adding up, and therefore what you might be missing. \$\endgroup\$ Jul 16 '14 at 11:56

Per Olin Lathrop's suggestion, I'll expand on bit-stuffing.

CAN uses NRZ coding, and is therefor not happy with long runs of ones or zeroes (It loses track of where the clock edges ought to be). It solves this potential problem by bit-stuffing. When transmitting, if it encounters a run of 5 successive ones or zeros it inserts a bit of the other polarity, and when receiving, if it encounters 5 successive ones or zeroes it ignores the subsequent bit (unless the bit is the same as the previous bits, in which case it issues an error flag).

If you are sending all zeroes or all ones for your test data, a string of 64 identical bits will result in the insertion of 12 stuffed bits. This will increase total frame length to 140 bits, with a best-case frame rate of 874 frames / sec. If the data bits are the same as the MSB of the CRC, you'll get another stuffed bit there, and the frame rate drops to 868 frames/ sec. If the CRC has long runs of ones or zeroes, that will reduce the frame rate even further. The same consideration applies to your identifiers.

A total of 16 stuffed bits will produce an ideal frame rate of 850.3 frames/sec, so you ought to consider it. A quick test would be to use test data with alternating bits, and see what happens to your frame rate.

  • 3
    \$\begingroup\$ Yes, in my original test there are indeed lots of zeros in the payload and the ID. After I make sure there are no 5 successive zeroes either in the data or the ID, now I can get 940 frames/sec, very close to the calculated limit. Thanks a lot for the great answer. \$\endgroup\$ Jul 17 '14 at 14:30

The smallest 2.0a (standard) frame you can build is 47bits ...The smallest 2.0b (extended) frame you can build is 67bits ...That INcludes 3bits of inter-frame spacing, and EXcludes bit stuffing ...In theory we can build a frame which will never stuff; In reality, bit stuffing is going to happen quite a lot!

The maximum baud for CANBus 2.0a/b is 1Mbit.
At 1Mb/S, a single (dominant/recessive) bit is 1uS long, ie. 0.000'001 S
So a 67bit frame [the smallest theoretical 2.0b frame] will take 67uS to transmit - before another (67bit) frame may be transmitted.
1'000'000 / 67 gives 14,925 complete frames (+ 25bits of the next frame)

As you are running at 1/8th of that speed, you can get at most 1/8th of the packets
14'925 / 8 = 1'865 frames/Second @125Kb

By the time you are using all 64bits (8bytes) of data, and ASSUMING you have not triggered bit stuffing "errors" by having strings of consecutive 1's or 0's
1'000'000 / (67 + 64) = 7'633
7'633 / 8 = 954

And that's also assuming your wiring is perfect. Is your can bus made from 120ohm UTP cable and capacitively decoupled at both ends? Or some random wire with a 120ohm resistor across one end?

Overall I would say you're doing pretty well to get 90% of theoretical maximum throughput.


Olin is right on with his description of bit stuffing and how that can adversely affect theoretical CAN throughput. One other thing that can further degrade actual throughput from theoretical is latency. Even if your CAN controller is able to achieve 100% bus utilization, the host processor may not be able to handle Tx and/or Rx at that rate. This could be the result of a slow processor and/or inefficient firmware that implements the CAN stack.


Another interesting question from the perspective of a receiver would be

What ist the worst case maximum frame transfer frequency?

For this case stuff bits can be likely ignored, since they make the frequency lower.


Looking just to standard identifier frames:

For data lenght 1 you would have to calculate with

55 Bits (minimum overhead + 8 data bits + 3 interfame space)

--> maximum frame fequency for 1 Mbit is about 18181.8/s (1/0.000055)

For data lenght 0 (can be also an information) you would have to calculate with

47 Bits (minimum overhead + 3 interfame space)

--> maximum frame fequency for 1 Mbit is about 21276.6/s (1/0.000047)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.