timing analysis of linux based can to can gateway
play

Timing Analysis of Linux-Based CAN-to-CAN Gateway Michal Sojka - PowerPoint PPT Presentation

Timing Analysis of Linux-Based CAN-to-CAN Gateway Michal Sojka Czech Technical University in Prague Faculty of Electrical Engineering sojkam1@fel.cvut.cz February 3, 2011 Center for Applied Cybernetics Embedded Systems Colloquium Michal


  1. Timing Analysis of Linux-Based CAN-to-CAN Gateway Michal Sojka Czech Technical University in Prague Faculty of Electrical Engineering sojkam1@fel.cvut.cz February 3, 2011 Center for Applied Cybernetics Embedded Systems Colloquium Michal Sojka Timing Analysis of Linux-Based CAN-to-CAN Gateway February 3, 2011 1 / 21

  2. Outline Introduction Testbed Description Results Conclusion Michal Sojka Timing Analysis of Linux-Based CAN-to-CAN Gateway February 3, 2011 2 / 21

  3. Introduction SocketCAN ◮ Open-source project, official CAN-bus support for Linux kernel ◮ Initiated by Volkswagen research – first open source project where Volkswagen participates ◮ Core developers also from a few other companies ◮ Contributors from many other people ◮ In mainline Linux since 2.6.25 ◮ Based on standard Linux networking infrastructure ◮ http://socketcan.berlios.de Michal Sojka Timing Analysis of Linux-Based CAN-to-CAN Gateway February 3, 2011 3 / 21

  4. Introduction SocketCAN-based Gateway ◮ Routes CAN frames between multiple CAN buses. ◮ Frames can be modified (ID, length, data) ◮ Modifications: SET, AND, OR, XOR, CRC ◮ Can filter frames based on ID/mask pairs. ◮ Implemented as Linux kernel module ◮ Easy to use Michal Sojka Timing Analysis of Linux-Based CAN-to-CAN Gateway February 3, 2011 4 / 21

  5. Introduction The Goal of our Work ◮ Timing analysis of the gateway ◮ How are the routed frames delayed by the gateway? ◮ What influences the delays (latencies)? ◮ Traffic patterns, ◮ additional load, ◮ gateway configuration, ◮ Linux kernel version. ◮ Volkswagen uses the gateway for fast prototyping. It works well for them and they wanted to know where are the limits. Michal Sojka Timing Analysis of Linux-Based CAN-to-CAN Gateway February 3, 2011 5 / 21

  6. Testbed Description Testbed Setup ◮ Gateway – PowerPC MPC5200 ◮ PC – Pentium 4, Kvaser PCI quad-CAN SJA1000-based Michal Sojka Timing Analysis of Linux-Based CAN-to-CAN Gateway February 3, 2011 6 / 21

  7. Testbed Description Measurement Methodology ◮ Bus bit-rate 1 Mbps ◮ Frames are sent from can0 ◮ Received on can1 and can2 ◮ Receive timestamps are taken by the driver at interrupt time – SO_TIMESTAMPNS socket option ◮ Timestamps with nanosecond precision (TSC) ◮ Same clock for both timestamps – no problems with time synchronization between computers msg 1 CAN bus 0 CAN bus 1 msg 1' time message latency Michal Sojka Timing Analysis of Linux-Based CAN-to-CAN Gateway February 3, 2011 7 / 21

  8. Testbed Description Measurement Measurement II. ◮ Traffic patterns: ◮ one message at a time, ◮ 50% bus load, ◮ flood (almost 100% bus load) ◮ Additional loads: ◮ CPU load – hackbench ◮ Ethernet load – ping -f -s 6000 ◮ Versions: ◮ Latest SocketCAN from SVN (rev 1199 + fixes) ◮ Kernel: 2.6.33, 2.6.33-rt, 2.6.36 Michal Sojka Timing Analysis of Linux-Based CAN-to-CAN Gateway February 3, 2011 8 / 21

  9. Results Precision and Presentation of Results No GW, two interfaces in PC (GW kernel 2.6.33.7-00007-g9c0ff90, Traffic 50, Load none) 10000 2 byte messages 4 byte messages Latency profile [messages] 6 byte messages 8 byte messages 1000 100 10 1 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5 Time [ms] ◮ Two points ( t 1 , m 1 ) and ( t 2 , m 2 ) : t 1 < t 2 ⇒ m 1 − m 2 frames had the latency in the range [ t 1 , t 2 ) . ◮ The right most point ( t w , m w ) : m w frames with the latency of t w . Michal Sojka Timing Analysis of Linux-Based CAN-to-CAN Gateway February 3, 2011 9 / 21

  10. Results Simple Gateway Single GW job for all messages, no modifications Single GW job for all messages, no modifications (GW kernel 2.6.33.7-00007-g9c0ff90, Traffic flood, Load none) (GW kernel 2.6.33.7-00007-g9c0ff90, Traffic flood, Load none) 10000 0.3 2 byte messages 2 byte messages 4 byte messages 4 byte messages Latency profile [messages] 6 byte messages 6 byte messages 0.25 8 byte messages 8 byte messages 1000 Latency [ms] 0.2 100 0.15 10 0.1 1 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0 1 2 3 4 5 6 7 Time [ms] Time [s] Michal Sojka Timing Analysis of Linux-Based CAN-to-CAN Gateway February 3, 2011 10 / 21

  11. Results Frame Filtering 2048 GW jobs (one per id, mask C00007FF), no modifications Two types of filters (GW kernel 2.6.33.7-00007-g9c0ff90, Traffic oneatatime, Load none) 10000 Message id 0 ◮ SFF frames (11 bit ID), Message id 255 Latency profile [messages] Message id 511 Message id 767 1000 single ID Message id 1023 Message id 1279 Message id 1535 Message id 1791 ◮ Implemented as lookup 100 Message id 2047 table (by ID) 10 ◮ Fast 1 0.05 0.1 0.15 0.2 0.25 0.3 ◮ Top figure Time [ms] ◮ EFF frames (29 bit ID) or 2048 GW jobs (one per id, mask 0x7FF), no modifications (GW kernel 2.6.33.7-00007-g9c0ff90, Traffic oneatatime, Load none) 10000 filters matching multiple Message id 0 Message id 255 Latency profile [messages] Message id 511 frames (mask) Message id 767 1000 Message id 1023 Message id 1279 ◮ Implemented as linear Message id 1535 Message id 1791 100 Message id 2047 list 10 ◮ Latency depends on ID ◮ Bottom figure 1 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 Time [ms] Michal Sojka Timing Analysis of Linux-Based CAN-to-CAN Gateway February 3, 2011 11 / 21

  12. Results Frame Filtering under Heavy Traffic 2048 GW jobs (one per id, mask 0x7FF), no modifications (GW kernel 2.6.33.7-00007-g9c0ff90, Traffic flood, Load none) 10000 Message id 0 Message id 255 Latency profile [messages] Message id 511 1000 Message id 767 Message id 1023 Message id 1279 Message id 1535 100 Message id 1791 ◮ Packet processing takes Message id 2047 10 longer time ⇒ packet losses 1 0.1 1 10 100 Time [ms] ◮ The effect of hardware 2048 GW jobs (one per id, mask 0x7FF), no modifications (GW kernel 2.6.33.7-00007-g9c0ff90, Traffic flood, Load none) buffers (bottom figure) 100 Message id 0 Message id 255 Message id 511 ◮ MPC5200 has 4 hardware Message id 767 10 Message id 1023 Latency [ms] Message id 1279 Message id 1535 buffers Message id 1791 Message id 2047 1 0.1 0 2 4 6 8 10 12 14 16 18 20 Time [s] Michal Sojka Timing Analysis of Linux-Based CAN-to-CAN Gateway February 3, 2011 12 / 21

  13. Results Frame Modification Single GW job for all messages with modifications, 8 byte messages (GW kernel 2.6.33.7-00007-g9c0ff90, Traffic oneatatime, Load none) 10000 Latency profile [messages] 1000 100 No modifications 10 T wo modifications Four modifications Four modifications and XOR checksum Four modifications and CRC8 checksum 1 140 150 160 170 180 190 200 Time [µs] ◮ Perpetum mobile – the more work to do, the less time it takes. ◮ Wrong branch prediction? No. Difference under 1 µ s . Michal Sojka Timing Analysis of Linux-Based CAN-to-CAN Gateway February 3, 2011 13 / 21

  14. Results Multi-Hop Routing with Virtual Interfaces MPC5200 GW0 GW(n+1) id id id+n id+n can0 vcan0 can1 nop nop id id+n id+1 id+2 id+1 i d + n - 1 GW1 GW2 GWn id ⇒ id+1 id ⇒ id+1 id ⇒ id+1 Figure: Multi-Hop gateway with a single virtual CAN interface (vcan0). MPC5200 GW0 GW1 GW2 id+1 id+2 id id+1 id+2 id+3 can0 vcan0 vcan1 can1 id ⇒ id+1 id ⇒ id+1 id ⇒ id+1 Figure: Multi-Hop gateway with several virtual CAN interfaces. Michal Sojka Timing Analysis of Linux-Based CAN-to-CAN Gateway February 3, 2011 14 / 21

  15. Results Multi-Hop Routing with Virtual Interfaces Chained GW jobs on a single VCAN interface Chained GW jobs on multiple VCAN interfaces (GW kernel 2.6.33.7-00007-g9c0ff90, Traffic oneatatime, Load none) (GW kernel 2.6.33.7-00007-g9c0ff90, Traffic oneatatime, Load none) 10000 10000 2 GW jobs, 1 vcan 1 GW jobs, 0 vcans 4 GW jobs, 1 vcan 2 GW jobs, 1 vcans Latency profile [messages] Latency profile [messages] 6 GW jobs, 1 vcan 4 GW jobs, 3 vcans 1000 8 GW jobs, 1 vcan 1000 6 GW jobs, 5 vcans 10 GW jobs, 1 vcan 8 GW jobs, 7 vcans 12 GW jobs, 1 vcan 10 GW jobs, 9 vcans 100 100 10 10 1 1 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.1 0.15 0.2 0.25 0.3 0.35 0.4 Time [ms] Time [ms] ◮ Goal: evaluate the internals of the gateway and SocketCAN infrastructure. ◮ Result: nothing unexpected – the more hops, the more time. ◮ Every additional hop adds approximately 11 µ s . Michal Sojka Timing Analysis of Linux-Based CAN-to-CAN Gateway February 3, 2011 15 / 21

  16. Results Kernel-Space vs. User-Space routing – Non-rt Kernel Kernel vs. userspace GW, no modifications Kernel vs. userspace GW, no modifications (GW kernel 2.6.33.7-00007-g9c0ff90, Traffic oneatatime, Load none) (GW kernel 2.6.33.7-00007-g9c0ff90, Traffic flood, Load none) 10000 10000 Userspace GW, 2 byte messages Userspace GW, 2 byte messages Userspace GW, 8 byte messages Userspace GW, 8 byte messages Latency profile [messages] Latency profile [messages] Kernel GW, 2 byte messages Kernel GW, 2 byte messages Kernel GW, 8 byte messages Kernel GW, 8 byte messages 1000 1000 100 100 10 10 1 1 0.1 1 10 100 1000 0.1 1 10 100 1000 Time [ms] Time [ms] ◮ Kernel-space has much lower overhead. ◮ Kernel-space handles even flood traffic without problems. Michal Sojka Timing Analysis of Linux-Based CAN-to-CAN Gateway February 3, 2011 16 / 21

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend