[MUSIC] This lecture we'll talk about what a protocol stack is, really define that term. We will go into a little bit of detail, little bit of information about how a protocol stack is defined. Now remember though, that in practice certainly in this specialization, in practice you're not gonna be writing a protocol stack, making a protocol stack, but you can use a protocol stack. So you at least would wanna know what this term is because it gets thrown around, right. If you want to make a new embedded system you say, well I need to be networked, you know Internet, which protocol stack am I going to use, right? Which implementation of the protocol stack will I use? You need to know what that term means, because it gets used a lot when you're actually coding things. You should know basically what it means. So not all the details that I'm talking about will be important in the long run, but you should see it all at once because it'll give you a better context about what you're using. So OSI Layer Concept. So the idea about taking these protocols and making a stack, different layers of protocol, is that you've got these multiple layers, different tasks, different networking tasks that you have to handle. These tasks are associated with different layers of protocol stack. And each layer is implemented usually in software, actually some of the lower layers are implemented in hardware. So some are in hardware, some are in software. The difference doesn't matter too much to us right now certainly the top layers are in software, but the idea is that a message, say you want to send a message okay. So you make this message, we got our picture up here, this message M. M is our message, and that's maybe just the pay load okay. That is what the data we want to send. So then that is basically an input to a layer. Let's talk about the first layer, layer R let's say is the first layer, the top layer. So that goes into it and into the code, so that code takes the message, it makes some kind of a decision, whatever decisions are made at that layer, and then it puts the results of that decision into the header of the message producing a new message, M prime down there, which is now bigger. It has whatever was inside M and it has additional header on the outside of that, right? So at every level every level that happens. So, the first level, for instance here, let's see this level is performing routing. So the goal of this level is to take a message and figure out a sequence of machines that it will hop through to get to its destination. So at this level it takes a message, it finds the route, it says okay you need to go through machines A, B, C, and D. All right, that sequence. So it can take a sequence, that whole sequence of nodes, put that into the header of the message, and then output this new message, M prime. Which is the same old message, but now with this extra routing message contained inside the header. So that's the general idea, that at every layer the code, or the hardware, or whatever it is that's implementing the protocol, will make some decisions like routing information, arbitration information, flow control information. And then the results of that it'll put into the header, or some of the results, it'll put directly into the header, and you'll get a new message out, which is bigger than the original one, right? Which now has its new header data. This is on the sending side. So this is the idea, and you have a stack of these layers. So that's what they mean by protocol stack, you have layer after layer and they call that a stack. Now, encapsulation is used to mean that the protocols they're separated from one another, in some sense. So, each layer, each protocol layer is separated. So, all these different tasks that need to be performed, say routing. That is mapped to a particular layer. That is performed by the protocol information stack at this layer and other layers do not have to deal with it. So it is encapsulated, it's separating the different layers. And the whole point of that is to make it simpler to understand and also to write code. All right, so as a programmer, if you're dealing with the layer that deals with routing, then that's all you have to think about, you don't have to think about flow control because flow control is dealt with at another layer. So that's what encapsulation generally means. And a protocol stack is the implementation of all the different layers put together. So a transmission, when want to send a message, basically the messages start at the top layer and then they go down. So you put the messages into the top layer protocol. It makes its decisions, adds to the header, passes it to the next layer, which adds, makes some decisions, adds to the header and continues, until you get to the bottom layer. Now the bottom layer is called the physical layer, and at that layer it actually takes the data and puts it on to an electrical mechanism, a transmission mechanism, some kind of medium. So that means one of two things, either wire, so a physical layer, it codes the data onto physical wires, or it encodes it onto wireless broadcasts, radio broadcasts, so one of the two. So always at the bottom layer there's this physical layer, which actually transmits the signal either by wire or through the air through radio. Now, at the receiving end, the message comes in. Remember, it's sent physically, right? So it's on wires, it's a bunch of electrical signals on wires, or it's sent through the radio. So at this end, the messages go up through the same protocol stack. So that means when it's received, it's received at the physical layer, right? Because it's physical signals, either wired or wireless. They come in, and then they have to get basically recoded back to the original data. So now at the receiving end, these messages are going through the protocol stack up, from bottom up. So the opposite of what happened on transmission happens here. At every layer, the message gets received, the appropriate header information is read and used, and then the new message that's produced is actually smaller than the first message, minus that header information, right? And then it goes up to the next layer, which takes the header information at that layer it uses that and then produces a new message which is smaller. And so by the end at the top all you have is the actual payload and all the header information has been stripped off. So that what happens at the receiving end and it's the reverse of what happens at the transmission side. Thank you. [MUSIC]