Communications layers, the Protocol Stack!
The CAN Basics Training Course provides a practical approach to understanding how CAN works. By giving real world examples, common practices, and an in-depth look at DBC files, Bryan Hennessy gives a real-world walkthrough of CAN.
Presentation by Bryan Hennessy. Recorded as part of a โliveโ training session in January 2019.
Video Transcript:
Bryan Hennessy: [00:00:01] I mentioned communication layers and a Protocol Stack, the intimidating terms that weโre going to clear up here, and thatโs what Iโm going to jump into right now. Iโll fall back to that a lot. Now make some notes on that. One of my main slides that I created is here with those layers that weโre going to explain and Iโll hopefully draw some notes out here to the right of those and show you how to interpret those and what goes on in those layers as we go. So this is, I think, a pretty good format for that. But youโll see that slide right there quite a bit. In fact, itโs the next slide up.
So, this slide I created a few months ago just to try and get this message apart. I modified it, itโs changing as time goes on as I learn how itโs accepted by the people that Iโm working with on it. So, a basic CAN bus, the wiring on a basic CAN bus, weโll get into a little bit more but the basic CAN bus has what we call the trunk and drop cables. [00:01:01] So, literally, a trunk cable is between two terminators. Thereโs a terminator on each end. Drop cables come off of that and go to the smart sensors or controls or displays or ECUs or whateverโs out there. Thatโs really the basics of a CAN bus. Every CAN bus in the world has two terminators of trunk cable and drop cables. Thatโs just how it is in every industry, in every application. Thatโs how they look. Thatโs what CAN is made to run on.
Thatโs part of what I call the physical layer. The best way to understand the physical layer is the job of the physical layer is no more than getting 1โs and 0โs from one device to the other on that network, reliably sending 1โs and 0โs which is what all digital communications of course works on. Thatโs its whole job. It doesnโt have anything to do with the frame, it doesnโt have anything to do with a protocol, it doesnโt have anything to do with J1939 or CANopen; itโs just there [00:02:01] to get the 1โs and 0โs across.
So when once you can get 1โs and 0โs reliably consistently across the network, your physical layer is good. Thatโs the best way to separate the physical layers. I understand that from all of the other more complicated stuff that works depending on how you look at it above that or below that in the Protocol Stack. So when you hear the term Protocol Stack, donโt be intimidated by that. Theyโre just referring to the different as theyโre broken up so-called layers of the communication stack. Some people donโt really like the term layers, and I started to get away from using the term layers but thatโs all you hear everywhere in the industry, is people talk about the data link layer. People talk about the applications layer. So I went back to it just because I want people to get more comfortable and more familiar with that term. Whether itโs right or not, whether you believe itโs a good concept or not, itโs used in the industry. Itโs not going away. [00:03:01] Weโre stuck with it. So weโre going to use the term layers quite a bit here.
The next, from the physical layer once you get the 1โs and 0โs across the network, we have to understand how to break up and understand what those 1โs and 0โs represent, and thatโs done via what we call the data link layer. The data link layer takes all the 1โs and 0โs if the physical layer can reliably send across the network and it packages them, if you will. It packages them in an understandable format called a CAN frame. And weโll get very extensively into a CAN frame and take a frame apart so you understand the different parts of the CAN frame.
The next one from that, which is sometimes used but not always, and Iโll explain why, is called the transport layer. A CAN frame is eight data bytes, only eight data bytes. A lot of data we want to send [00:04:01] is a lot more than eight data bytes. So a transport layer allows the packaging of messages that are more than eight data bytes. Allows the transmitter to package them in a number of different frames and allows a receiver, or receivers, to take them apart and understand what they are and reassemble the message, longer message, basically. The transport layer, as Iโll show the next slide, is different for different protocols, for different communication systems, whether it be NMEA 2000, or J1939, or CANopen, or others, they all have their own transport layer or transport protocol.
So once you get past the data link layer, youโre no longer really talking about the CAN standard. Youโre talking about a J1939 or youโre talking about a CANopen. Theyโre talking about some other standards. So CAN really is defined here. [00:05:01] This is where CAN is. You can send J1939 or you can send CANopen or NMEA 2000 over Ethernet. So it can be repackaged and sent over a different media, but this is where CAN is defined. This is where CAN is used as in these two layers. Weโll talk more about that, but these are standards or definitions that are communicated in different standards.
So I took this slide and I wanted to add more complexity to it. It was starting to get full and complicated. So I kind of broke it out into the next slide. I used the same colors in the next slide and I just added a little bit of a text to it to prompt me to talk about the right things here. So, these are the same four layers. I show the transport layer [00:06:01] as not always being used by showing it off to the side with the dotted line. Many messages arenโt affected by the transport layer in their communication system. So theyโre just passed directly from data link to applications if their messages were only eight data bytes, as I said.
So, we got the physical layer on the left. It defines the wires, the baud rate, bit timing and basically again sends 1โs and 0โs, thatโs a very important thing to remember about the physical layer, its main job, its only job.
The data link layer, again, defines the frames, the structure, and it sends and receives CAN frames so that we can put a box around and understand what the data is. Transport layer, again, is with different high level protocols. Itโs called different things. It may work in different ways. Theyโre not compatible. But like I say, Fast Packet is what NMEA 2000 developed and Fast Packet is [00:07:01] specific and good for what marine electronics needed at the time. The transport protocol is what itโs called in J1939. Itโs different in that. It has quite a bit of limitations there. I wonโt get into that because thatโs a lot of detail. But an interesting point of a comment here is that when they hired on PACCAR Technical Center a number of years ago, they require a real thorough presentation, a half an hour presentation on some real technical subject and they all really critique you on that presentation. Thatโs part of getting a job there. They say thatโs the hardest part. Well, my presentation was contrasting the transport protocol and the Fast Packet protocol. So I went and I still use some of the slides I developed for that presentation. I think thereโs some of that material in here. So itโs neat stuff when you really look at it at the bit level.
Iโve been recently studying CANopen, and thereโs something called an SDO block transfer [00:08:01] that transfers messages more than eight data bytes in CANopen.
Any questions so far? The layer concept, hopefully, is starting to make more sense now.