 From most of the examples and the most of the things that we talk about from now on we'll look at we'll use digital data as an example So now if we have analog data, we know a way that we can convert that analog into digital So if I want to send audio across a communications network or a link I can convert that analog audio into digital So many systems today we deal with data in a digital form even if it's original in analog so From now on this topic and the subsequent ones. We're really going to focus at digital data This topic. We're going to just introduce one concept and again skip almost half of it and introduce the concept of error detection and I think most of you probably have have seen error detection in Maybe a computer hardware type course or operating systems. So it'll be quite easy The issue is I've got some data to send across a link from A to B So the data is in a digital form zeros and ones. I send it across the link but unfortunately in practice There's a chance that when I send the sequence of bits what's received doesn't match what was sent We've talked about some examples before where we can have noise from other sources that make the received signal to be a Lower quality and as a result we get errors at the receiver So with digital data if I send a sequence of bits one zero one one Four bits one zero one one. I send it across the link, but there are some errors. There are some problems in the link So what's received is one zero zero one? transmit one zero one one receive one zero zero one What's received is not the same as what is transmitted. There's a bit error One of the bits has arrived in error We need to do something about that. That's not good I send a file or I download a file across the internet if there are bit errors in some of the links Then I will not be able to use the file So the first thing that we want to do is that the receiver needs to know that there is an error You're the receiver you receive a sequence of bits one zero zero one you need to know is this correct or not? so the procedure we'll talk about or introduce is called error detection and Then the next topic we'll look at okay. Once we know that there's an error. How do we fix it? error correction and A couple of other things about digital data So we'll use mainly examples to explain this but we're gonna From now on assume that we can have bit errors When we send a sequence of bits Sometimes some of the bits received may be different from what was sent and Usually it's random. We cannot predict which bits Okay, because it's due to some noise or some some problems in the communication system So we'd like a way to deal with that. We need methods to detect those errors and When possible correct them fix them so that we get the original original data Sometimes the bit errors occur one at a time Okay, I send a thousand bits one of them is in error In other cases in worst cases I send a thousand bits and 100 in a row are in an arena error a burst of errors due to Some significant problem in the system Sometimes we have to deal with them in different ways, but we'll look at the simple ways to deal with errors Let's start with an example let's say you are the receiver Rx is short for receiver and You receive a sequence of bits Seven bits you receive We know the transmitter was going to send us seven bits. We received seven bits Is it correct or not? What's your answer Don't know. Why do you not know? We don't know what was sent. You're the receiver The transmitters on the other endpoint of the link could be on the other side of the world They've sent you data. You don't know what they sent. You only know what you receive So that's the problem we have we receive a sequence of bits. How do we know it's correct or not? Okay, so that's our problem Of course if we knew what was transmitted Then we would know whether it's correct or not, but we don't know what was transmitted The only way to learn what was transmitted is from them sending it to us So a simple way is that the transmitter Or a general way is the transmitter attaches some extra information before they send the data So the transmitter has some data a sequence of bits They attach some extra information There are different ways different algorithms to do it. We'll start with simple ones such that when we receive that data plus their extra information We use some algorithm to try and detect is this correct or not? and the simplest piece of extra information Now I think you may have heard of is a parody check or a parody bit We'll use that as the example. It's not the best but It's easy one to illustrate so Let's try a different example. Let's say we know the transmitter I'm the transmitter. I have a sequence of bits. What do we have? Let's say it's the same as before but not significant Just a random sequence of bits. I want to transmit to you With a parody check we attach with a single bit parody check we attach one other bit Which will be used at the receiver to detect an error and there are different ways to do it But let's use what's called an odd parody check We attach one more bit in an odd parody. We attach a bit such that the total number of ones should be odd So what do we attach to this sequence of seven bits? There are currently four ones in this sequence if we want an odd parody check We must attach another one such that the There are an odd number of ones so there are five ones so the parody bit in this case will be bit one So in our sequence of eight bits. We now have an odd number of ones So the transmitter will attach a bit such that there's always an odd number of ones transmitted. I Attached at the at the start Another scheme could attach it at the end. It makes no difference. There's still an odd number of ones So now instead of sending seven bits across the link we send these eight bits and now let's look at what's received Forget about what was transmitted now. You're the receiver. You don't know what was transmitted. You just know what you receive Let's say you receive this sequence of bits You just receive those eight bits and you know that the transmitter used an odd parody check So you know that the first bit is the parody bit the next seven bits of the data Correct or not Why is it correct? Because the number of ones is odd You know that the transmitter always sends an odd number of ones in their eight bits So if you receive an odd number of ones you assume That this is correct and that's the parody check and and how it's used for error detection in this case There are five ones so The receiver assumes I'll write it here We make an assumption that is of the bits received If the number of ones is odd we assume it's correct and if the number of ones is Even Will assume it's incorrect. So in this case we have an odd number of ones. So let's assume. It's okay Was it okay? Now you're the receiver. That's all you know, but we know That I know what was transmitted as well and it was this data Is it correct? Yes, the the data received is identical to the data transmitted. So this assumption was This assumption was a correct assumption So if we know both the transmitted and received data we can determine did the receiver make the right choice So in this case it worked Let's try some other cases Let's say instead you received a different sequence of bits. You're the receiver you receive those eight bits What do you do? What decision do you make you make a check and how do you check count the number of ones how many and What's the answer now? Assume it's incorrect Assume there's an error there are four ones and even number of ones. So let's assume that's The data I received this an error Where is the error? If you're the receiver, where is the error? You don't know Okay, you're the receiver. So figure it forget about what was transmitted remove that from your memory and just think You've got these eight bits The only way to check is to use the parody Parody check count the number of ones For ones we expected five Sorry, we expected an odd number of ones. So this must be wrong. It must be an odd number of ones received We don't know where the error is The receiver doesn't know where the error is we know because we've seen that the answer before Was it a correct decision? Now let's look from the perspective of Someone who knows both the transmitted and received data. Was it a correct decision to assume that the data was incorrect? yes, because we know that okay the seven bits and Transmitted 011 here. We have 010. There's in fact an error here if we check. So this was a correct decision To decide that this data is wrong was a correct decision So it worked in that case the error detection worked we detected the error a Couple of more quick cases What do we assume? again wrong We've got an even number of ones We expect an odd number So assume there's an error was there an error Well, there is an error The error is in the parody bit Okay, not in the data But in fact there still is an error in this case we transmitted Eight bits even though one was a parody bit. We still transmitted it 101 we received zero zero one. So there is an error in the transmission system So we have detected an error Even though the error wasn't in the data we still a correct in this case because We've detected an error of what was transmitted Remember we can't distinguish where the error is We can just detect or not. So in fact, this is a correct thing to do as well Even though it was the parody bit that was wrong What do we decide? It's correct. There's an odd number of ones. We expect an odd number of ones. It's correct. Good What's the problem? It's not correct. If we compare what was transmitted. We see that there are two bits in error here They're different from what was transmitted here. So this was the wrong decision So our error detection did not work in this case and that's the case with Every error detection scheme Sometimes it doesn't work. It's not perfect We want an error detection scheme that increases the chance that it would detect errors But in this case When we had two bits in error We assume the data we receive was correct But that's wrong because it's incorrect So this highlights that our Single bit parody check is not very good in some cases. It worked for these cases. It didn't work for this case When does it not work in general the parody check? When will a single bit parody check fail? Can anyone see the difference between the errors that cause it to fail in this case? Here we have two bit errors So we transmit an odd number of ones if we have two bit errors that it means two bits change So we still end up with an odd number of ones so an odd sorry an Even number of bit errors two four six or eight in this case will produce our error detection scheme to fail An odd number of bit errors with a single bit parody check will be okay in these cases So a single bit error it works Any bit changes will detect it because it goes from odd transmitted to even transmitted when you change just one bit But two bit errors or four bit errors and it won't work So parody check is very simple but not very good if you have more than one bit error Because you'll start to have it fail. It won't detect the errors So if you expect many errors in your data Then it may be a parody check is not so good. So all error detection schemes They may not detect every error But we want them to detect as many as possible and people do analysis to see and compare them There are other algorithms and we will not cover other algorithms But another one you may see there's one slide on it But another one you may have heard of is the CRC check that won't know the CRC the cyclic redundancy check CRC 16 CRC CRC 32 another variance Just more complex algorithms, but again a CRC check attaches extra bits Not just one bit. It takes the data attaches extra bits such that when we receive we do some calculation and and the result of the calculation tells us whether we assume there's an error or not and In general The more bits we attach For this extra information Here we attach one, but we can attach more if we use different algorithms the more bits we attach The greater the chance that will detect that will get a correct decision So if we attach more bits, there's a more chance that will make the correct decision Less chance that we'll get this case where an error will go undetected So that's better more bits means more chance of successful error detection But what's the problem of attaching more bits? The problem is that our efficiency goes down in our single bit parody check What do we do we we had original data of seven bits and We had the extra error detecting information The parody bit Sometimes called an error detecting code in general the extra information we added was one bit That was our our example So we can say the efficiency of this scheme For every seven bits of data, we need to send eight bits So the efficiency is seven over eight So I've got seven bits of real data to send But I need to send an eighth bit to get that to the other side because that's what's needed for the parody check Which is what? 87.5% saying that 87.5% of the time if I'm using this single bit parody check and just sending data Seven bits of data one bit parody seven bits data one bit parody. I keep doing that Then it says that eighty seven point five percent of the time I'm sending real data The other twelve point five percent of the time. I'm sending that extra parody bit. So it's eighty seven point five percent efficient What if we had a different algorithm where we attached? two bits that is if we sent data of Seven bits and every time we sent seven bits of data. We added the the extra info of two bits Then the efficiency is seven over nine Seven bits of real data for every nine bits that we need to transmit. Which is what? 77 percent About so the more bits we attach the lower the efficiency for the same amount of data That's bad Because I've got my link and I'm using it for sending real data less percent of the time But the trade-off is the more bits we attach The more chance we'll be able to make the correct decision The less errors will miss By using a single bit parody check We saw that we'll miss errors if there's two bits or four bits in error by using a two-bit parody check we can in We could change the algorithm to decrease the chance that will miss those errors So attach many bits to make the error detection better But attach few bits to make the efficiency better So we need to choose an appropriate trade-off and that applies to all algorithms no matter how complex they are the more information we add The lower the efficiency, but the better error detection capabilities Any questions on parody checks error detecting? We're not going to go through any other algorithms. It was just using a parody check as a simple example, but there are other better ones There are other algorithms Okay question if we just go back to our examples What do I mean by assume the blue one and correct the red one remember the receiver receives data they make a decision Do I assume the data is correct or not? That's what I marked in the blue line the blue column here. That is we were assume this data is correct That's a tick in this second case. We assume the data is incorrect The red column I'm saying was that decision correct or not? In the first three cases, yes, it was correct because if we compare the received data those eight bits To the original transmitted data. There's a difference Sorry for these two there's a difference So it was a correct decision for the first one. There was no difference. So it's still a correct decision in the last case The receiver assumed the data was correct, but that's the incorrect decision They they the algorithm was wrong in that case we don't want those cases to occur and to in general to Reduce the chance of those cases we attach more bits. We have an algorithm that uses more information Instead of one bit add add more bits and you'll reduce the chance of getting this case But you'll reduce the efficiency at the same time any other questions error detection on its own is not very useful So in Say in the second case here the receiver detects an error. It assumes that there's an error. It was correct What does a receiver do? What do we do when we detect an error? When you you're you're doing your exam you're answering questions Then you've got an answer and then you go back and check it and you find it's in error What do you do? You check again, and you try and fix it. Okay, you try and correct the error Of course if there's an error we want to fix it and get the right data. Well, what's the receiver do then? How can they fix this? They've received eight bits. They think there's an error. They know there's an error. They don't know where They would want to they want to receive the original data. They want to fix it So the next step is error correction error detection is detecting it error correction is fixing it and There are two basic approaches for error correction one of them is to attach similar to error detection attach more information such that The algorithms can tell us where the error is Our parody check couldn't do that. It told us there was an error, but not where If we had an algorithm that told us ah, there's an error and the error is the fourth bit Then it's easy to correct change the fourth bit from zero to one and we've got the original data so there's Algorithms that will also be able to tell us where the error is so how to fix the error That's called forward error correction. I'll go back to the slides in a moment. What's the other way to correct errors? I receive data. I detect there's an error. What could I do? send the message again and Hope it will be correct. Good. So I Receive data error. I tell the receipt the transmitter The data you just sent me was wrong Please send it again They send it again and hopefully this time what I receive is correct okay, and Well, why would it be correct the second time if it was wrong the first time? Well, what causes errors usually errors are due to noise Random variations in some cases. So usually usually when errors are not so often I don't know there's one error every one million bits So if we send a thousand bits and we're unlucky and get an error the next one thousand bits We should be lucky and not get an error. So usually sending again can be quite Quite good because the second time we send There won't be an error. It depends upon how often errors occur And if they send again and I detect an error in the second time, I can just ask them, please send again Please send again. Try again. Try again Well at some stage I may give up and say Data transfer failed Because after so many attempts that I didn't receive the correct data so two ways To correct errors attach extra information so that the receiver can find where the error is and fix it That's called forward error correction The second way is when you detect an error tell the transmitter to send again We're going to cover the second way not the first way the second one is more common in the systems We will see so let's just look at the slides and see if there's anything with we need to know more If you understand what we've gone through that simple example of parody check and the goal and the general concepts of error detection Then that's all you need for this topic These slides try and explain it in general saying okay, we send k bits of data We attach extra bits at the end in this picture So we have k bits of data we attach an extra n minus k bits so when we add them together we get n bits In our example we started with seven bits of data. We attached one extra bit We ended up with eight bits to be sent We transmit that There is What do we attach? Well, there's some algorithm that tells us what are those extra bits in our it was add a bit Such that the total number is odd, but there are other algorithms We send those bits those n bits the receiver receives those n bits and uses that extra information to and Compares that with what they expect to try and determine is there an error or not? that's what we did we Took the receive data and compared to what we expected if it wasn't what we expected error detected That's the general pro approach for error detection The more bits we attach The more chance we'll be able to be successful at the receiver But the lower the efficiency and I think that's the main point there We did an example of a parody check odd parody check. It wasn't that example, but it was another one There's also a cyclic redundancy check at another common algorithm use and there are others But we will not go through CRC. It's much more common, but a little bit more complex We don't have time for it. Then there's error correction What do we do when the error is detected? Well, like we said we can ask the Transmitter not transmitted ask the transmitter to send again retransmit We cover that in the next topic. We'll spend a lot of time on on the retransmission schemes There's another way called forward error correction the sender similar to error detection We attach extra information so that this Receiver can find out where the error was and fix it without getting a retransmission forward error correction They have different advantages and disadvantages. They generally some Retransmission works well when there are not so many errors just a small number of errors FEC works better when there's Quite often we have errors So there are different trade-offs. We're not going to cover forward error correction It's interesting, but no time but The last slide captures maybe the key trade-off for both error detection and forward error correction For a given amount of data Say k bits of data we want to send In our example, we had seven bits The total number of bits we send n So in our example, we had k equal to seven bits of data. We send n equal to eight bits For a given value of k bits of data the larger n the larger the more we send The better we are at detecting and correcting errors. That's a good thing But the larger n The lower the efficiency of the transmission. That's a bad thing. So that's the trade-off we observe here We had seven bits of data where he transmitted eight bits in total if we transmit Nine bits or ten bits or twelve bits instead a larger n we'd be able to detect more errors But it'd be lower efficiency because we have to send extra To get that original seven bits sent. Any questions on error detection? That was a quick topic Let me draw this sequence of eight transmitted bits again We'll explain one more. There's some new terminology What do we have? We had a sequence of bits transmitted That was our example. We had seven bits of real data One bit of header Or I gave it away. One bit of extra information. We call that extra information a header sometimes We attached it at the head of the real data Now when we deal with communication systems we'll often talk about not signals Not just a sequence of bits But we'll group those bits together to get what's called a message A frame or more generally a packet A chunk of data at a time is sent So in this example We had seven bits. So these seven bits That was our original data The first one bit Was we can call the header And together those eight bits Header plus data There are different names for it, but we may refer to it as a frame Sometimes a packet so We have a million bits to send If we're using a single bit parity check each frame would contain eight bits We take seven bits of data, attach one bit Send that Then the next seven bits of data we attach another bit and send that So we'll look at from the perspective of Okay, we have a frame of data Which contains some original data Plus some extra information And if we put that extra information at the start we call it the header If we attach it to the end and we can in some cases we call it what? What if we attach it to the end? It's the trailer at the end. So in general we can have a header data trailer Not just for error detection for for many Systems and protocols we'll look at from now on we'll see that structure If it's at the front of the data we call it the header if at the end the trailer And sometimes rather than listing the sequence of bits. We just will draw as a Set of rectangles. So this means the data whatever it is whatever sequence of bits is represented here We have a header at the front and a trailer at the end. We don't need to have All three sometimes we'll have header plus data Sometimes data plus trailer no header sometimes we have header no data or trailer We'll see some special cases, but from now on we'll start to see Diagrams similar to that and together we call that a frame Sometimes a packet. This is one frame of information one frame of data The header doesn't have to just be the error detection code. So An example of what is in the header Our example was some error detection information So the header in general may contain error detection information same with the trailer. What else could the header contain? Now I think I'm sending data from a to b I send that data in a frame Often in the header will also include who sends it and who's it destined to It's coming from a it's going to be So we'll often include the addresses of the source and destination The source address may be included And the destination doesn't have to be but that's common in some systems And other stuff that helps the protocol work To help us communicate clearly so We have a million bits of data. We break it into many frames We send the first frame In the header we may include a number saying this is the first frame In the next frame we send we include a number saying this is the second frame So when the receiver receives it can put them back together in the right order So that's usually called a sequence number And many other things may be included in the header or trailer I've just given an example of four common things we'll see Who sent it Who's it going to Which order did this come in in a set of many frames so a sequence number Maybe some error detection information a parity check bit or some other information and Through the rest of this course we'll see examples of other types of information inside headers They all contribute some overhead to the data transmission We have the original data to send plus the overhead of the header and trailer The more information we add in there The the larger the overhead but To communicate effectively We usually need some of this information. We can't just discard it. So it's needed for different protocols So from now on we're mainly going to talk about frames and eventually packets. We're not going to talk about sequences of bits Any questions on the structure of a frame before we move on to the next topic