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.

Back to: CAN Basics Training: A Practical Introduction to the CAN bus > Basics