 So, we have a two-bit sequence number, in fact the question tells you that that gives us a maximum window size of three, there should be a parenthesis there, which is the two to the k minus one, two to the power of two is four minus one, maximum window size is three, there's some paper up there if anyone's missing, then we're looking at the state of the destination node, the receiver. Remember it keeps track of three variables that tell us the split in this diagram, it tells us the split between these four sets of frames. The last frame acknowledged from the receiver's perspective, remember it receives data and sends back acts, so last frame acknowledged was frame number zero. The current window size is one frame, meaning it contains one frame, not sequence number one, but contains one frame, in fact there's a third variable, remember there's, in the diagram there's this vertical bar and there's the window, the blue box, and we use three variables to keep track of those. Last frame act, current window size and you'll see for the destination the last frame received as well. You need to determine that, what is the last frame received, and then you can move on to this part, which is, okay if we have some state and then we receive a frame and send an act with some act number, what's the next state? So try and draw the diagram, the vertical bar and the window for the initial state, the current state, that is with these two values, then you'll draw the diagram of what happens after we receive a data frame and receive an act. So first try and draw this diagram that captures this information, but for that to be complete you need to work out one more thing, the last frame received. If you don't remember those variables and what they mean, go look in your lecture notes on that slide about what the receiver stores. If you need one of these diagrams you can either draw your own or use this paper. I'll just briefly go back to the lecture notes. We're focusing on the receiver, the destination in this question, and this slide and you look in your own lecture notes explains that the receiver records three things, last frame act, last frame received, current window size. And they are related to the diagram in this way. Last frame act, last frame received, window size. What I want you to do, given the question, first try and draw this picture on that piece of paper provided where I've given you last frame act and current window size. You will need to determine what is the last frame received. Then consider what happens when you receive a data frame and send an act. What's the next state? This is not about efficiency or the change. In this case you need two diagrams. The current state and for that you use the last frame act equals zero. The current window size is one frame. You need to calculate what is the last frame received from the information provided. And from that you can draw your first diagram. Where's your picture? That's more interesting. The last frame acknowledge is zero so it should be here. But then the second one is after ready and two is done so it should be here. Or something. I have no idea what I'm doing. This looks correct. This doesn't. Yeah, is this correct? Which one? the answer? First state. Where is this? Okay, try and draw this vertical bar just to help visualise the split between there and there. Correct? Last received will be the frame two, and then it receives a receipt ready for frame two, which means last received becomes free after the transmission. Last received, okay. Can you say because it turns into here? The vertical line. The vertical line. Last act. Last act is one, because previously last act, because you received a receipt ready of two, which means last act is one, because a receipt ready of two is an act of one. I'll show another one in a moment. The first thing you need to do is look at the current state and forget about the second paragraph, but the current state, the destination, recall that we use three variables to record the state. The last frame act means the last frame, the number of the last frame that we've received and also acknowledged, which really is the last one that's done, complete, successful. And then the second thing, not given here is, okay, from the receiver we receive some frames, but we haven't yet act, and we can call that the last frame received, but not yet act. That's not given, but what's given is also the current window size of one frame, which means that in the window we're allowed or we expect to receive one more frame. Now, from the question, the maximum window size is three frames. So the maximum size is three. In this current state, we expect to receive one more. That implies that there must be two frames that have been received at this point in time. So two frames received and not yet act. So you think two frames stored in memory in the buffer, because if the maximum window is three and we've got a current window of one, meaning we're allowed to send one more, means two must be received. So you need to draw that, and I'll draw it on the board to get started. The last frame act was zero here. So to visualize this, so I'm going to separate, okay, let's separate those that have been act, everything before here, those that haven't been act. The current window size is one frame, that it contains one frame. The maximum window is three. So at this point, the maximum could go up from one, two, and three. That's the maximum window size, but it's currently one. That means there must be two frames that have been received. Received but not yet act. So this must have been received, received, not yet act, and the window covers just this frame. So this frame zero is the last frame act. Frames one and two have been received, stored in memory, but not yet act. And frame three, we expect to receive. We haven't received it yet. We don't expect to receive any more. Because recall, the size of the frames received and the window should add up to three, the maximum window size. So it should be one here and two here. And therefore frame number two is the last frame received, right, Rx. This is the last frame, last frame act. So three variables. Last frame act, last frame received, current window size. We know two, we can determine the other because the sum of last frame received, the sum of the frames received in the current window must equal three, the maximum window. So that's the current state where it's following this type of diagram, the vertical bar here, the window here. From that, at that point in time, we then receive one data frame. That's going to change the state. And we send an act or receive ready. And inside that act is the number two, act number two. So that changes the state. So now draw the next diagram of what's the state after receiving the data and sending the act. Just try that in the next few minutes. So this, I want you to draw two diagrams and then we'll get the final answer. This is the current state. Now draw a similar diagram for the next state. So think about what happens when the node receives one data frame, which one, and then what happens when it sends an act? Well, the act implies that, well, now means that some frames have moved from that state of received, but not yet act, into received and act. So this vertical bar is going to move and the window may move. It may even change in size. Try and determine what the next state is. And while you're doing that, for those that have done the first one, it's just a variation. So this is a different one, but I'll switch back in a moment, but those that have done the first one, try the second one. Similar, but just some different parameters. One data. For the first question from this state, we then, what do we say? We receive one data frame and send an act with act number, what was it, two. From this question, we, current state, we receive one data frame and then send an act with act number two. So what's the next state? And now this is the second question. Okay, but don't start that until you've got the answer for the first question. And the second question, do the same thing, draw the pictures. Draw the current state and then draw the next state. Remember, the receipt of a data frame, you can think of it in different ways, but receiving a data frame closes the window. That is, we need to store one more. And acknowledgement opens the window, allows us to send more and also changes where this vertical bar is. And be careful with the acknowledgement number. Act with act number two means, really, we're acknowledging frame with sequence number one. The act number is the next number. So if I send an act with act number two, it means everything up until frame one, up until and including frame one, has been successfully received an act. In the past, in the current state, everything up until including sequence number zero had been act. If I send an act with act number two, it means everything up until and including frame number one has been act. Because this is the next number expected. This vertical bar is going to move to here. Check that the two mean that that looks correct. But one more data frame has been received. Currently, we've received two frames. One and two. Then we receive another one. Which one do we receive? Three. So three is no longer needed. So if I figured this right, if I have an act with two, which means one was transmitted and the last frame transmitted was five, I only have three frames available in my window and you're saying I'm transmitting four before I receive the act? That may be a mistake. I recall there was some mistake somewhere. I thought I fixed it. There were no transmits. The last frame act is two. Where's that last frame act? Last frame transmitted was five, which gives me three available left in my window. That's the last frame act. Where's two? Where's the vertical bar? No, two. The vertical bar should be here, yeah? Well, it's weeding, right? The last frame act means it's done. So three, four, and five. Oh, okay. I thought you were saying, I thought you were just saying that the act means it was received ready at two. No, last frame act is the last one. We've sent an act four. Okay, so that's received ready at three. Yeah. Okay. Just check. It's probably wrong. My memory is not that good to remember the answer. This is two was acknowledged. Yep, correct. There's seven frames and there's only one frame. Well, what about last frame transmitted? That's frame transmitted. It's five. That's wrong. Yes, that's correct. That looks correct. Yes, the top one is. I can't remember the bottom one. We'll have a look in a minute. Let's do the answer for the first one and then give everyone a chance to work on the second one. Then we'll move on. Let's see if I can draw. The first case, we got, that was our current state for the first question. So from there, what happens? From there, we receive one data frame and we send an act with act number two. So what happens next? We've already received frames one and two. We've received frames one and two. That's what this means in this space. Zero is done. Three we're allowed to receive or expect to receive next. So from here, if we receive one data frame, what is it? Well, it's frame three. Because that's the next one in sequence. So after receiving one data frame, we would have received one, two and three. Our window would be zero. But then we send an act with act number two. What that means is frame with sequence number one and before have been completed. Act number two means the next I expect is two, which means one and before are done and finished. So if one, two and three are received and then the act indicates frame number one has also been act. The act indicates frame one has been act. So our vertical bar moves to here meaning zero and one are done successful. Two and three have been received not yet act because we'd received that new frame, frame three. So with two and three received we have a window of one. Frame zero we're allowed to send. So that's the next state. Receive one frame. So receive frame three and act one frame. Act frame one and our window moves along. The question was what is the last frame transmitted? What is the last frame received? What is the new value of the last frame received? What's the answer? Three. The last frame received in this case is frame three. Any questions before we do the second one? So we need to look at the current state and an important thing we needed for the current state was to know that we knew the window size was one. We knew the last frame act was zero so our vertical bar goes here. Always the window size plus the frames received should be three in this case because the maximum window size is three. So if we know this is one we know there must be two frames here. So we get the current state we acknowledge one frame this bar moves along but we also receive one frame frame three so our window is left at one again that is one frame in the window as we expect to receive one frame. Very similar this one so do this one quickly now we just have so you turn over your sheet okay turn over your sheet the zero to seven on the other side and for the source node we have last frame act is two last frame transmitted is five so you know two of those points there what's the window size quickly? Maximum window size is seven the maximum is seven last frame act is two last frame transmitted is five which means there are what three frames frame three, frame four frame five which have been transmitted but not yet act so if the maximum window is seven and there are three frames transmitted the current window is four so you can draw the current state the vertical bar comes after frame two the window is four coming after frame five and going up to whatever the value is draw the current state and then consider okay we send four data frames and we receive an act what happens from there so we know the last frame act is frame two the last frame transmitted is five and the window should be four last frame last frame act two last frame transmitted is five so three, four and five have been transmitted and the maximum window is seven so the current window must be four four plus three frames and now we transmit four frames and receive an act with act number four so how do they move? receiving an act first receiving an act with act number four means we now means the receiver expects four next which means frame number three and before have been successfully acknowledged so an act number four means three is done so our vertical bar moves to hit to pass frame three three is done allowing us to send one more frame so our window would grow six seven zero one and cover two but we also in the question send four frames which four? six seven zero one our end result will be here because frame three done finished allow us to send one more our window expands here but we also send four frames these four so our window expanded to cover two and closed for the frames which were transmitted so we're allowed to send frame two four five six seven zero one have been transmitted we're waiting for the act for them questions if you want to ask questions I'll walk around let's move on to the next question which these two were about how the window mechanism works when we transmit and receive frames we go back to what we did in the lecture and look at efficiency and do let you do some quick calculations or may not be so quick some calculations of efficiency here's a scenario satellite up in space geostationary orbit we have two ground stations what we do is we transmit a signal up to the satellite that may send down to another ground station somewhere else in the world ground station and satellite 36,000 kilometers we have both the links being the same we have a data rate of one megabit per second we're going to use a flow control protocol and actually we're going to focus just on one link let's say the uplink from ground station A to satellite let's say we need to send data up to the satellite just ignore this link for the moment and we're going to use flow control the satellite's been there for ten years the hardware on it is quite old it doesn't have much memory we cannot send too fast such that we overflow that satellite's memory because then the satellite will lose data and we're not able to transmit it down to B so we're going to use flow control across this link when we send data frames the amount of data inside is a thousand bytes the real data is sometimes called the payload the actual information we want to send but we attach a 50 byte header so we're going to send a data frame we have a thousand bytes plus 50 bytes and when the satellite sends an AC it's a 50 byte frame so we have the frame sizes speed of light 3 by 10 to the 8 meters per second that's the speed of transmission first question using stop and wait calculate the efficiency first thing and you'll need it for each question find the propagation delay for this link find the transmission delay of the data frame the transmission delay of the AC frame so calculate them first and then look at what happens with stop and wait so calculate those three propagation transmission delay of the data we have the AC and then try and work out the timing for stop and wait you may draw the diagram for stop and wait no processing delays let's keep that simple if you have any queries about the previous question about the sliding window let me know if you need some blank paper there's some up the front if you need some space to calculate there's some blank paper if you need first thing propagation delay data transmission AC transmission delays what's the propagation delay anyone have an answer ignore the second link we're looking at just the first link from ground station A to satellite just for this case we're using flow control across that first link we may use it across the second link but we're not focusing on it it's 36 divided by 3 don't waste too much time trying to draw a better satellite than mine try and spend some time calculating the answer calculating the propagation delay easy distance divided by the speed of transmission and then the data transmission delay data size 1000 plus 50 bytes divided by the data rate propagation delay was calculated as 120 milliseconds point something efficiency we need to move on so you have the scenario propagation delay 120 milliseconds 36,000 kilometers divided by 300 million meters per second 120 milliseconds data transmission there's 1,000 bytes of payload plus 50 bytes of header so the data frame is 1,050 bytes at a rate of 1 megabit per second you use your calculator you get 8.4 milliseconds 1,050 times by 8 to convert to bits divided by 1 million and we also need the ACK transmission and the ACK is just 50 bytes so 50 bytes times by 8 400 bits divided by a million is 0.4 milliseconds 0.4 milliseconds this is stuff that with your calculator or your brain you'll calculate in the final exam in 1 minute those 3 okay the next the most important part stop and wait what's the efficiency so draw the diagram draw the diagram of the data exchange data and ACK and look at the timing what's the total time to get the data there and get the ACK back draw the diagram of the stop and wait flow control and importantly put the timing and then you'll get the total time then you can determine the efficiency that a question no just a yawn tired what's the total time to transfer the data draw the diagram like that stop and wait data ACK draw the picture don't try and draw it to scale that's not so important if you're looking for a stop and wait you know with stop and wait we're going to send data we don't have any processing time in this question as soon as we receive the data we send back the ACK ACK comes back we'll send more data and keep going well you don't have to draw it all just look at the first phase 0 or does this time well data transmission 8.4 then we propagate plus 120 it exists to 128 0.4 ACK takes time to transmit 0.4 so it brings us up to 128.8 then the ACK needs to propagate back plus 120 to 48.8 that's the time it takes to deliver one data frame to the destination 248.8 milliseconds what's the efficiency if we continue doing that how at what rate do we deliver the data answer 3.2 percent sounds close time to receive the ACK the first 4 components is 248.8 milliseconds efficiency is the fraction of time we spend delivering the real data to the destination we can also calculate throughput which is the rate at which we deliver real data to the destination and they're related to the data rate in that the throughput divided by the data rate is the efficiency so if we deliver 1,000 bytes of real data that's here the data frame contains 1,050 bytes but only 1,000 are the real data the rest is the header we don't count the header as the useful data in delivering to B the satellite so every 248.8 milliseconds we're delivering 1,000 bytes of real data 1,000 bytes get there 248.8 milliseconds later another 1,000 bytes and so on so 1,000 bytes every 248.8 milliseconds just do the the division 1,000 bytes times 8 to convert to bits divided by the time 32,000 bits our data rate is 1,000,000 bits per second here I use uppercase B for bytes here I use lowercase B for bits, I've converted 1,000 bytes divided by 248.8 milliseconds is 32,000 bits per second correct anyone 1,000 times 8 is 8,000 divided by 248 I've got to apply this by 8 to get this number that's our data rate is 1,000,000 bits per second our throughput is 32,000 bits per second what fraction of the data rate is the throughput 3.2% simply the efficiency is the fraction of the data rate that the throughput is that is throughput divided by data rate how much of the data rate that we use to deliver real data and you see that that's 3.2154% this is 3.2% of 1 million is it good not good 3% efficiency is terrible stop and wait doesn't work very well across satellite links because their propagation delay is so high any problems now okay be careful with units so efficiency is bad 3% terrible let's make it better do the same sorry here's the diagram we'll come back to that one later but stop and wait I've tried to draw it to scale here you can see small time to transmit the data and then a long time to propagate there and a long time to get the act back because that long propagation delay we spend a small amount of time sending data a large amount of time waiting for the act to come back do it again but now use sliding window and try a window size of 7 okay try with sliding window with a size of 7 same numbers same transmission propagation delay but now use a window size of 7 see what you get and as a hint to get you started it's going to be similar to this except with a window size of 7 we can send 1, 2, 3, 4, 5, 6, 7 frames before we have to wait for the act so maybe one thing you can consider well after sending 7 frames it's time it's not easy to draw to scale but one frame takes 8.4 milliseconds at what time have we finished transmitting 7 frames is it 248.8 is it after or before that's going to be important how long does it take to transmit 7 frames it's the same time to receive the act because for the first frame 248.8 milliseconds but how long does it take to transmit those first 7 frames how long for the first 7 frames 7 frames how long does it take 7 times 8.4 good so I will not draw it here I have it later if you drew 7 frames here well each one takes 8.4 to transmit so the time to transmit those 7 is 7 times 8.4 which is 50 something 56 or 58 58.8 milliseconds the time to send a window of frames so if we send them what can the sender do next after sending those 7 the maximum window is 7 it just sends 7 frames it now must wait for the act to come back that's the way the sliding window works send your window frames in the best case you get to send the window of frames and then in this case we'll have to wait for the act for that first frame to come back I'll just skip through we'll come back to the numbers so it looks like this I haven't drawn all the acts just the important point we're allowed to send 7 frames the first frame arrives at the same time as before 128.4 and the act gets back at 248.8 the act of the first frame remember when we receive an act that allows us to send another frame so at this point although it's not on the diagram we could transmit another frame and the second frame would arrive slightly later and the act would come back slightly later allowing us to transmit the next frame and then the third act would come back and the fourth and then the act for the seventh frame will eventually come back which would have allowed us to transmit another 7 frames from this point on and then we'd have to wait again for the act for that first of those 7 to come back it would look like this just repeated so we'd have another 7 boxes here then a long time for the act to come back then another 7 then wait for the act so we'd be delivering 7 frames to the destination every 248.8 milliseconds with stop and wait we delivered 1 frame every 248.8 milliseconds here we deliver 7 times as much so you can easily determine the efficiency and throughput and because we're getting short on time let's go straight to the answer in this case total time to receive the first act same as before 248.8 time to send the first 7 frames 58.8 so within in every 248.8 milliseconds we deliver 7 frames which means 7,000 bytes of real data so 7,000 bytes every 248 milliseconds gives us our throughput 7,000 bytes times by 8 divided by 248.8 225,000 bits per second which is 22.5% of our data rate for 7 times better than stop and wait stop and wait was 3 here we have 22.5% because we're sending 7 times as much data in the same amount of time question is it good? still not so good 22% efficiency it's not very good we're wasting a lot of the link and we see that in the picture again this picture is close to scale we transmit data for some period of time for 58 milliseconds and then we must wait for about 200 milliseconds for that first act to come back a lot of time spent waiting not sending very inefficient that's why we're only about 22% how do we make it better? increase the window that was a case with a window of 7 stop and wait is really a window of 1 okay if you try to window of 7 if this is to scale anyone want to guess what the window should be? 29 that's a good guess that's more than a guess that's a calculation alright let's double each time and use the binary that is for example with 3, 7, 15, 31 we can use other values but if we double this window then it would come to about here we'd still spend only or less than half of the time transmitting data because if the window was 14 or 15 we'd send those packets, those frames still have to wait for the first act to come back so doubling gets us roughly to here if we double those boxes doubling again from say 15 up until 30 gets us about to here and you can see you can determine the exact value the more frames we transmit within one window the more likely that we'll spend little time waiting for that first act to come back you can actually determine the optimal value it needs to be a whole number I will not ask you to calculate with just a few minutes remaining we need a window to achieve the highest efficiency well we need to we receive the act after 248.8 milliseconds we know the data transmission the aim is to be able to continuously send data, no waiting that gives us the best efficiency that is we need the window size such that the number of frames times by 8.4 is greater than or equal to 248.8 divided by 8.4 is 29.6 well we don't have a fraction of frames so we could say a window size of 30 frames would be sufficient here 30 if we send 30 frames and then wait for the act it will turn out that we receive that act while we're still sending the 30th frame so a window size of 30 would be okay here sometimes we try and keep the window to be a binary sequence number to be this 2 to the k minus 1 like 3, 7, 15, 31, 63 we don't have to but it's common let's say we had a 5 bit sequence number gives us 31 as the maximum window size with 31 we'd find the efficiency we're always sending same with 30 in fact we're always sending the only inefficiency is the header so we're sending 1,000 bytes of data and every 1,050 bytes that is the extra 50 bytes of header 95.2% of the time we're sending the data in this case we cannot do any better 95.2% of our data rate would get a throughput of 952 kilobits per second unfortunately we don't have time to calculate this I will leave it for you to check and to make sure you understand this in preparation for your quiz and exam let's just finalize this is 4 different mechanisms stop and wait a window of 1 a window of 7 a window of 15 and a window of 31 an approximate scale and we see as the window gets bigger we eventually get to a case where we're always sending frames we're sending a frame in the window an act comes back allowing us to send one more which means then we can send another one and then another act comes back from the second frame allowing us to send one more and we'll get this forever we're allowed to send a frame and send another one and we're always sending never waiting and that's the best case we can achieve the only overhead is the header in that case that's what we'd like so if we know about the link characteristics we can choose a window size which is optimal this just plots the window size against efficiency we see as the window gets bigger what it was one the efficiency goes up until we get an optimal value in this case we're around 30 making the window larger doesn't help making a thousand doesn't help because we cannot go higher than that 95.2% efficiency we always have the header there so this would be the optimal point the optimal window size we're out of time for today we've had enough of understanding sliding window you have a few examples next week we'll look at error control what do we do when we lose data and we'll see that it's very similar to the sliding window mechanism we use the same concepts just with a few extra features there will be a quiz and it has I think four questions I need to check it will be available yet but this afternoon it will be available four questions and the calculation questions like you've gone through today in the efficiency looking at the window how it changes and I think that's it from today's lecture you should be able to do the quiz