NTP_simulation,NTP开放源码 的模拟配置问题,官方描述不正确
来源:互联网 发布:ubuntu zip解压 编辑:程序博客网 时间:2024/06/05 23:48
所用的ntp 开发包是 ntp-dev-4.2.7p56
一、问题描述
NTP的模拟一直想用原汁原味的源代码来模拟,可惜一直卡在配置问题上,没有进展近两个星期。最终还是看代码修改了一条源代码的配置才搞定了,开源代码就是没有一个完善的文档,以及版本问题跟新系统。
用的是ntp.conf是官方网站描述的配置释例:
# Client configuration disable kernel server pogo driftfile ./ntp.drift statsdir ./ntpstats/ filegen loopstats type day enable filegen peerstats type day enable # Simulation configuration simulate { simulation_duration = 86400 beep_delay = 3600 # Server 1server = louie.udel.edu { server_offset = 0 duration = 50000 {freq_offset = 400wander = 1.0jitter = 0.001prop_delay = 0.001proc_delay = 0.001 } duration = 6400 {freq_offset = 200wander = 1.0jitter = 0.001prop_delay = 0.001proc_delay = 0.001 }} # Server 2server = baldwin.udel.edu { server_offset = 0.02 duration = 10000 {freq_offset = 400wander = 1.0jitter = 0.001prop_delay = 0.5proc_delay = 0.001 } duration = 60000 {freq_offset = 200wander = 1.0jitter = 0.05prop_delay = 0.005proc_delay = 0.001 }} }
存为/etc/ntp.conf,运行 ./ntpdsim后有如下提示:
18 Dec 16:38:41 ntpdsim[4867]: proto: precision = 0.200 usec18 Dec 16:38:41 ntpdsim[4867]: line 3 column 5 syntax error, unexpected T_Server, expecting T_EOCConfiguring Simulator...Some ntpd-specific commands in the configuration file will be ignored.ERROR!! I couldn't find a "simulate" block for configuring the simulator.Check your configuration file.
也就是说server 后面缺少一个结束符。
二、解决办法
1)检查关键字是否正确
开始怀疑 是不是 sever 写错了,因该写成T_Server
阅读ntp_keyword.h中 keyword_text[181], T_EOC对应于NULL。T_Server 对应于server 字符串,T_Sim_Duration对应于 "simulation_duration",因此那些token对应的字符串可以在keyword_text中找到。同时,keyword-gen.c是生存ntp_keyword.h的原文件,struct key_tok ntp_keywords[] 将Token和对应的脚本文件变量字符串 一一对应。
struct key_tok ntp_keywords[] = {{ "...", T_Ellipsis, FOLLBY_TOKEN },{ "allpeers", T_Allpeers, FOLLBY_TOKEN },{ "automax", T_Automax, FOLLBY_TOKEN },{ "broadcast", T_Broadcast, FOLLBY_STRING },{ "broadcastclient", T_Broadcastclient, FOLLBY_TOKEN },{ "broadcastdelay", T_Broadcastdelay, FOLLBY_TOKEN },……
/* simulator commands */{ "simulate", T_Simulate, FOLLBY_TOKEN },{ "simulation_duration",T_Sim_Duration, FOLLBY_TOKEN },{ "beep_delay", T_Beep_Delay, FOLLBY_TOKEN },{ "duration", T_Duration, FOLLBY_TOKEN },{ "server_offset", T_Server_Offset, FOLLBY_TOKEN },{ "freq_offset", T_Freq_Offset, FOLLBY_TOKEN },{ "wander", T_Wander, FOLLBY_TOKEN },{ "jitter", T_Jitter, FOLLBY_TOKEN },{ "prop_delay", T_Prop_Delay, FOLLBY_TOKEN },{ "proc_delay", T_Proc_Delay, FOLLBY_TOKEN },};验证关键字是正确的,没有错。
2) T_EOC的纠正
在ntp_scanner.c中,有一个is_EOC函数。来判断是否是T_EOC类型。
static intis_EOC( int ch ){ if ((old_config_style && (ch == '\n')) || (!old_config_style && (ch == ';'))) return 1; return 0;}
而在 ntp_config.c 中
int old_cofig_style==1;
也就是在配置文件中\n相当于T_EOC,可是一直解析不对
将old_config_style=0,即启用 ;作为T_EOC类型。并修改配置文件:
#client configuration disable kernel; server pogo; driftfile ./ntp.drift; statsdir ./ntpstats/; filegen loopstats type day enable; filegen peerstats type day enable; # Simulation configuration simulate { simulation_duration=86400; beep_delay = 3600; # Beep_Delay = 3600 EOC server = 10.2.2.23 { server_offset = 0; duration = 50000 { freq_offset = 400; wander = 1.0; jitter = 0.001; prop_delay = 0.001; proc_delay = 0.001; } duration = 6400 { freq_offset = 200; wander = 1.0; jitter = 0.001; prop_delay = 0.001; proc_delay = 0.001; } } # Server 2 server = baldwin.udel.edu { server_offset = 0.02; duration = 10000 { freq_offset = 400; wander = 1.0; jitter = 0.001; prop_delay = 0.5; proc_delay = 0.001; } duration = 60001 { freq_offset = 200; wander = 1.0; jitter = 0.05; prop_delay = 0.005; proc_delay = 0.001; } } }最后得到如下正确输出:
Received packet from 128.4.1.24 on 127.0.0.1WARNING: e->time 81169 comes before sim_time 81170 (gap -0.982291)WARNING: e->time + gap 81168 comes before local_time 81171Received packet from 10.2.2.23 on 127.0.0.1WARNING: e->time 81202 comes before sim_time 81203 (gap -0.982835)WARNING: e->time + gap 81201 comes before local_time 81204Received packet from 128.4.1.24 on 127.0.0.1WARNING: e->time 81233 comes before sim_time 81234 (gap -0.982523)WARNING: e->time + gap 81232 comes before local_time 81235Received packet from 10.2.2.23 on 127.0.0.1WARNING: e->time 81266 comes before sim_time 81267 (gap -0.981338)WARNING: e->time + gap 81265 comes before local_time 81268Received packet from 128.4.1.24 on 127.0.0.1WARNING: e->time 81299 comes before sim_time 81300 (gap -0.982363)WARNING: e->time + gap 81298 comes before local_time 81301Received packet from 10.2.2.23 on 127.0.0.1WARNING: e->time 81333 comes before sim_time 81334 (gap -0.981446)WARNING: e->time + gap 81332 comes before local_time 81335
终于成功了,看来还是要自己研究代码了!
- NTP_simulation,NTP开放源码 的模拟配置问题,官方描述不正确
- NTP服务器的配置
- ntp server的配置
- 关于NTP的配置
- NTP服务器的配置
- NTP服务器的配置
- WINDOWS的NTP配置
- ntp服务器的配置
- NTP的配置
- ntp同步的问题
- 解决拷贝的虚拟机网卡配置不正确的问题
- 解决“由于应用程序配置不正确,应用程序未能启动”的问题
- 应用程序配置不正确,程序无法启动的问题小结
- “由于应用程序配置不正确,应用程序未能启动”的问题
- “由于应用程序配置不正确,应用程序未能启动”的问题
- 一种解决运行程序报“应用程序配置不正确”的问题
- “由于应用程序配置不正确,应用程序未能启动”的问题
- “由于应用程序配置不正确,应用程序未能启动”的问题
- 《.NET 软件工程师就业求职手册》 - 书摘精要
- 2299 Ultra-QuickSort
- Climbing Worm
- Js动态添加表格行
- SaveGameBackup绿色版-免费的游戏通关记录备份软件
- NTP_simulation,NTP开放源码 的模拟配置问题,官方描述不正确
- CacheBooster-优化硬盘缓存从而提高系统性能
- Java 判断字符串是否为空的四种方法
- 大一的各种c++实验课小程序
- 做到以下五点,让你的主页人见人爱
- JSP学习笔记
- jdbc 连接 Access 乱码解决
- DWR调用Java中的方法
- (void) (&_x == &_y)