 Latency is a measure of time delay in a system. Now, because there are many different types of systems and time delays, it is always very important to have a precise definition of what we mean by latency. So because we will be talking about message latency, we will define it as the time that it takes or the delay for a message to travel from its point of origin to destination. So simply put, we have two points. We have A and B, and we will be sending a message from A to B. And the latency of the system is the time that it takes for a message to travel from point A to point B. So this is the one-way latency of the message. Now, let's spend the next few minutes and take a look at some ways of how we can deliver a message from a perspective of network latency. So let's start with the simplest and the most familiar example, which is, well, on foot. And there's probably no better example than the fabled run of a Greek messenger from the battle of Marathon to the city of Athens, where this messenger ran the distance of 42.2 kilometers. Or if you prefer miles, that's 26.2 miles to deliver this message. And of course, this is where the name and the distance for the modern marathon comes from. Now, the current world record for the marathon is just over two hours. It is actually two hours and three minutes. And this is a very important number because this is, of course, the total time that it takes or the latency of the message to go from the battle of Marathon to Athens. Now let's also calculate the speed with which the message travels. We know that the distance is 42.2 kilometers. And I'll simplify this a little bit and just say that it's 42 kilometers. And we'll divide this distance by the time that it takes us to deliver the message, which is two hours. So I'll also simplify this a little bit. And that will give us 21 kilometers an hour. So that is the speed with which the message travels per hour. Now in our other examples, we'll actually want to use meters per second. So I'll just show you once how to make this conversion. It's actually very simple. We know that there are 1,000 meters in each kilometer. So we just need to multiply that out. And we will divide, to get seconds, we will divide this number by the number of minutes in an hour, which is 60, and the number of seconds in an hour. So if you do this math, it will come out to be approximately 5.8 meters per second, which is a very, very quick pace. And what this tells us is that our message will travel with the speed of 5.8 meters per second. But it will nonetheless take us roughly two hours, or the total latency, to deliver the message from the Battle of Marathon to Athens. Now of course, we could also recruit some help to deliver the message. So it just so happens that a speed of a very fast horse is about 85 kilometers an hour. So what we have here is the speed in kilometers per hour, which is the same number as we had here. And if we repeat the same calculation as we did earlier, it will actually come out to be about 24 meters per second, which is the speed with which the message will travel. And it's more than four times faster than our messenger on foot. Now we know the distance, which is 42.2 kilometers, and we know the speed. Now we can figure out the total time that will take us to deliver the message. So let's do that. We know that the distance is 42.2 kilometers, and let's convert this into meters. So once again, we'll multiply this by a thousand, and we will divide this number by the speed. So this will be meters, and we know that the speed is 24 meters per second. So if we do this calculation, it will work out to be 1,758 seconds, which we can convert into minutes by just dividing that by 60, and that works out to be approximately 29 minutes. So what this tells us is that the message latency for delivering the message by horse is more than four times faster and works out to be approximately 29 minutes. Now another way we can deliver the message is with a homing pigeon. And believe it or not, this is a method that's been in use for over 3,000 years. Both the Egyptians and the Persians use homing pigeons to deliver messages. And the speed of a pigeon varies quite a bit, but on average they travel at a speed of about 80 kilometers an hour, which if we do our usual calculation will work out to be approximately 22 meters per second. So this is the speed with which the message travels. Now if we repeat the same calculation as we did here, we can actually calculate the total time that will take us to deliver the message. And we'll skip that because we did it earlier, but the total time will be approximately 31 minutes. So very similar to the horse, but still about four times faster than delivering the message on foot. Now in some cases we can't deliver the message either on foot by horse or be a carrot pigeon, like for example where we need to cross the sea. And the thing about ships is that they have generally been very slow. So a ship built in around 1800, something like a Spanish galleon, would travel with a maximum speed of six kilometers an hour, which is approximately 1.7 meters per second, which is a lot slower than even a runner on foot. Now the good news is we've actually learned how to build much faster ships. And a modern fast ship can travel with a speed of about 55 kilometers an hour, which is about 15 meters per second, which is almost 10 times faster than before, but nonetheless slower than the horse and even a carrier pigeon. So if we do the same math as before, we will actually see that for us to deliver the same message by ship, it would take us approximately 47 minutes. Now some of these examples may feel a little antiquated, but in reality we can still hire a runner to deliver a message within the city, something like legal paperwork, except that chances are he won't be using a horse, he may be using a bicycle. And of course, we still deliver a lot of mail by sea and by ship. And believe it or not, our avian friends here are still in active use. So let's take a look at some fun examples. So first we have the Reuters news agency, which was started around 1860 by Paul Reuter. And his original service was actually to deliver messages from the city of Brussels to the city of Aachen, where he employed a fleet of 45 carrier pigeons to deliver stock quotes. And in fact, 80 or so years later, during World War II, carrier pigeons were frequently used, especially in cases where radio may have been compromised. And finally, believe it or not, in this day and age, we are still using carrier pigeons in many remote locations. So for example, we have the police pigeon service being used in places like India to reach remote locations, which is pretty neat. Now, there's only one issue with this entire picture that we've come up with here, and that is we're actually missing a very important way for how we can deliver the message. So let's take a look at that. And that is through the use of visual signals, which is, of course, an ancient and a very popular way that we've been using for thousands and thousands of years through things like torches, fires, smoke signals, and so on. And in the case of our Battle of Marathon, we could have, of course, used visual signals to deliver the message. Now, because the distance is actually pretty far, it's 42 kilometers, chances are we would actually need several different relays along the way. And the question is, what would be faster if we used these visual signals or if we just used one of these pigeons to deliver the message to the city of Athens? Now, that is actually a little bit of a trick question, because if we were to use a pigeon, we could actually scribble a little note and attach it to the pigeon and send it over. So we could send quite a bit of information, whereas with smoke signals, really all we're doing is communicating one bit of information, which is, let's say, whether we won the battle or not. But that could be enough. And in the case of our Marathon messenger, that is all we want to communicate. So we will assume that these two ways are actually equivalent. And we already know that it takes a pigeon roughly half an hour to deliver this message. So the question is, how much time will it take us to communicate the same information via visual signals? And to answer this question, we actually need to look at the sources of latency. So let's introduce a couple of new terms. And the first one is propagation delay, which is actually the delay that we've been focused up until this very moment. So propagation delay is defined as the time it takes for a message to travel from sender to the receiver. So propagation delay is a function of two variables. One is distance, so this is how far the message needs to travel. And then the other one is the speed in the medium that it travels. So we saw earlier a couple of examples where the message was transported by different means and the speed varied, and hence the propagation time changed. So for our avian friend here, it's about 30 minutes. Now, processing delay is a little bit different. And it is defined as the time it takes to process the incoming message. And up until now, we haven't actually encountered any processing delays. And same thing for the transmission delay. So the time it takes to push the message onto the link or the medium, which is a little bit abstract. So let's take a look at some examples. On the one hand, we have our pigeon, and we want to compare them to visual signals. So let's break apart some of the delays in the system. First, we have propagation delay. And we know that the distance is the same in both cases, it's 42 kilometers. And we also calculated the speed of the pigeon earlier, which was 22 meters per second. And we know that the time it'll take the pigeon to make the strip is approximately 30 minutes. So the propagation delay is 30 minutes. Now, for visual signals, the story is very, very different because our signals will travel with the speed of light, which is 300 million meters per second. And if we do our calculation here, we will see that to travel 42 kilometers at this speed, it'll basically come out to be a rounding error in a tiny fraction. So for all intents and purposes, it is zero seconds. Now, processing delay is interesting. Recall that to transmit the visual signal, we needed multiple points along the way, or multiple relay points. So first, we would start by lighting the fire. And then the second person here would have to identify the fact that we're transmitting a message, verify it, and then also light a fire such that the next person could repeat the same process. So the time that it takes this person right here to identify and verify that we're sending a message is going to be our processing delay, or the time it takes to process the incoming message. And let's pick a number out of a hat and say that this will take 30 seconds. Now for transmission delay, recall that this person would also have to light a fire right here to indicate to the next person in line that we're transmitting a message. So let's be optimistic and say that it takes us 60 seconds to light the fire. And with this information, we now actually have enough information to compute all of the totals. So for the pigeon, we know that the processing delay is zero seconds because this guy is just flying directly from the Battle of Marathon to the city of Athens. And same thing for transmission delay. And so with that, we have enough information to calculate the totals. So we know that the total to here is 30 minutes because these are zero. And for visuals, we actually have multiple processing and transmission delays. So let's take a look at that. First, we would need to light the fire, which will take us 60 seconds. Then the second person will have to detect it and light another fire. And then we repeat the same process once more. And finally, we detect it here. So let's add up these numbers. 60, 30, so 90, 150, 180, 240, 270. So that's 270 seconds, which is four and a half minutes. And we can round this up and call it five minutes. So assuming the delays are 30 and 60 seconds, our message will travel six times faster if we use visual signals as compared to our pigeon. And this exercise here is a very good illustration of a principle that holds true for all message systems, which is there are different types of delays or different components for each system. And it is always very important to define what these are because they will add up in different ways for every system.