-
大小: 4KB文件類(lèi)型: .rar金幣: 1下載: 0 次發(fā)布日期: 2021-01-05
- 語(yǔ)言: 其他
- 標(biāo)簽: linux??ntp??實(shí)時(shí)校時(shí)??ntp下載??ntp客戶(hù)端??
資源簡(jiǎn)介
功能:ntp客戶(hù)端,實(shí)時(shí)校時(shí)
運(yùn)行環(huán)境:linux
內(nèi)核版本:2.6.25-14.fc9.i686
描述:嚴(yán)格按照rfc1305的規(guī)范來(lái)編寫(xiě)的ntp客戶(hù)端程序,時(shí)間服務(wù)器使用國(guó)家授時(shí)中心。ip:210.72.145.44
程序中有必要的注釋?zhuān)阌陂喿x,復(fù)制在任意目錄下直接make,./ntp_client就可以實(shí)現(xiàn)時(shí)間的實(shí)時(shí)校對(duì)。
根據(jù)需要可以選擇粗略對(duì)時(shí)和精確對(duì)時(shí)兩種,但在精確對(duì)時(shí)的時(shí)差和延遲計(jì)算方法上還有待進(jìn)一步研究。
enjoy!
代碼片段和文件信息
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#define?NTP_SERVER??“133.100.11.8“
#define?NTP_PORT????123
#define?JAN_1970????0x83aa7e80 //3600s*24h*(365days*70years+17days)
#define?NTPFRAC(x)?(4294?*?(x)?+?((1981?*?(x))?>>?11))
#define?USEC(x)?(((x)?>>?12)?-?759?*?((((x)?>>?10)?+?32768)?>>?16))
struct?ntptime
{
??unsigned?int?coarse;
??unsigned?int?fine;
};
void
send_packet?(int?fd)
{
??unsigned?int?data[12];
??int?ret;
??struct?timeval?now;
#define?LI?0 //協(xié)議頭中的元素
#define?VN?3
#define?MODE?3
#define?STRATUM?0
#define?POLL?4
#define?PREC?-6
??if?(sizeof?(data)?!=?48)
????{
???
?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----
?????文件????????149??2010-11-08?15:28??ntp_client\Makefile
?????文件???????8377??2010-11-08?15:39??ntp_client\ntp_client.c
?????文件????????367??2010-11-08?15:49??ntp_client\readme.txt
?????目錄??????????0??2010-11-08?15:40??ntp_client
-----------?---------??----------?-----??----
?????????????????8893????????????????????4
評(píng)論
共有 條評(píng)論