Annotation of embedaddon/ntp/include/ntpsim.h, revision 1.1

1.1     ! misho       1: /* ntpsim.h
        !             2:  *
        !             3:  * The header file for the ntp discrete event simulator. 
        !             4:  *
        !             5:  * Written By: Sachin Kamboj
        !             6:  *             University of Delaware
        !             7:  *             Newark, DE 19711
        !             8:  * Copyright (c) 2006
        !             9:  */
        !            10: 
        !            11: #ifndef NTPSIM_H
        !            12: #define NTPSIM_H
        !            13: 
        !            14: #include <stdio.h>
        !            15: #include <math.h>
        !            16: #ifdef HAVE_SYS_SOCKET_H
        !            17: #include <sys/socket.h>
        !            18: #endif
        !            19: #include <arpa/inet.h>
        !            20: #include "ntp_syslog.h"
        !            21: #include "ntp_fp.h"
        !            22: #include "ntp.h"
        !            23: #include "ntp_select.h"
        !            24: #include "ntp_malloc.h"
        !            25: #include "ntp_refclock.h"
        !            26: #include "recvbuff.h"
        !            27: #include "ntp_io.h"
        !            28: #include "ntp_stdlib.h"
        !            29: 
        !            30: #include "ntp_data_structures.h"
        !            31: 
        !            32: /* CONSTANTS */
        !            33: 
        !            34: #ifdef PI
        !            35: # undef PI
        !            36: #endif
        !            37: #define PI 3.1415926535         /* The world's most famous constant */
        !            38: #define SIM_TIME 86400         /* end simulation time */
        !            39: #define NET_DLY .001            /* network delay */
        !            40: #define PROC_DLY .001          /* processing delay */
        !            41: #define BEEP_DLY 3600           /* beep interval (s) */
        !            42: 
        !            43: 
        !            44: /* Discrete Event Queue
        !            45:  * --------------------
        !            46:  * The NTP simulator is a discrete event simulator.
        !            47:  *
        !            48:  * Central to this simulator is an event queue which is a priority queue
        !            49:  * in which the "priority" is given by the time of arrival of the event.
        !            50:  *
        !            51:  * A discrete set of events can happen and are stored in the queue to arrive
        !            52:  * at a particular time.
        !            53:  */
        !            54: 
        !            55: /* Possible Discrete Events */
        !            56: 
        !            57: typedef enum {
        !            58:     BEEP,          /* Event to record simulator stats */
        !            59:     CLOCK,         /* Event to advance the clock to the specified time */
        !            60:     TIMER,         /* Event that designates a timer interrupt. */
        !            61:     PACKET         /* Event that designates arrival of a packet */
        !            62: } funcTkn;
        !            63: 
        !            64: 
        !            65: /* Event information */
        !            66: 
        !            67: typedef struct {
        !            68:     double time;       /* Time at which event occurred */
        !            69:     funcTkn function;  /* Type of event that occured */
        !            70:     union {
        !            71:         struct pkt evnt_pkt;
        !            72:         struct recvbuf evnt_buf;
        !            73:     } buffer;          /* Other data associated with the event */
        !            74: #define ntp_pkt buffer.evnt_pkt
        !            75: #define rcv_buf buffer.evnt_buf
        !            76: } Event;
        !            77: 
        !            78: 
        !            79: /* Server Script Information */
        !            80: 
        !            81: typedef struct {
        !            82:     double duration;
        !            83:     double freq_offset;
        !            84:     double wander;
        !            85:     double jitter; 
        !            86:     double prop_delay;
        !            87:     double proc_delay;
        !            88: } script_info;   
        !            89: 
        !            90: 
        !            91: 
        !            92: /* Server Structures */
        !            93: 
        !            94: typedef struct {
        !            95:     double server_time;             /* Server time */
        !            96:     sockaddr_u *addr;                      /* Server Address */
        !            97:     queue *script;                  /* Server Script */
        !            98:     script_info *curr_script;       /* Current Script */
        !            99: } server_info;
        !           100: 
        !           101: 
        !           102: /* Simulation control information */
        !           103: 
        !           104: typedef struct Sim_Info {
        !           105:     double sim_time;      /* Time in the simulation */
        !           106:     double end_time;      /* Time at which simulation needs to be ended */
        !           107:     double beep_delay;    /* Delay between simulation "beeps" at which
        !           108:                              simulation  stats are recorded. */
        !           109:     int num_of_servers;   /* Number of servers in the simulation */
        !           110:     server_info *servers; /* Pointer to array of servers */
        !           111: } sim_info;
        !           112: 
        !           113: 
        !           114: /* Local Clock (Client) Variables */
        !           115: 
        !           116: typedef struct Local_Clock_Info {
        !           117:     double local_time;     /* Client disciplined time */
        !           118:     double adj;            /* Remaining time correction */
        !           119:     double slew;           /* Correction Slew Rate */
        !           120:     double last_read_time; /* Last time the clock was read */
        !           121: } local_clock_info;
        !           122: 
        !           123: extern local_clock_info simclock;   /* Local Clock Variables */
        !           124: extern sim_info simulation;         /* Simulation Control Variables */
        !           125: 
        !           126: /* Function Prototypes */
        !           127: 
        !           128: int     ntpsim                  (int argc, char *argv[]);
        !           129: Event    *event                  (double t, funcTkn f);
        !           130: void     sim_event_timer         (Event *e);
        !           131: int      simulate_server         (sockaddr_u *serv_addr,
        !           132:                                  struct interface *inter,
        !           133:                                  struct pkt *rpkt);
        !           134: void     sim_update_clocks       (Event *e);
        !           135: void     sim_event_recv_packet   (Event *e);
        !           136: void     sim_event_beep          (Event *e);
        !           137: void     abortsim                (char *errmsg);
        !           138: double  gauss                   (double, double);
        !           139: double  poisson                 (double, double);
        !           140: int      yyparse                 (void);
        !           141: void     create_server_associations (void);
        !           142: 
        !           143: #endif /* NTPSIM_H */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>