6 #include "test_config.h"
12 #include <sys/socket.h>
13 #include <netinet/in.h>
14 #include <arpa/inet.h>
17 #include "fwp_confdefs.h"
18 #include <fres_sa_scenario.h>
22 int main(int argc, char* argv[])
24 char msg[MSGBUFFSIZE];
26 frsh_resource_id_t resource_id = TEST_RESOURCE_ID;
27 frsh_stream_id_t port = TEST_STREAM_ID;
28 long int num_msg = TEST_NUM_MSG;
29 size_t msg_size = MSGBUFFSIZE;
30 int time_period = 1000;
33 bool opt_daemon = false;
34 char *opt_pidfile = NULL;
37 frsh_send_endpoint_t sepoint;
39 frsh_send_endpoint_protocol_info_t send_pinfo;
40 frsh_contract_t contract;
41 frsh_rel_time_t budget, period;
45 while ((opt = getopt (argc, argv, "e:d:p:s:m:t:")) != -1) {
53 dst_ip = inet_addr(optarg);
59 num_msg = atoi(optarg);
62 msg_size = atoi(optarg);
65 time_period = atoi(optarg);
67 printf("Usage: %s -e -d dst_ip_addr -p port"
68 "-m num_msg -s msg_size\n",
74 forb_daemon_prepare(opt_pidfile);
78 send_pinfo.body = NULL;
80 //TODO: What's the return value?
81 if (frsh_send_endpoint_create(resource_id, dst_ip, port,
82 send_pinfo, &sepoint)< 0) {
86 /* Contract negotiation */
87 WVFRSH(frsh_contract_init(&contract));
89 WVFRSH(frsh_network_bytes_to_budget(resource_id, msg_size, &budget));
90 period = fosa_msec_to_rel_time(time_period);
91 WVFRSH(frsh_contract_set_basic_params(&contract,
96 WVFRSH(frsh_contract_set_resource_and_label(&contract,FRSH_RT_NETWORK,
97 resource_id, "net_cont1"));
98 WVFRSH(frsh_contract_negotiate(&contract, &vres));
100 printf("Send endpoint created\n");
101 WVFRSH(frsh_send_endpoint_bind(vres, sepoint));
102 printf("Send endpoint bounded\n");
105 while (count != num_msg) {
106 // TODO: Synchronize with receiver
109 sprintf(msg,"msg%d",count);
110 WVPASSEQ(frsh_send_async(sepoint, msg, msg_size), msg_size);
111 printf("%s sent\n",msg);
114 /* TODO: destroy vres and send enpoint */
116 printf("Test PASSED!\n");