i have this code

#include <stdio.h>
#include <stdlib.h>
#include <csim.h>

#define NUM_CLIENTS 5
#define DB_SIZE 500
#define DATA_SIZE 1024
#define BANDWIDTH 10000
#define CACHE_SIZE 100
#define HOT_DATA_ITEMS 50
#define HOT_DATA_ACCESS_PROB 0.8
#define COLD_DATA_ITEMS (DB_SIZE - HOT_DATA_ITEMS)
#define HOT_DATA_UPDATE_PROB 0.33

int query_count = 0, hit_count = 0, cold_count = 0, update_count = 0;
double query_delay = 0;

int cache[CACHE_SIZE]; // array to store cached data items
int hot_data[HOT_DATA_ITEMS]; // array to store hot data items
int cold_data[COLD_DATA_ITEMS]; // array to store cold data items

double T_QUERY = 5; // mean query generation time
double T_UPDATE = 5; // mean update arrival time

void init_data() {
int i;
// initialize cache with -1 to indicate empty slots
for (i = 0; i < CACHE_SIZE; i++) {
cache[i] = -1;
}
// initialize hot data items and cold data items
for (i = 0; i < HOT_DATA_ITEMS; i++) {
hot_data[i] = rand() % DB_SIZE; // generate random hot data item id
cold_data[i] = -1; // initialize cold data item with -1
}
for (i = 0; i < COLD_DATA_ITEMS; i++) {
cold_data[i] = rand() % DB_SIZE; // generate random cold data item id
}
}

int is_in_cache(int data_id) {
int i;
// check if data item is in cache
for (i = 0; i < CACHE_SIZE; i++) {
if (cache[i] == data_id) {
return 1; // data item is in cache
}
}
return 0; // data item is not in cache
}

void update_cache(int data_id) {
int i, lru_index = 0, lru_time = simtime() + 1;
// update cache with new data item
for (i = 0; i < CACHE_SIZE; i++) {
if (cache[i] == data_id) {
return; // data item is already in cache, no need to update
}
if (cache[i] == -1) {
cache[i] = data_id; // found empty slot, update with new data item
return;
}
if (lastchange(cache[i]) < lru_time) {
lru_index = i; // found least recently used slot
lru_time = lastchange(cache[i]);
}
}
cache[lru_index] = data_id; // update least recently used slot with new data item
}

int find_data(int data_id) {
int i;
// check if data item is a hot data item
for (i = 0; i < HOT_DATA_ITEMS; i++) {
if (hot_data[i] == data_id) {
return HOT_DATA_ACCESS_PROB >= ((double) rand() / RAND_MAX); // check if hot data item is accessed
}
}
// check if data item is a cold data item
for (i = 0; i < COLD_DATA_ITEMS; i++) {
if (cold_data[i] == data_id) {
return 1; // data item is a cold data item and is available
}
}
cold_count++; // data item is not in database, counted as cold data access
return 0; // data item is not available
}

double generate_query() {
int data_id = rand() % DB_SIZE; // generate random data item id
if (is_in_cache(data_id)) {
query_count++;
wait(0.001); // wait for a small amount of time to simulate cache hit
return 0;
}
wait(expntl(1.0/T_QUERY)); // wait for mean query generation time to simulate cache miss
if (find_data(data_id)) {
hit_count++; // data item found, counted as cache hit
update_cache(data_id); // update cache with new data item
}
query_count++;
return simtime() - event_time; // calculate query delay
}

void generate_update(int data_id) {
if (HOT_DATA_UPDATE_PROB >= ((double) rand() / RAND_MAX)) {
hot_data[rand() % HOT_DATA_ITEMS] = data_id; // update a random hot data item
} else {
cold_data[rand() % COLD_DATA_ITEMS] = data_id; // update a random cold data item
}
update_count++;
}

void server() {
int data_id = rand() % DB_SIZE; // generate random data item id
generate_update(data_id); // update database with new data item
write("Data updated: ");
writeline(data_id);
hold(expntl(1.0/T_UPDATE)); // wait for mean update arrival time
}

void client() {
while (1) {
generate_query(); // generate queries continuously
}
}

int main() {
init_data(); // initialize data
T_QUERY = 5; // set mean query generation time
T_UPDATE = 5; // set mean update arrival time
set_seed(12345);
start_simulation(); // start CSIM simulation
process(“main”); // create main process
int i;
for (i = 0; i < NUM_CLIENTS; i++) {
process(client); // create client processes
}
process(server); // create server process
hold(10000.0); // wait for simulation to finish
printf(“Total queries: %d, hits: %d, hit rate: %.2f%%\n”,
query_count, hit_count, (double) hit_count / query_count * 100);
printf(“Cold data queries: %d, update count: %d\n”, cold_count, update_count);
return 0;
}

which is built for the following requirements :
Implement a simple pull-based cache invalidation scheme by using CSIM. In the scheme, a node
generates a query and sends a request message to a server if the queried data item is not found in its local
cache. If the node generates a query that can be answered by its local cache, it sends a check message to
the server for validity. The server replies to the node with a requested data item or a confirm message. A
set of data items is updated in the server. This scheme ensures a strong consistency that guarantees to
access the most updated data items.
2. Refer to the following technical paper and its simulation models (e.g., server, client, caching, data query
and update, etc.):
• G. Cao, “A Scalable Low-Latency Cache Invalidation Strategy for Mobile Environments,” ACM
Mobicom, pp. 200-209, 2000
For the sake of simplicity, use the following simulation parameters. Run your simulation several times by
changing the simulation parameters (e.g., T_query and T_update). You can make an assumption and define
your own parameter(s). Then draw result graphs in terms of (i) cache hit ratio and (ii) query delay by
changing mean query generation time and mean update arrival time, similar to Figs. 3 and 4 in the paper.
Note that remove a cold state before collecting any results.
Parameter Values
Number of clients 5
Database (DB) size 500 items
Data item size 1024 bytes
Bandwidth 10000 bits/s
Cache size 100 items
Cache replacement policy LRU
Mean query generate time (T_query) 5, 10, 25, 50, 100 seconds
Hot data items 1 to 50
Cold data items remainder of DB
Hot data access prob. 0.8
Mean update arrival time (T_update) 5, 10, 20, 100, 200 seconds
Hot data update prob. 0.33


but it turns out the author did not use the proper variables and functions of the csim.h file, for reference i will give you the csim.h file contents below, assume all the functions are defined and rewrite the above code to function properly

#ifndef CSIM_H
#define CSIM_H

/*
* CSim - Discrete system simulation library
*
* Copyright © 2002 Vikas G P <<PRESIDIO_ANONYMIZED_EMAIL_ADDRESS>>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
/

/
* The CSim library provides an embeddable frame-work for discrete system
* simulation, using the paradigm adopted by SIMSCRIPT. It is written in C,
* as opposed to most other such libraries, which are written in C++.
/

#ifndef NULL
# define NULL 0
#endif

#include “queue.h”

/
* Each entity of a system is represented by a CsEntity. They are created with
* the function cs_entity_new(…)
*/
typedef struct _CsEntity{
CsQueue attribute_queue;
} CsEntity;

/
* Each event is represented by a CsEvent.
*/
typedef struct _CsEvent{
int (*event_routine)(void user_data);
int count;
} CsEvent;

/ Each set is represented by a CsSet */
typedef struct CsSet{
CsQueue queue;
int discipline;
int count;
} CsSet;

/ Data type for clock time /
typedef long simtime_t;

/ Macro for event routines */
#define CS_EVENT_ROUTINE(func) int (*func)(void )

/ Synonym for the current time /
#define NOW cs_get_clock_time()

/ Checks if set is empty /
#define cs_set_is_empty(set) cs_set_count_elements((set))

/ Set operations /

#define FIFO 1
#define LIFO 2

/ functions prefixed with cs are exported to the outside /

/
* Initializes the library.
/
int cs_init(void);

/
* Starts the simulation, executing the events until it runs out of events.
/
int cs_start_simulation(void);

/ Entity functions /

/
* Creates a new entity.
*/
CsEntity cs_entity_new(void);

/ Destroys an entity */
void cs_entity_destroy(CsEntity entity);

/
* Adds an attribute to an entity’s list of attributes.
*/
int cs_attribute_add(CsEntity *entity, char name);

/ Set’s an attribute to the specified value */
int cs_attribute_set(CsEntity *entity, char name, int new_value);

/ Returns the value of the specified attribute */
int cs_attribute_get(CsEntity *entity, char name);

/
* This is a faster way to specify all the attributes of an entity.
*/
void cs_attribute_specify(CsEntity *entity, char *attr_names);

/ To create temp. entities */
CsEntity *cs_entity_new_with_attributes(char *attr_names);

/ Event functions /

/
* Creates a new event.
*/
CsEvent *cs_event_new(int (*event_routine)(void user_data));

/ Get’s the event’s count */
int cs_event_get_count(CsEvent event);

/
* Schedules an event to executed at the specified time.
*/
int cs_event_schedule(CsEvent *event, simtime_t time, void user_data);

/
* Same as the cs_event_schedule, but the time is specified as an offset from
* the current clock time.
*/
int cs_event_schedule_relative(CsEvent *event, simtime_t offset, void user_data);

/ Set functions /

/ Creates a new set */
CsSet cs_set_new(int discipline);

/ “Files”, i.e., inserts an entity into a set */
void cs_set_file(CsSet *set, CsEntity entity);

/ Returns the top-most member of a set, and removes it from the set */
CsEntity *cs_set_remove(CsSet set);

/ Same as above, but doesn’t remove it */
CsEntity *cs_set_remove_nodestroy(CsSet set);

/ Return number of elements in a set */
int cs_set_count_elements(CsSet set);

/ Destroys a set */
void cs_set_destroy(CsSet set);


/ Misc. functions /

/ Get’s the current time /
simtime_t cs_get_clock_time(void);

#endif / CSIM_H */