NFC APDU READ command performance tuning

旧巷老猫 提交于 2019-12-03 20:27:54

I modified my reads to use ADDITIONAL FRAME.

This reduced the total bytes sent+received from 1628 to 1549 bytes, a 5% reduction.

The time used by tranciecve() was reduced from 602ms to 593ms, a 1.5% reduction.

The conclusion is that use of AF will not give additional performance other that the reduced time for bytes transfered.

The finding also indicates that since the time was reduced by a much lower factor than the data reduction, there must be operations that introduce significant latency that is not dependent on the data trancieved, but ReadFile is not the one.

Authenticate, SelectApplication or ReadRecord may be significantly more expensive than the time used for data transfer.

(Wanted to write a comment, but it got quite long...)

I would use the ADDITIONAL FRAME (AF) way, some reasoning follows:

  • in addition to the mentioned 7 bytes saved in the command, you save 4 MAC bytes in all of the responses (but the last one, of course)

  • every time you read 54 bytes, you wastefully MAC 2 zero bytes of padding, which might have been MACed as data (given by DES block size of 8). In the "AF way" there is only a single MAC run covering all the data, so this does not happen here

  • you are not enforcing the actual frame size. It is up to the reader and the card to select the right frame size (here I am not 100% sure how DESFire handles the ISO 14443-4 chaining and FSD)

  • some readers can handle the AF situation on their own and (magically?) give you the complete answer (doing the AF somehow in their firmware -- I have seen at least one reader doing this)

If my thoughts are (at least partially) correct, these points make only 9ms difference in your scenario. But under another scenario they might make much more.

Additional notes:

  • I would exclude the SELECT APPLICATION and AUTHENTICATE from the benchmark and measure them separately. It is up to you, but I would say that they only interfere with the desired "raw" data transfer measurement

  • I would recommend to benchmark the pure "plain data transfer" mode which is (presumably) the fastest "raw" data transfer possible

Thank you for sharing your results, not many people do so...Good luck!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!