RHEL7 - How NTP Works

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
very good afternoon this is all ocean washed off from network not so as promised a new video in a very short gap so this is a very interesting way video and actually I should be saying thank you to our clients from Singapore Lake VA we have some students from Singapore and we are conducting trainings for them obviously the online trainings so I was explaining them the concept of NTP and fine like fair enough as far as your RSC is concerned whatever is mentioned in the books also and done everything is fine but these guys are really very smart they are working with a very big organization there I cannot disclose the name and handling a damn huge data center so they asked me how NTP works like the cushion was not that fine you you go to it if you are working on l6 then you go to ET C and D b.com right server and the IP address and if you are working on rel seven then you go to EDC chronicon and give the IP address and your machine will go on to the internet and will fetch the time and then your time will be adjusted their question was much more the question was how exactly it works something like when we learn about DHCP we have to learn about Dora the mechanism in which the DHCP works so the same thing the same question was being asked how it works so here goes the videos so that everybody of you will be benefited from the questions and I hope I will be able to answer that cushion and for those who don't like have the cushion itself in the mind so it's a ready reference for the NTP so let us go brief about NTP and then I will explain it to you what exactly happens so I am just opening a G edit my editor here for you just own please so here it is so it is an TP deep inside so a couple of very a review of the NTP is that the purpose what what is the purpose of the NTP the purpose is very simple to synchronize the talks I hope the font is visible synchronize the clocks of a server constellation to UTC that is the main job synchronize the clock that is good right where it is used utility everywhere the timestamps are used everywhere so timestamps are used everywhere like starting from log files to your banking applications everywhere the timestamp is used right and like your airline industry timestamp when the transaction has happened it it's very important and what kind of packets are exchanged sorry so those who have already done the RSC over a same level of knowledge they know that the NTP works on the use the UDP protocol and port number is one two three so if your firewall is on you need to make sure that this sport should be allowed right and it uses its own binary format I am NOT going into that binary of format just a reference that if you wish to learn about it please refer RFC 1305 and RFC 2013 I am NOT going into that but it is they use their own binary form format and what what kind of packets are exchanged so there is a two-way communication one you have a decline and one you you were server right so the client okay I can write here packet exchange first is the packet send what packet is sent so the first thing is that I do like this at a client send the request with its timestamp fair enough now the sir it's not the duty of the server to respond him in back so I am just changing the direction of the arrows here beautiful arrows the server returned the packet with three times times Wow this is something new three times times what are these three times times sorry number one the echo of the client thanks champ when the client has sent the request if I am the NTP client so when I had initiated the recoup the request to the server that I want my time to be synchronized so echo of the client timestamp that when you had given me the request second when did I I here means server when did I receive the request because you are working on Internet it's not at all possible on the internet that the communication is on the wire speed there are Layton sees and things beyond your control over the ADA like Internet you might have a say 100 Mbps of connection but still some kind of latency must be there or it it is bound to happen and the third is when did I I here means not Alex Wausau I had me server when did I Center the response so once the server has received the request he might take some time to respond the client back I am I am busy you are asking me some question I am I'm busy I will take my own time right now these are types of packets are sent and then what happens okay I can write a check I can just mark it here like this so that will be easier for you yeah that makes sense is look beautiful then what happened the client then estimates the offset of time the difference between him and the server the client can have many server remember this these are the basic building blocks these are the basic knowledge that you should have for entity but the client will only choose one in DB client choose only one ntp server to sync the time right and to minimize the offset and it then minimize with the offset I'll tell you how it then minimize the offset and skew with the time difference to will feedback loops so it is what kind of packets are as exchange here let me make it more interesting here let me highlight it like this underline it so that will be easier for you to remember now these things are not there in your standard course we're in RSC or everywhere else they just teach you how to configure yourself as NTV client but as admin as a person who is curious you should be understanding what kind of packets are being exchanged and I will be digging on it more okay so that is it and as far as the NTP is concerned it's the traffic is minimal means that packet size that it exchanges it's a very small size of packet so I mean like exchanging with you or sharing with you a very interesting our data here network use of NTP as per the estimate there are thousands and thousands of NTP servers here or say thousands of NTP servers and thousands and thousands and thousands of anticline so how much traffic they are generating over the internet just because every client is requesting to the NTP servers please give me the true time so the the packets are very slow so just note down these important point the pair of sorry some very small packets at every sorry 64 to say one zero to four seconds are being exchanged seconds for each server these are size the frequency here and it is there is a very new feature here and as per the estimate sorry only 0.01 percent of the world traffic on internet is of NTP so it is something like less than five GB per day and I think I'm written a very huge size here okay sir say less than buddy so it is not putting that much of load or condition on the Internet and one very interesting thing in rel seven that now we use like say act right here and TP with rel seven this is what the major focus is so we now use like the current the latest version is NTP version for v4 right and another thing thing is that we have got a feature of IBUs there I can write here or I can write in the network use okay I just mention here the speed of communication between and TP client and NTP server will be eight times more if first keyword is used I what is this burst cure let me show it if I open my machine here and you need to make sure that for if the NTP is working here the very easiest way to find out is there is a command there time dates UTL so if you see there by default my NTP is enabled by default it is there and NTP is synchronized means the time is being my machine is getting the true time but from where it is getting the to time I hadn't configured anything I'd just installed the machine fair enough a very good cushion and another thing that you should be aware of this that you should check the status of the chrony service kronole D either right County d dot service or right Khurana D it makes same so make sure it is active running and that it should be enabled that means it is available across the reboot fair enough Wow now the main configuration file in rn7 is chronicon in rl6 I'll just write here in rl6 it was UTC and T pecan those who remembered so here it is so by default it uses these predefined servers by Red Hat and see here I burst I burst Q what is used now it is not there in rl6 that means when I am I will be communicating with these servers as I am communicating for the first time please attach the nose like our fast and furious please initiate the norms or please start the nose in my communication so my communication between the server and the client will be eight times more if I remove this IBUs option so let it be there no issues so this is the information here so miss my machine is getting synced from these sources how can it check this is very simple command chrony see sources see here these are the locations from where I am getting my true time and this is the stratum 2 server which is very good and if you wish to learn more about it just increase over boss increase the velocity here so it will give you much more detailed information here like this right so that if the star is there that means it is currently synched need not to worry right if it is a cannot symbol layer that means it's a server not appear here will be reflected by a is equal to symbol and the information about it that when it has been poured and reach and the last sample and just avoiding all this thing here we'll be focusing on how actually the communication happens how my machine adjust its time when it gets a request or is or it gets a response from the NTP server fair enough you can change the server like suppose right now my I'm getting the IP or sorry that time from this machine I don't want this server I want to use another server with a higher stratum value so I will just show it to you I it is very easy to find another NTP server they are freely available across the world I open my browser here let it be the size so that you be so I open google.com the lifeline of all all admins thank you google for saving my life and whatever haha okay just right here IP address of NDP server so the most trusted resources n is tea time servers here I always choose these IPs and they give you a list of the NTP servers freely available okay let me choose this one I do not know which stratum it is right now so I just copy this IP address and you should remember the name is n is T 1 - P a dot US timing orgy fair enough now I go to wim etc' crony conf I removed all these I don't want this that I should be using these as my reference so I write my own entry server and I paste it that's it fair enough because I want a fast communication so I should be using I bus chair save and come out as usual and please restart the cron uni crony Wow how can I be sure again give the same command repeat the same command and it should now instead of this you should be getting your IP address let me check chronic sources look here wow there's great and wonderful this is the stratum 1 server that means it's a more trusted source it's a more trusted source and look the same means now my machine has changed it location from where it was earlier taking the time that is what they teach you in the books how to change it but what have what happens how the communication has done what kind of packets my machine has send how the server has it has responded how they have adjusted for the delay of time that happens during that like the transit what is this how this has happened now we will be focusing on the actual story so let me go back to the but right now it is everything is working fine and getting the right time everything Universal Time and the is - time NTP is enabled NTP is synchronized wow that's great and there are a couple of more like commands there's a chrony if I am not forgetting it CH crony sorry crony see and if you want to help just right heaven if I help here so see here hostname port number and the command so if I give a man crony see there are a couple of options that you can use confine crony D check the crony D here right so I'm I'm just avoiding that that thing so now the machine is getting the time from this stratum one IP address but what happens behind the scene how the how actually everything happened so let us understand about this so I'm back with my notepad orgy I did sorry not notepad okay so let's give a blank space here give some beautiful hashes something like this now how it works let us understand this not how it works couple of very interesting points no one you should know that NTP is actually the idea comes by mr. David Mills he he is the guy we should be thanking for NTP and he has done this project way back in 1985 so he is the guy who created this so thank you mr. David it is based on mark zulus algorithm but actually this algorithm is used only by a high stratum servers to get the accurate time so I will just it is not used by the clients so I will just mention it here but it is used only by high strata servers to get accurate time using several sources remember using several sources so but a client only use one source here source means the server not the peers right so I can mention here but normally a normal client on a normal day will use only one server I hope you will agree so how it use now let's start the walk working so what happens is that now another thing you should understand and TP time is not being stored or send of in actual mmddyy or Wi-Fi mmdd or Wi-Fi ddmm our format ntp timestamps are used in seconds so first point that you should remember is that and TP timestamps are stored in seconds and a very interesting thing here is that and the seconds are calculated since first January 1990 remember that the Year Cal c'mon uses the date or epic format since first January 1970 but the NTP starts its number of seconds since first January 1995 and the time strength is actually Earth I can write here timestamp is actually a 64 bit in size and from this 64-bit 32 bit is for number of seconds and 32 bit is for fraction of seconds so what we had learned is that when the client initiate the communication as I had mentioned there like this here client send the request with the timestamp so he is sending the his timestamp which is calculated in number of seconds since first January 1990 and which is a 64 bit in size of that 32 bit is the number of second and 32 bit is a fraction of second Wow this is new now so totally 64 bit right so client now why I use ntp i am using NDB because i think my time is not the correct time so means i consider my time as wrong time and the server time has the true time right so i'll just write here client time is say wrong time and server time server here means NTP server I will write here time is true damn so because the client has got wrong time he need to recalculate or adjusts his timing as per the response given by the NTP server so how it works okay let me assume let me assume here that say the steps steps involved very interesting point number one because I am in need of the true time so client and the client client send the request at wrong time I am the client and you yes you yes yes exactly you yes yes you are the person you means you who is viewing this video so client sent the request at wrong time right say wrong time is say it is 1312 1200 okay just to make it easy I make it say times 100 100 so let me give it a value here so I say a equal 200 a is the wrong time so client has sent the request at say 100 time when that time is hundred right now because of Internet connectivity right you will agree it is not at all possible that the serval that the server will get this request at 100 times at at the like the time is hundred so there must be some lid some some latency some couple of seconds so server say let us assume that server get the request at true time means the server time let us say true time is at say 150 right so that means okay let me write it here it will be interesting here like this a is 100 right okay so the wrong now the server get the request say the time is X equal to 150 means client has okay let me convert it is in seconds client has sent the to time request at 100 seconds because of Internet connectivity just just picture this just picture this because of Internet connectivity issues server will get the request after a predict a some amount of time some some some number of seconds it is practically not at all Pollak not feasible and possible that I had send you the request at 100 second and you receive the request at 100 second there must be some delay right so server has received the request at hundred seconds right just wait now third point server might be busy you are busy you are busy catering in some to some other clients so I could write here server might be busy so it doesn't send out the response let me until the true time right until I say right here through time let me give the time say at 160 missed server he has received the request at Mach 150 but because he was busy he will he will respond you back but at the at 160 seconds right so I make it a value here y equal to 160 so I've got three values by now me the client has sent you the request at 100 seconds because of Internet connectivity you receive my request at 150 seconds because you are busy catering to other clients you have responded to my request at 160 second this is a very fair and practical scenario right okay now for you you have sent me the request but again the Internet connectivity is here because so I will write here again of Internet connectivity blind will get the request at wrong time wrong time means wrong time very simple say he has received the request at 1:20 means the client clock was saying 1:20 when he has received the request so the client clock was saying 1:50 so let me give it a value again it's going to be like school maths so let me give it a value be equal to 120 now picture this client when the client clock was saying 100 he has sent the request but because of Internet connectivity the server get the request when his time was 150 but because server was busy he has responded back at the time 160 because of Internet connectivity the client get the respond back from the server when the client time was 120 so means 20 seconds has elapsed but gives the time difference when the client was at 100 the server was at somewhere around 150 okay not how the client failed determined that time that is the sole client determine the time spent on the network this is all in the algorithm you need not to worry about how the client will calculate how much time is spanned by the packet on the network so these are for a simple formula there say B minus a minus y minus X it is how that means that means guys that means B is 120 120 minus a a is 100 minus y is 160 and X in my case is 150 so that comes out to be for me it is 10 seconds so means 10-second is the time over which the packet was on internet now 6 step the client assumed but the but this time is the time for the packet to go to the server and coming back to and flow time so done' client assumed that time it took for the response to get from server to client is what it's very simple just ten divided by two so this comes out to be five cents because it is a two in flow traffic right now five second is the time that it tooks the response to get from server to client means when the server has sent the request and the time by which the client has received there is a latency of five seconds so five five-second it tooks for the packet to come from server to the client Wow making maths again very difficult oh my god now the client will do what client will add that time to the true time when the server send the response to estimate that it received the response at true dime so what the client will do so now the client will add that time to the to time when the server has sent the response so server has sent the respond at 160 so that and so now the client is supposed to add five seconds into 160 so that means it is going to add 160 plus five write that for me I am NOT very good in maths comes out to be 165 seconds right now the client knows flying now knows that he need to add 45 seconds to its clock 45 seconds how 45 seconds why 45 seconds look the client has received the request at 120 seconds but the time that he has got is 165 7 5 seconds so if you subtract the true time or the the so what you need to do you need to subtract the time at which the client received the request from the server and the estimated times right 165 time in step number seven so what it comes it comes that he need to add so 165 subtracted by 120 so 45 so he need to add 45 so that means 165 minus 120 that comes out to be for me I think it is 45 seconds that means there is a difference of 45 seconds between the client is clock and the server clock so the client will add 45 seconds to its clock so it is how the NTP time is calculated so the client will automatically increase its clock by 45 seconds 45 seconds right so it is what has happened when I had I will just go back here when I had configured myself as NTP client and when I had started this service so that all has happened so Ronnie sources have said this is all has happened in the background when I had given that come on and one more thing if you go to the chrony conf there is something known as the drift file you should also understand what is the drift file and how it records the gains and loss in time right so let us understand a bit about the drift file if you know the location of the drift file is valve lip crow adrift so if I seen this file where Lib sorry Ronnie drift it contains this time four point three five and four so it is a positive value let me write this number it is four point three five something right four point three four point three five nine okay and we'll close this four point three five nine I am opening my edit again so let us understand so it is how the eight steps are very important for you how the actually the NT we calculates the time now let us understand a bit about the drift file a bit about drift file what is the drift file right so drift file happens so why our drift happens so the reason why a drift means a deviation right a drift happen when your Hardware clock is either fast or slow compared to reference clock reference clock here means and TP server clock because look it's all about the crystals and the oscillations and TP cell right so only then the drift will will have will happen right but we as we are using NTP version 4 and all already told you so normally it can NTP version 4 can accurately keep your clock it up to 233 picoseconds and believe me it is a very very good equation I can write here accurately keep clock within 233 Pico seconds right and okay if I go back to my file here so it is a positive number right four point three five nine fine it's a positive number so you should understand this thing also so if if it's a positive number and drift file that means your clock is fast as compared to the NTP clock your clock is fast as compared to to reference the reference piece and DB server and in case if you find a negative value here if it's a negative number and drift file that means your clock is slow as compared to reference clock you should be knowing all these small things right and number there is measured in parts per million so that is not for point some seconds it is not seconds it is parts per million it is not second this is not four point three five nine seconds it is parts per million oh my god this is nonsense how can I calculate in seconds foof this is difficult I am NOT going to continue more okay let me continue and explain it to you so remember number in drift five is measured in ppm or you call it parts per million right now I've got a problem the problem is that let me put a lot of question marks how to convert it in two seconds and believe me I'm not good in math and still I am doing this crazy lot of question marks here so okay a very simple maths here look rule number one you should remember there are eighty six thousand and four hundred seconds in a day fact number one okay 86,400 seconds in a in a day so to convert it into ppm what I do let me put it like this it will be more easy right so that means how many parts per million so I say 86,400 divided by million means once tens hundred thousand ten thousand lakh million yeah six zeroes right right right right right right if I'm not wrong yeah okay so for me this comes out to be zero point zero eight six four seconds parts-per-million right so if you calculate its in ppm so it is this value so my drift file was showing what my drift file was showing a value of sorry I forgot the value let me go back and check it again four point three five nine four point three five nine so my value a four point three five nine right but this is in picoseconds this is in in ppm parts per million this is parts per million ppm how can I convert it into the seconds so okay that means that means this value tells me that means my machine is fast by four point three five nine ppm parts per million compared to my time source fair enough but please calculate convert it into seconds so now please convert it in seconds so it will be more human readable okay so what I do here I just point zero point zero eight six four multiplied by my value is four point three five nine four point three five nine so that comes out to be I don't know let me use my calculator if I open my calculator yeah so that means zero point zero eight six four right multiplied by what was the value what was the value four point five three nine so I sorry multiplied by four sorry four point five three nine zero point three nine seconds zero point three nine three seconds whatever so that means my machine is roughly fast by zero point three nine milliseconds as compared to my reference I can write it zero point three nine milliseconds right so that means roughly my machine is fast by zero sorry 0.39 milliseconds as compared to my time source I hope you understand these things so whenever you configure NTP so it is then you just give the server IP address and just start the service it is all that happens in the background it is all that happens in the background I hope you understand these concepts and just try to see on your machines how the things works and how the NTP works so it's my a very small effort of explaining you how NTP works deep inside so thank you very much for seeing this video god bless and and I will be back again with some couple of more very interesting videos thank you very much god bless I'm stopping the video now
Info
Channel: networknutsdotnet
Views: 25,391
Rating: 4.7486911 out of 5
Keywords: rhce on rhel7, rhel7, rhce training video, red hat linux videos, red hat linux training, Red Hat Enterprise Linux (Operating System), Network Time Protocol (Protocol), /etc/chrony.conf, systemctl status chronyd, /var/lib/chrony/drift, networknuts, alok srivastava, best red hat linux training, online linux training
Id: vHR0OF7iVRk
Channel Id: undefined
Length: 45min 6sec (2706 seconds)
Published: Wed Oct 29 2014
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.