return -EINVAL;*/
_fwp_sendto(fwp_ac_table[id].sockfd, msgb->data, msgb->len, 0,
msgb->peer->addr, msgb->peer->addrlen);
-#if 0
- while (sendto(fwp_ac_table[id].sockfd, msgb->data, msgb->len,
- /*msgb_>flags*/0, (struct sockaddr*)msgb->peer->addr,
- msgb->peer->addrlen) < 0) {
-
- if (errno == EINTR) continue;
- perror("fwp_ac_send - Error while sending data");
- return (-errno);
- }
-#endif
return 0;
}
}
static void* fwp_vres_tx_thread(void *_vres)
-{/* TODO: Implement budgeting, make changes that count with changing of params */
+{/* TODO: make changes that count with changing of params */
struct fwp_vres *vres = (struct fwp_vres*)_vres;
struct fwp_msgq *msgq = &vres->tx_queue;
struct fwp_msgb *msgb;
- unsigned int ac_id = vres->params.ac_id;
- int rc;
+ unsigned int ac_id = vres->params.ac_id;
+ int budget = vres->params.budget;
+ int curr_budget;
+ int rc;
struct timespec start_period, end_period, period;
struct timespec current_time, interval;
period.tv_nsec = vres->params.period_usec % SEC_TO_USEC;
period.tv_sec = vres->params.period_usec / SEC_TO_USEC;
- FWP_DEBUG("Iterval: sec = %ld nsec = %ld \n", period.tv_sec,
- period.tv_nsec);
fwp_set_rt_prio(90 - ac_id);
sem_wait(&msgq->empty_lock);
clock_gettime(CLOCK_MONOTONIC, &start_period);
- msgb = fwp_msgq_dequeue(msgq);
-
- if (msgb) {
- /* TODO: rc handling */
+ curr_budget = 0;
+ while ((msgb = fwp_msgq_dequeue(msgq)) &&
+ (curr_budget < budget)) {
+
rc = fwp_ac_send(ac_id, msgb);
- FWP_DEBUG("Message sent through AC %d\n",ac_id);
+ if (!(rc < 0)) {
+ FWP_DEBUG("Message sent through AC%d\n",ac_id);
+ curr_budget+= msgb->len;
+ }
fwp_msgb_free(msgb);
}
fwp_timespec_add(&end_period, &start_period, &period);
clock_gettime(CLOCK_MONOTONIC, ¤t_time);
- FWP_DEBUG("sec = %ld nsec = %ld \n", current_time.tv_sec,
- current_time.tv_nsec);
fwp_timespec_sub(&interval, &end_period, ¤t_time);
nanosleep(&interval, NULL);
- FWP_DEBUG("Iterval: sec = %ld nsec = %ld \n", interval.tv_sec,
- interval.tv_nsec);
}
/* it should normaly never come here */
char buffer[30];
int sepoint_id1, repoint_id;
int count;
+ struct timespec sendtime;
vparam1.ac_id = FWP_AC_VO;
vparam1.budget = 100;
for (count = 0; count < NUM; count++) {
fwp_send(sepoint_id1, msg1, sizeof(msg1));
+
+ clock_gettime(CLOCK_MONOTONIC, &sendtime);
+ FWP_DEBUG("Sent: sec = %ld nsec = %ld \n", sendtime.tv_sec,
+ sendtime.tv_nsec);
+
printf("count= %d\n", count++);
if ((len = fwp_recv(repoint_id, buffer, sizeof(buffer))) < 0) {
perror("Error while receiving data");