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 budget_min.tv_sec = 5;
44 period_max = frsh_msec_to_rel_time(3369);
46 ret = frsh_contract_set_basic_params
50 FRSH_WT_INDETERMINATE,
52 if (ret != 0) PUT_ERROR ("could not set basic params");
54 #if !FRSH_AUTOMATIC_PRIO_ASSIGN_ENABLE
55 ret = frsh_contract_set_preemption_level(&contract, 5);
56 if (ret != 0) PUT_ERROR ("could not set preemption level");
59 printf("Negotiating a contract\n");
60 ret = frescan_bwres_negotiate(NETWORK, &contract, &ss, &accepted);
61 if (ret != 0) PUT_ERROR ("could not negotiate succesfully");
64 printf("The contract was accepted, ss:%u\n", ss);
65 ret = frescan_servers_get_data(NETWORK, &server_params, ss);
66 if (ret != 0) PUT_ERROR ("could not get servers data");
68 printf("B:%u, T=(%u,%u), P:%u\n",
70 server_params.period.tv_sec,
71 server_params.period.tv_nsec,
74 printf("The contract was not accepted\n");