Lines Matching +full:sample +full:- +full:time

46 	return (e1->time - e2->time);  in determine_event_ordering()
63 /* Simply convert the time received to double and subtract */ in determine_recv_buf_ordering()
64 LFPTOD(&b1->recv_time, recv_time1); in determine_recv_buf_ordering()
65 LFPTOD(&b2->recv_time, recv_time2); in determine_recv_buf_ordering()
67 return (int)(recv_time1 - recv_time2); in determine_recv_buf_ordering()
82 -1, in create_server_associations()
112 simclock.slew = 500e-6; in ntpsim()
143 * Watch out here, we want the real time, not the silly stuff. in ntpsim()
161 * Pop the queue until nothing is left or time is exceeded in ntpsim()
167 /* Update all the clocks to the time on the event */ in ntpsim()
171 (*event_ptr[curr_event->function])(curr_event); in ntpsim()
192 strlcpy(loopback_interface->name, "IPv4loop", in init_sim_io()
193 sizeof(loopback_interface->name)); in init_sim_io()
194 loopback_interface->flags = INT_UP | INT_LOOPBACK; in init_sim_io()
195 loopback_interface->fd = -1; in init_sim_io()
196 loopback_interface->bfd = -1; in init_sim_io()
197 loopback_interface->ifnum = 1; in init_sim_io()
198 loopback_interface->family = AF_INET; in init_sim_io()
199 AF(&loopback_interface->sin) = AF_INET; in init_sim_io()
200 SET_ADDR4(&loopback_interface->sin, LOOPBACKADR); in init_sim_io()
201 SET_PORT(&loopback_interface->sin, NTP_PORT); in init_sim_io()
202 AF(&loopback_interface->mask) = AF_INET; in init_sim_io()
203 SET_ADDR4(&loopback_interface->mask, LOOPNETMASK); in init_sim_io()
215 e->time = t; in event()
216 e->function = f; in event()
240 (*rbuf->receiver)(rbuf); in sim_event_timer()
272 l_fp lfp_host; /* host-order l_fp */ in simulate_server()
293 curr_script = server->curr_script; in simulate_server()
296 * Masquerade the reply as a stratum-1 server with a GPS clock in simulate_server()
302 xpkt.ppoll = rpkt->ppoll; in simulate_server()
303 xpkt.precision = rpkt->precision; in simulate_server()
312 t2 ----------------- t3 in simulate_server()
316 d1 = poisson(curr_script->prop_delay, curr_script->jitter); in simulate_server()
317 d2 = poisson(curr_script->proc_delay, 0); in simulate_server()
318 d3 = poisson(curr_script->prop_delay, curr_script->jitter); in simulate_server()
324 * Note: This function is called at time t1. in simulate_server()
327 NTOHL_FP(&rpkt->xmt, &lfp_host); in simulate_server()
329 t2 = server->server_time + d1; in simulate_server()
330 t3 = server->server_time + d1 + d2; in simulate_server()
334 xpkt.org = rpkt->xmt; in simulate_server()
350 rbuf.fd = inter->fd; in simulate_server()
356 * arrival time (t4) of the packet at the client in simulate_server()
359 e->rcv_buf = rbuf; in simulate_server()
363 * Check if the time of the script has expired. If yes, delete it. in simulate_server()
365 if (curr_script->duration > simulation.sim_time && in simulate_server()
366 NULL == HEAD_PFIFO(server->script)) { in simulate_server()
373 UNLINK_FIFO(curr_script, *server->script, link); in simulate_server()
390 /* Compute the time between the last update event and this update */ in sim_update_clocks()
391 time_gap = e->time - simulation.sim_time; in sim_update_clocks()
394 printf("WARNING: e->time %.6g comes before sim_time %.6g (gap %+.6g)\n", in sim_update_clocks()
395 e->time, simulation.sim_time, time_gap); in sim_update_clocks()
398 if (e->time + time_gap < simclock.local_time) in sim_update_clocks()
399 printf("WARNING: e->time + gap %.6g comes before local_time %.6g\n", in sim_update_clocks()
400 e->time + time_gap, simclock.local_time); in sim_update_clocks()
401 simclock.local_time = e->time + time_gap; in sim_update_clocks()
403 /* Advance the simulation time */ in sim_update_clocks()
404 simulation.sim_time = e->time; in sim_update_clocks()
411 simulation.servers[i].curr_script->freq_offset += in sim_update_clocks()
412 gauss(0, time_gap * simulation.servers[i].curr_script->wander); in sim_update_clocks()
415 (1 + simulation.servers[i].curr_script->freq_offset); in sim_update_clocks()
427 simclock.local_time -= adj; in sim_update_clocks()
429 simclock.adj -= adj; in sim_update_clocks()
450 memcpy(rbuf, &e->rcv_buf, sizeof(*rbuf)); in sim_event_recv_packet()
452 /* Store the local time in the received packet */ in sim_event_recv_packet()
453 DTOLFP(simclock.local_time, &rbuf->recv_time); in sim_event_recv_packet()
469 char *dash = "-----------------";
473 enqueue(event_queue, event(e->time + simulation.beep_delay, BEEP));
483 n->time, n->clk_time, n->ntp_time);
488 n->time, n->clk_time, n->ntp_time);
507 * -----------------------------------
517 * get_systime - return the system time in NTP timestamp format
521 l_fp *now /* current system time in l_fp */ )
532 simclock.local_time += 200e-9;
538 ntp_node.ntp_time += 200e-9;
546 * adj_systime - advance or retard the system clock exactly like the
551 double now /* time adjustment (s) */
561 * in microsecond quanta, but some adjust in 10-ms quanta. We
568 dtemp = -dtemp;
571 dtemp -= adjtv.tv_sec;
574 dtemp -= adjtv.tv_usec / 1e6;
583 adjtv.tv_sec = -adjtv.tv_sec;
584 adjtv.tv_usec = -adjtv.tv_usec;
585 sys_residual = -sys_residual;
594 * step_systime - step the system clock. We are religious here.
603 printf("step_systime: time %.6f adj %.6f\n",
611 * gauss() - returns samples from a gaussion distribution
613 double /* Gaussian sample */
615 double m, /* sample mean */
616 double s /* sample standard deviation (sigma) */
622 * Roll a sample from a Gaussian distribution with mean m and
631 return (m + s * sqrt(-2. * log(q1)) * cos(2. * PI * q2));
636 * poisson() - returns samples from a network delay distribution
638 double /* delay sample (s) */
647 * Roll a sample from a composite distribution with propagation
648 * delay m and exponential distribution time with parameter s.
655 return (m - s * log(q1 * s));