1 #include <stdio.h> // perror
2 #include <stdlib.h> // exit
3 #include <unistd.h> // sleep
8 #include "frescan_bwres.h"
9 #include "frescan_servers.h"
11 #define PUT_ERROR(s) {perror (s); exit (-1);}
19 frescan_init_params_t init_params;
21 frsh_contract_t contract;
22 frescan_server_params_t server_params;
24 frsh_rel_time_t budget_min, period_max;
26 init_params.net = NETWORK;
27 init_params.node = LOCAL_NODE;
28 init_params.tx_fp_max_prio = 10;
29 init_params.rx_num_of_channels = 10;
30 init_params.rx_channel_max_prio = NULL;
32 printf("Initializing FRESCAN\n");
33 ret = frescan_init(&init_params);
34 if (ret != 0) PUT_ERROR ("could not init FRESCAN");
36 printf("Initializing BWRES\n");
37 ret = frescan_bwres_init(NETWORK);
38 if (ret != 0) PUT_ERROR ("could not init BWRES");
40 ret = frsh_contract_init(&contract);
41 if (ret != 0) PUT_ERROR ("could not init contract");
43 ret = frescan_fna_network_bytes_to_budget (NETWORK, 10, &budget_min);
44 if (ret != 0) PUT_ERROR ("could not transform bytes to budget");
46 period_max = frsh_msec_to_rel_time(3369); // 3,369 secs
48 ret = frsh_contract_set_basic_params
52 FRSH_WT_INDETERMINATE,
54 if (ret != 0) PUT_ERROR ("could not set basic params");
56 #if !FRSH_AUTOMATIC_PRIO_ASSIGN_ENABLE
57 ret = frsh_contract_set_preemption_level(&contract, 5);
58 if (ret != 0) PUT_ERROR ("could not set preemption level");
61 printf("Negotiating a contract\n");
62 ret = frescan_bwres_negotiate(NETWORK, &contract, &ss, &accepted);
63 if (ret != 0) PUT_ERROR ("could not negotiate succesfully");
66 printf("The contract was accepted, ss:%u\n", ss);
67 ret = frescan_servers_get_data(NETWORK, &server_params, ss);
68 if (ret != 0) PUT_ERROR ("could not get servers data");
70 printf("B:%u, T=(%u,%u), P:%u\n",
72 server_params.period.tv_sec,
73 server_params.period.tv_nsec,
76 printf("The contract was not accepted\n");