+++ /dev/null
-# Generic directory or leaf node makefile for OCERA make framework
-
-ifndef MAKERULES_DIR
-MAKERULES_DIR := $(shell ( old_pwd="" ; while [ ! -e Makefile.rules ] ; do if [ "$$old_pwd" = `pwd` ] ; then exit 1 ; else old_pwd=`pwd` ; cd -L .. 2>/dev/null ; fi ; done ; pwd ) )
-endif
-
-ifeq ($(MAKERULES_DIR),)
-all : default
-.DEFAULT::
- @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
-else
-include $(MAKERULES_DIR)/Makefile.rules
-endif
-
+++ /dev/null
-bin_PROGRAMS = fwpmngr
-CFLAGS += -Wall -D_REENTRANT -g -D_FWP_INTERNALS_
-#fwpagent_SOURCES+= fwp_agent.c
-#fwpmngr_SOURCES+= fwp_participant.c fwp_mngr.c fwp_contract_table.c\
- fwp_agent_table.c fwp_admctrl.c
-fwpmngr_SOURCES+= fwp_mngr.c
-fwpmngr_SOURCES+= fwp_admctrl.c
-fwpmngr_SOURCES+= admtest_utilization.c
-#fwpmngr_SOURCES+= gui.c
-
-lib_LOADLIBES+= fwp ulut pthread rt
-#lib_LOADLIBES+= fwp ulut pthread rt ncurses
-
+++ /dev/null
-#include "fwp_admctrl.h"
-#include <fwp_utils.h>
-#include <stdint.h>
-#include <fwp_conf.h>
-#include <stdbool.h>
-#include <fwp_participant.h>
-#include "fwp_participant_table.h"
-#include "fwp_foreach.h"
-
-/* TODO: Find out the real value and determine what influences it (MTU
- * of the interface minus header sizes?). */
-#define MTU 1472
-#define UDP_HEADER_SIZE 8
-#define IP_HEADER_SIZE 20
-#define LLC_HEADER_SIZE 2 /* ??? */
-#define MAC_HEADER_SIZE 26 /* With QoS field added */
-#define MAC_FCS_SIZE 4
-
-#define RTS_FRAME_SIZE 20
-#define CTS_FRAME_SIZE 14
-#define ACK_FRAME_SIZE 14
-
-#define BITRATE_BPS (1000*1000)
-#define ASLOTTIME_USEC 20 /* 802.11g-2003 p. 46 */
-#define ASIFSTIME_USEC 10
-#define ADIFSTIME_USEC (ASIFSTIME_USEC + 2*ASLOTTIME_USEC)
-#define AAIFSTIME_USEC(n) (ASIFSTIME_USEC + (n)*ASLOTTIME_USEC)
-
-#define TXTIME_USEC(bytes) ((int64_t)(bytes) * 8 * SEC_TO_USEC / BITRATE_BPS)
-
-
-/* Default values from 802.11e */
-const int aifsn[FWP_AC_NUM] = { 2, 2, 3, 7 };
-const int cwmin[FWP_AC_NUM] = { 3, 7, 15, 15 };
-
-/* Experimental konstants - weight of backoff */
-const int pisvejc[FWP_AC_NUM] = { 6, 5, 2, 2 };
-
-int fwp_reserved_utilization;
-
-/**
- * Calucaltes frame duration in microseconds. If the real duration is
- * represented by a fractional number, the value is rounded up.
- *
- * @param length Number of bytes in PSDU.
- * @param rate_bps Transmit rate of PSDU. The rate should correspond
- * to other parameters accoring to 19.3.2 (802.11g)
- * @param erp_ofdm Whether Extended Rate PHY (part of 802.11g) and ERP-OFDM
- * modulation is used.
- * @param short_preamble Whether short preamble (HR/DSSS/short) is
- * used (802.11b)
- *
- * @return The number of microseconds or a negative number in case of error.
- */
-static int frame_duration(uint16_t length, int rate_bps, bool erp_ofdm, bool short_preamble)
-{
- uint32_t duration_usec;
-
- if (!erp_ofdm) {
- duration_usec = ((int64_t)(length) * 8 * SEC_TO_USEC / rate_bps);
- if (short_preamble) {
- /* For HR/DSSS/short (2, 5.5 and 11 Mbit,
- * 802.11b-1999), also for DSSS-OFDM rates and
- * ERP-PBCC rates.
- * Preamble sent at 1 MBit, header at 2 Mbit */
- duration_usec += 72/*bits*/+48/*bits*//2;
- } else {
- /* For DSSS PHY (1 and 2 Mbit rates,
- * 802.11-1999) and for DSS-OFDM and ERP-PBCC
- * rates. Always sent at 1 MBit */
- duration_usec += 144/*bits*/+48/*bits*/;
- }
- } else {
-#define MBIT_TO_INDEX(rate_Mbps) ((rate_Mbps)/3 - 2)
- const int N_dbps[] = {
- [MBIT_TO_INDEX(6)] = 24,
- [MBIT_TO_INDEX(9)] = 36,
- [MBIT_TO_INDEX(12)] = 48,
- [MBIT_TO_INDEX(18)] = 72,
- [MBIT_TO_INDEX(24)] = 96,
- [MBIT_TO_INDEX(36)] = 144,
- [MBIT_TO_INDEX(48)] = 192,
- [MBIT_TO_INDEX(54)] = 216
- };
- int rate_idx = MBIT_TO_INDEX(rate_bps/1000/1000);
-#undef MBIT_TO_INDEX
- if (rate_idx < 0 ||
- rate_idx >= sizeof(N_dbps)/sizeof(*N_dbps) ||
- N_dbps[rate_idx] == 0)
- return -1;
-
- duration_usec += 16 + 4; /* Preamble, SIGNAL */
- int bits =
- 16 + /* SERVICE */
- length * 8 +
- 6; /* tail bits */
- int Nsym = (bits + N_dbps[rate_idx] - 1)/N_dbps[rate_idx];
-
- duration_usec += Nsym * 4;
-
- duration_usec += 6; /* signal extension */
- }
- return duration_usec;
-}
-
-void fwp_admctrl_utilization(fwp_contract_data_t *contdata_new)
-{
- int utilization = 0;
-
- const int rate = 1*1000*1000;
- const bool erp_ofdm = false;
- const bool short_preamble = false;
- fwp_contract_data_t *contdata;
-
- struct foreach_contract fec;
- fec.contdata_new = contdata_new;
-
- for (contdata=foreach_contract_begin(&fec);
- contdata;
- contdata=foreach_contract_next(&fec)) {
- int bytes, duration_usec, fragments;
- struct fwp_contract *contract = &contdata->contract;
- int ac = FWP_AC_VO; /* FIXME: assign to AC before this
- * loop based on deadlines */
- /* Calculate protocol overhead */
-
- bytes = contract->budget;
- fragments = (bytes + MTU - 1) / MTU;
-
- if (fragments == 0)
- continue;
-
- const int data_overhead = UDP_HEADER_SIZE + IP_HEADER_SIZE +
- LLC_HEADER_SIZE + MAC_FCS_SIZE;
-
- duration_usec = frame_duration(data_overhead + bytes%MTU, rate, erp_ofdm, short_preamble);
- duration_usec += frame_duration(data_overhead + MTU, rate, erp_ofdm, short_preamble)*(fragments-1);
-
- /* Add average backoff - assume there is no collision */
- duration_usec += (aifsn[ac] + cwmin[ac]/2)*ASLOTTIME_USEC*fragments*pisvejc[ac];
- /* We use ACK and ignore burst */
- duration_usec += fragments * (ASIFSTIME_USEC +
- frame_duration(ACK_FRAME_SIZE, rate, erp_ofdm, short_preamble));
-
- /* TODO: If STA-to-STA, multiply it by two. Note that
- * AP may use different values for backoff. */
- duration_usec *= 2; /* For demo, we have always STA-to-STA */
- if (contract->period_usec == 0) {
- if (contdata == contdata_new) {
- contdata->status = FWP_CONT_NOTNEGOTIATED;
- return;
- }
- }
- utilization += (long long)(duration_usec * 10000) / contract->period_usec;
- }
-
- if (contdata_new) {
- if (utilization >= 10000 * 96/100) {
- contdata_new->status = FWP_CONT_NOTNEGOTIATED;
- } else {
- struct fwp_contract *c = &contdata_new->contract;
- int d = c->deadline_usec;
- if (d <= 0) d = 100*1000*1000;
- if (d < 50000) {
- contdata_new->status = FWP_CONT_NOTNEGOTIATED;
- } else {
- contdata_new->status = FWP_CONT_RESERVED;
- }
-
- contdata_new->vres_params.ac_id =
- d < 100*1000 ? FWP_AC_VO :
- d < 500*1000 ? FWP_AC_VI :
- d < 1000*1000 ? FWP_AC_BE :
- FWP_AC_BK;
- contdata_new->vres_params.budget = c->budget;
- contdata_new->vres_params.period_usec = c->period_usec;
- }
- }
-
- /* Update utilization for GUI */
- if (contdata_new == NULL || contdata_new->status == FWP_CONT_RESERVED) {
- fwp_reserved_utilization = utilization;
- }
-}
+++ /dev/null
-#include "fwp_admctrl.h"
-#include "fwp_vres.h"
-
-static int nr_negotiated =0;
-/***/
-
-void fwp_admctrl_stupid(fwp_contract_data_t *contdata)
-{
- contdata->vres_params.ac_id = FWP_AC_VI;
- contdata->vres_params.budget = 100;
- contdata->vres_params.period_usec = 20;
-
- if (nr_negotiated <= 4) {
- nr_negotiated++;
- contdata->status = FWP_CONT_RESERVED;
- }
-}
+++ /dev/null
-#ifndef _FWP_ADMCTRL_H
-#define _FWP_ADMCTRL_H
-
-#include "fwp_contract_table.h"
-
-typedef void (*fwp_admctrl_test_t)(fwp_contract_data_t *contdata);
-
-void fwp_admctrl_stupid(fwp_contract_data_t *contdata);
-void fwp_admctrl_utilization(fwp_contract_data_t *contdata);
-
-extern int fwp_reserved_utilization;
-
-#endif /*_FWP_AMDCTRL_H */
+++ /dev/null
-#ifndef FWP_FOREACH_H
-#define FWP_FOREACH_H
-
-#include <fwp_participant.h>
-#include "fwp_participant_table.h"
-
-struct foreach_contract {
- fwp_participant_t *participant; /**< Current participant */
- fwp_contract_data_t *contdata; /**< Current contract */
- fwp_contract_data_t *contdata_new; /**< The contract being negotiated */
-};
-
-static inline fwp_contract_data_t *foreach_contract_begin(struct foreach_contract *fec)
-{
- fec->contdata = NULL;
- fec->participant = fwp_participant_table_foreach_begin();
- while (1) {
- if (fec->participant) {
- fec->contdata= fwp_contract_table_foreach_begin
- (&fec->participant->contract_table);
- } else {
- break;
- }
- if (fec->contdata == NULL) {
- fwp_contract_table_foreach_end(&fec->participant->contract_table);
- fec->participant = fwp_participant_table_foreach_next(fec->participant);
- continue;
- }
- break;
- };
-
- if (fec->contdata == NULL) {
- fwp_participant_table_foreach_end();
- fec->contdata = fec->contdata_new;
- }
- return fec->contdata;
-}
-
-static inline fwp_contract_data_t *foreach_contract_next(struct foreach_contract *fec)
-{
- if (fec->contdata == fec->contdata_new) {
- /* This was the last contract */
- return NULL;
- }
- fec->contdata=fwp_contract_table_foreach_next(&fec->participant->contract_table,
- fec->contdata);
- while (1) {
- if (fec->contdata == NULL) {
- fwp_contract_table_foreach_end(&fec->participant->contract_table);
- fec->participant = fwp_participant_table_foreach_next(fec->participant);
- if (fec->participant == NULL) {
- break;
- }
- fec->contdata= fwp_contract_table_foreach_begin(
- &fec->participant->contract_table);
- continue;
- }
- break;
- };
-
- if (fec->contdata == NULL) {
- fwp_participant_table_foreach_end();
- fec->contdata = fec->contdata_new;
- }
- return fec->contdata;
-}
-
-#endif
+++ /dev/null
-#define CONFIGURE_FWP_MY_STREAM_ID 3000
-#define CONFIGURE_FWP_MNGR_ADDR "127.0.0.1"
-
-#include <error.h>
-#include <errno.h>
-#include "fwp_confdefs.h"
-#include "fwp.h"
-
-#include "fwp_contract_table.h"
-#include "fwp_participant_table.h"
-#include "fwp_admctrl.h"
-#include "fwp_mngt.h"
-#include "gui.h"
-
-#define FWP_MTU 2346
-#define BUFFSIZE FWP_MTU
-
-/* Admission control test */
-fwp_admctrl_test_t fwp_admctrl_test = &fwp_admctrl_utilization;
-
-/**
- * fwp_mngt_input
- *
- * Function waits for remote or local message
- *
- * @msgb received message
- * \return
- * On success, it returns 0 and the pointer to received message in msgb parameter.
- * On error, it returns negative error code
- *
- */
-int fwp_mngr_input(struct fwp_msgb **pmsgb)
-{
- /* buffer and socket for incomming message */
- static unsigned char buffer[FWP_MTU];
- struct fwp_msgb *msgb;
- ssize_t size, expected;
- struct fwp_msg_header *header = (void*)buffer;
-
- FWP_DEBUG("Waiting for messages\n");
- /* TODO: consider to replace with fwp_mngt_recv call */
- size = fwp_recv(fwp_participant_this->epointd, buffer, sizeof(*header), 0);
- if (size < 0) {
- return size;
- }
- if (size < sizeof(*header)) {
- return -EPROTO;
- /* TODO: Use errno for error reporting */
- }
- expected = ntohs(header->length)-sizeof(*header);
- size = fwp_recv(fwp_participant_this->epointd, buffer+size,
- expected, 0);
- if (size < expected) {
- return -EPROTO;
- }
-
- /* For future: fwp_socket could be allocated behind data in msgb*/
- if (!(msgb = fwp_msgb_alloc(ntohs(header->length)))) {
- perror("No memory available.\n");
- return -ENOMEM;
- }
- /*memcpy(fwp_msgb_put(msgb, len), buffer, len); */
- msgb->data = buffer;
- fwp_msgb_put(msgb, ntohs(header->length));
-
- *pmsgb = msgb;
- return (0);
-}
-
-/**
- * Processes hello message.
- *
- * @param msgb
- * @param participant_id
- *
- * @return Zero on success, -1 on error.
- */
-int fwp_mngr_hello(fwp_msgb_t *msgb, fwp_participant_id_t participant_id)
-{
- fwp_participant_info_t participant_info, my_info;
- fwp_participant_t *participant;
- fwp_endpoint_attr_t attr;
- int ret;
-
- FWP_DEBUG("Received HELLO msg from nodeid= %d appid= %d\n",
- participant_id.node_id, participant_id.app_id);
-
- fwp_endpoint_attr_init(&attr);
- fwp_endpoint_attr_setreliability(&attr, FWP_MNGT_RELIABILITY);
- /* Create a new participant */
- fwp_msg_hello_out(msgb->data, &participant_info);
- participant = fwp_participant_new(&participant_info);
- if (!participant)
- return -1;
- ret = fwp_mngt_service_vres_create(&participant->service_contract,
- &participant->vresd);
- if (ret < 0)
- goto err_vres;
- ret = fwp_send_endpoint_create(participant->id.node_id, participant->stream_id,
- &attr, &participant->epointd);
- if (ret < 0)
- goto err_endpoint;
- ret = fwp_send_endpoint_bind(participant->epointd, participant->vresd);
- if (ret < 0)
- goto err_bind;
- fwp_contract_table_init(&participant->contract_table);
-
- /* Insert participant into table */
- fwp_participant_table_insert(participant);
-
- /* Send back hello msg with mngr`s info */
- /* prepare hello message */
- fwp_msgb_reset_data(msgb);
- fwp_msgb_reserve(msgb, sizeof(struct fwp_msg_header));
-
- my_info.id = fwp_participant_this->id;
- my_info.stream_id = fwp_participant_this->stream_id;
-
- fwp_msg_hello_in(msgb->tail, &my_info);
- fwp_msgb_put(msgb, sizeof(struct fwp_msg_hello));
-
- /* Send hello to manager */
- ret = fwp_mngt_send(FWP_MSG_HELLO, msgb,
- fwp_participant_this, participant);
- if (ret < 0)
- goto err_send;
-
- FWP_DEBUG("Sent HELLO msg from nodeid= %d appid= %d\n",
- participant_id.node_id, participant_id.app_id);
- return 0;
-err_send:
- fwp_send_endpoint_unbind(participant->epointd);
-err_bind:
- fwp_endpoint_destroy(participant->epointd);
-err_endpoint:
- /* FIXME: This function is probably not the opposite of
- * fwp_mngt_service_vres_create(), beacuse it doesn't delete
- * the service contract. */
- /*fwp_vres_destroy(participant->vresd);*/
- fwp_contract_destroy(participant->service_contract);
-err_vres:
- fwp_participant_delete(participant);
- return -1;
-}
-
-int fwp_mngr_bye(fwp_msgb_t *msgb, fwp_participant_id_t participant_id)
-{
- fwp_participant_t *participant;
- fwp_contract_data_t* contdata;
-
- /* Find participant */
- if (!(participant = fwp_participant_table_find(&participant_id))){
- return -EPERM;
- }
-
- /* TODO: Check for errors */
- fwp_participant_table_delete(participant);
- fwp_send_endpoint_unbind(participant->epointd);
- fwp_endpoint_destroy(participant->epointd);
- fwp_contract_destroy(participant->service_contract);
- //fwp_vres_destroy(participant->vresd);
-
- /* Delete all participant's contracts */
- for (contdata = fwp_contract_table_foreach_begin(&participant->contract_table);
- contdata;
- contdata = fwp_contract_table_foreach_next(&participant->contract_table, contdata)) {
- fwp_contract_destroy(contdata);
- }
- fwp_contract_table_foreach_end(&participant->contract_table);
-
- fwp_participant_delete(participant);
-
- FWP_DEBUG("BYE nodeid = %d appid = %d\n", participant_id.node_id,
- participant_id.app_id);
-
- return 0;
-}
-
-int
-fwp_mngr_contract_reserve(fwp_msgb_t *msgb, fwp_participant_id_t participant_id)
-{
- fwp_participant_t *participant;
- fwp_contract_data_t *contdata;
-
- /* Find participant */
- if (!(participant = fwp_participant_table_find(&participant_id))){
- return -EPERM;
- }
-
- contdata = fwp_contract_data_new();
-
- /* Extract contract header */
- fwp_msg_contracthdr_out(msgb->data, &contdata->id, &contdata->status);
- fwp_msgb_pull(msgb, sizeof(struct fwp_msg_contracthdr));
- /* Extract contract params */
- fwp_msg_contract_out(msgb->data, &contdata->contract);
- fwp_msgb_pull(msgb, sizeof(struct fwp_msg_contract));
-
- /*launch admission test */
- fwp_admctrl_test(contdata);
-
- free(msgb);
- msgb = fwp_msgb_alloc(sizeof(struct fwp_msg_header) +
- sizeof(struct fwp_msg_contract) +
- sizeof(struct fwp_msg_vres_params));
- fwp_msgb_reserve(msgb,sizeof(struct fwp_msg_header));
-
- /*Add contract header*/
- fwp_msg_contracthdr_in(msgb->tail, contdata->id, contdata->status);
- fwp_msgb_put(msgb, sizeof(struct fwp_msg_contracthdr));
- /* Add contract params */
- /* No needed to send back if spare capacity is not considered
- * fwp_msg_contract_in(msgb->tail, &contdata->contract);
- * fwp_msgb_put(msgb, sizeof(struct fwp_msg_contract));
- * */
-
- /*Send back contract reservation */
- if (contdata->status == FWP_CONT_RESERVED) {
- fwp_msg_vres_params_in(msgb->tail, &contdata->vres_params);
- FWP_DEBUG("Sent vres params budget=%d period=%d ac=%d\n",
- contdata->vres_params.budget,
- contdata->vres_params.period_usec,
- contdata->vres_params.ac_id);
- fwp_msgb_put(msgb, sizeof(struct fwp_msg_vres_params));
- /* Add contract to contract table */
- fwp_contract_table_insert(&participant->contract_table,contdata);
- FWP_DEBUG("Contract id=%d stored in table\n", contdata->id);
-
- } else {
- free(contdata);
- }
-
- fwp_mngt_send(FWP_MSG_RESERVE, msgb,
- fwp_participant_this, participant);
- return 0;
-}
-
-int
-fwp_mngr_contract_commit(fwp_msgb_t *msgb, fwp_participant_id_t participant_id)
-{
- fwp_participant_t *participant;
- fwp_contract_data_t *contdata;
- fwp_contract_id_t id;
- fwp_contract_status_t status;
-
- /* Find participant */
- if (!(participant = fwp_participant_table_find(&participant_id))){
- return -EPERM;
- }
-
- fwp_msg_contracthdr_out(msgb->data, &id, &status);
- fwp_msgb_pull(msgb, sizeof(struct fwp_msg_contracthdr));
- FWP_DEBUG("Contract id=%d to commit\n", id);
-
- contdata = fwp_contract_table_find(&participant->contract_table, id);
- contdata->status = FWP_CONT_NEGOTIATED;
-
- /* TODO: Send response to confirm reception */
-
- return 0;
-}
-
-int
-fwp_mngr_contract_cancel(fwp_msgb_t *msgb, fwp_participant_id_t participant_id)
-{
- fwp_participant_t *participant;
- fwp_contract_data_t *contdata;
- fwp_contract_id_t id;
- fwp_contract_status_t status;
-
- /* Find participant */
- if (!(participant = fwp_participant_table_find(&participant_id))){
- return -EPERM;
- }
-
- fwp_msg_contracthdr_out(msgb->data, &id, &status);
- fwp_msgb_pull(msgb, sizeof(struct fwp_msg_contracthdr));
-
- contdata = fwp_contract_table_find(&participant->contract_table, id);
- contdata->status = FWP_CONT_NOTNEGOTIATED;
- /* release vres - success only for local vres */
- fwp_vres_destroy(contdata->vresd);
- /* delete contract from contract table */
- fwp_contract_table_delete(&participant->contract_table, contdata);
- fwp_contract_destroy(contdata);
-
- /* Update admission data (only necessary for demo and GUI) */
- fwp_admctrl_test(NULL);
-
- FWP_DEBUG("Contract id=%d to canceled\n", id);
-
- return 0;
-}
-
-void fwp_mngr_msg_handler(fwp_msgb_t *msgb)
-{
- fwp_msg_type_t msg_type;
- fwp_participant_id_t participant_id;
- int ret = 0;
-
- fwp_msg_header_out(msgb->data, &msg_type, &participant_id);
- fwp_msgb_pull(msgb, sizeof(struct fwp_msg_header));
-
- switch (msg_type) {
- case FWP_MSG_HELLO:
- FWP_DEBUG("Message HELLO received from nodeid = %d "
- "appid = %d\n", participant_id.node_id,
- participant_id.app_id);
- ret = fwp_mngr_hello(msgb, participant_id);
- if (ret < 0) {
- ret = fwp_mngr_bye(msgb, participant_id);
- if (ret < 0) {
- error(0, errno, "Cannot send bye");
- }
- }
- break;
-
- case FWP_MSG_BYE:
- FWP_DEBUG("Message BYE received from nodeid = %d "
- "appid = %d\n", participant_id.node_id,
- participant_id.app_id);
- fwp_mngr_bye(msgb, participant_id);
- break;
-
-
- case FWP_MSG_RESERVE:
- FWP_DEBUG("Message RESERVE received from nodeid = %d "
- "appid = %d\n", participant_id.node_id,
- participant_id.app_id);
- fwp_mngr_contract_reserve(msgb, participant_id);
- break;
-
- case FWP_MSG_COMMIT:
- FWP_DEBUG("Message COMMIT received from nodeid = %d "
- "appid = %d\n", participant_id.node_id,
- participant_id.app_id);
- fwp_mngr_contract_commit(msgb, participant_id);
- break;
-
- case FWP_MSG_CANCEL:
- FWP_DEBUG("Message CANCEL received from nodeid = %d "
- "appid = %d\n", participant_id.node_id,
- participant_id.app_id);
- fwp_mngr_contract_cancel(msgb, participant_id);
- break;
-
- default:
- printf("Invalid message\n.");
- fwp_msgb_free(msgb);
- }
-}
-
-void fwp_mngr_main_loop()
-{
- struct fwp_msgb *msgb;
- int rv;
-
- /* start admission control thread */
- while (1 /*exit_flag*/){
- //gui_print_status();
- rv = fwp_mngr_input(&msgb);
- if (rv == 0 && msgb)
- fwp_mngr_msg_handler(msgb);
- FWP_DEBUG("Mngr waiting for next msg.\n");
- }
-}
-
-int main()
-{
- if (fwp_init()) {
- fprintf(stderr,"FWP manager initialization failed.\n");
- exit(1);
- }
-
- //gui_init();
- fwp_mngr_main_loop();
- //gui_end();
-
- return 0;
-}
+++ /dev/null
-#include "fwp_participant_table.h"
-#include <pthread.h>
-
-typedef
-struct {
- unsigned int nr_participants;
- /*gavl_cust_root_field_t root;*/
- gavl_node_t *participant_tree;
- pthread_mutex_t lock;
-} fwp_participant_table_t;
-
-int fwp_cmp_participant_id(const void *a, const void *b)
-{
- if (((fwp_participant_id_t*)a)->node_id > ((fwp_participant_id_t*)b)->node_id)
- return 1;
- if (((fwp_participant_id_t*)a)->node_id < ((fwp_participant_id_t*)b)->node_id)
- return -1;
-
- if (((fwp_participant_id_t*)a)->app_id > ((fwp_participant_id_t*)b)->app_id)
- return 1;
- if (((fwp_participant_id_t*)a)->app_id < ((fwp_participant_id_t*)b)->app_id)
- return -1;
-
- return 0;
-}
-
-GAVL_CUST_NODE_INT_DEC(_fwp_participant_table, fwp_participant_table_t,
- fwp_participant_t, fwp_participant_id_t,
- participant_tree, participant_tree_node, id,
- fwp_cmp_participant_id);
-
-GAVL_CUST_NODE_INT_IMP(_fwp_participant_table, fwp_participant_table_t,
- fwp_participant_t, fwp_participant_id_t,
- participant_tree, participant_tree_node, id,
- fwp_cmp_participant_id);
-
-fwp_participant_table_t fwp_participant_table = {
- .nr_participants = 0,
- .participant_tree = NULL,
- .lock = PTHREAD_MUTEX_INITIALIZER,
-};
-
-int fwp_participant_table_nr_participants()
-{
- return fwp_participant_table.nr_participants;
-}
-
-void fwp_participant_table_insert(fwp_participant_t *participant)
-{
- pthread_mutex_lock(&fwp_participant_table.lock);
- _fwp_participant_table_insert(&fwp_participant_table, participant);
- fwp_participant_table.nr_participants++;
- pthread_mutex_unlock(&fwp_participant_table.lock);
-}
-
-fwp_participant_t*
-fwp_participant_table_find(fwp_participant_id_t *participant_id)
-{
- return _fwp_participant_table_find(&fwp_participant_table,
- participant_id);
-}
-
-int fwp_participant_table_delete(fwp_participant_t *participant)
-{
- int rv;
-
- pthread_mutex_lock(&fwp_participant_table.lock);
- rv = _fwp_participant_table_delete(&fwp_participant_table, participant);
- fwp_participant_table.nr_participants--;
- pthread_mutex_unlock(&fwp_participant_table.lock);
-
- return rv;
-}
-
-fwp_participant_t* fwp_participant_table_foreach_begin(void)
-{
- pthread_mutex_lock(&fwp_participant_table.lock);
- return _fwp_participant_table_first(&fwp_participant_table);
-}
-
-void fwp_participant_table_foreach_end(void)
-{
- pthread_mutex_unlock(&fwp_participant_table.lock);
-}
-
-fwp_participant_t* fwp_participant_table_foreach_next(fwp_participant_t *current)
-{
- return _fwp_participant_table_next(&fwp_participant_table, current);
-}
-
+++ /dev/null
-#ifndef _FWP_PARTICIPANT_TABLE_H
-#define _FWP_PARTICIPANT_TABLE_H
-
-#include "fwp_participant.h"
-
-void fwp_participant_table_insert(fwp_participant_t *participant);
-fwp_participant_t* fwp_participant_table_find(fwp_participant_id_t *participant_id);
-int fwp_participant_table_delete(fwp_participant_t *participant);
-
-fwp_participant_t* fwp_participant_table_foreach_begin(void);
-fwp_participant_t* fwp_participant_table_foreach_next(fwp_participant_t *current);
-void fwp_participant_table_foreach_end(void);
-
-int fwp_participant_table_nr_participants();
-
-#endif /*_FWP_PARTICIPANT_TABLE_H */
+++ /dev/null
-#include "gui.h"
-#include "fwp_foreach.h"
-#include <ncurses.h>
-#include <fwp_contract.h>
-#include "fwp_admctrl.h"
-
-void gui_init(void)
-{
- initscr();
- cbreak();
- noecho();
-}
-
-static char *num_with_unit(char *buf, unsigned num, const char *units[])
-{
- const int div[] = {100,10,1};
- unsigned order = 0;
- int d;
-
- while (num > 999 && units[(order+3)/3] != NULL) {
- num /= 10;
- order++;
- }
-
- d = div[(order+2)%3];
- if (d == 1)
- sprintf(buf, "%4d %s", num, units[(order+2)/3]);
- else
- sprintf(buf, "%d.%.*d %s", num/d, (d==10) ? 1 : 2, num%d, units[(order+2)/3]);
- return buf;
-}
-
-char *bandwidth_to_text(char *buf, unsigned bandwidth_bps)
-{
- const char *unit[] = {"bps", "kbps", "Mbps", NULL};
- return num_with_unit(buf, bandwidth_bps, unit);
-}
-
-char *usec_to_text(char *buf, unsigned usec)
-{
- const char *unit[] = {"us", "ms", "s", NULL};
- return num_with_unit(buf, usec, unit);
-}
-
-#define addfield(width, title, format, ...) \
- move(y, x); \
- x+=width; \
- if (cd == NULL) addstr(title); \
- else { \
- snprintf(str, sizeof(str), format, __VA_ARGS__); \
- addstr(str); \
- }
-
-static void print_contract(int y, fwp_contract_data_t *cd)
-{
- const char *ac_ids[] = { [FWP_AC_VO]="VO", [FWP_AC_VI]="VI", [FWP_AC_BE]="BE", [FWP_AC_BK]="BK" };
- struct fwp_contract *c = &cd->contract;
- char str[200], s1[20];
- int x = 0;
-
- addfield(4, "ID", "%d", cd->id);
- addfield(11, "BW", "%s", bandwidth_to_text(s1, (long long)1000*1000*8*c->budget/c->period_usec));
- addfield(11, "Budget", "%d bytes", c->budget);
- addfield(11, "Period", "%s", usec_to_text(s1, c->period_usec));
- addfield(11, "Deadline", "%s", usec_to_text(s1, c->deadline_usec));
- addfield(3, "AC", "%s", ac_ids[cd->vres_params.ac_id]);
- addfield(11, "Num partics", "%d", fwp_participant_table_nr_participants());
-}
-
-void gui_print_status()
-{
- fwp_contract_data_t *cd;
- struct foreach_contract fec;
- int y;
- char str[200];
-
- clear(); /* Repaint the screen completely to
- * delete error messages */
- mvaddstr(0, 0, "FWP Manager");
- sprintf(str, "Reserved utilization: %d%%", fwp_reserved_utilization/100);
- mvaddstr(2, 0, str);
-
- /* Print header */
- y=4;
- print_contract(y, NULL);
- y++;
-
- /* Print contracts */
- fec.contdata_new = NULL;
- for (cd=foreach_contract_begin(&fec);
- cd;
- cd=foreach_contract_next(&fec)) {
- print_contract(y, cd);
- y++;
- }
- refresh();
-}
-
-void gui_end(void)
-{
- endwin();
-}
+++ /dev/null
-#ifndef GUI_H
-#define GUI_H
-
-/* FIXME: Conditionally define these functions as empty macros (to
- * disable GUI). */
-
-void gui_init(void);
-void gui_print_status(void);
-void gui_end(void);
-
-#endif
+++ /dev/null
-12 17.5 17.5
-20 28.1 28.1
-30 40.2 40.2
-40 50.4 50.4
-50 60.0 60.0
-60 69.1 69.1
-70 77.2 77.2
-80 83.1 83.1
-90 89.8 89.8
-100 94.8 94.8
-110 102 102
-120 107 107
-130 111 111
-140 116 116
-150 119 119
-160 125 125
-170 126 126
-180 131 131
-190 132 132
-200 136 136
-250 151 151
-300 161 161
-350 168 168
-400 174 174
-450 179 179
-500 186 186
-550 187 187
-600 192 192
-650 194 194
-700 199 199
-750 200 200
-800 203 203
-850 204 204
-900 204 204
-950 205 205
-1000 208 208
-1050 207 207
-1100 210 210
-1150 210 210
-1200 212 212
-1250 214 214
-1300 212 212
-1350 217 217
-1400 215 215
-1450 217 217
-1460 212 212
-1470 217 217
-1480 199 199
-1490 200 200
-1500 199 199
-1510 199 199
-1520 198 198
-1550 200 200
-1600 201 201
-1650 204 204
-1700 205 205
-1750 207 207
-1800 207 207
-1850 206 206
-1900 209 209
-1950 211 211
-2000 210 210
+++ /dev/null
-# Generic directory or leaf node makefile for OCERA make framework
-
-ifndef MAKERULES_DIR
-MAKERULES_DIR := $(shell ( old_pwd="" ; while [ ! -e Makefile.rules ] ; do if [ "$$old_pwd" = `pwd` ] ; then exit 1 ; else old_pwd=`pwd` ; cd -L .. 2>/dev/null ; fi ; done ; pwd ) )
-endif
-
-ifeq ($(MAKERULES_DIR),)
-all : default
-.DEFAULT::
- @echo -e "\nThe Makefile.rules has not been found in this or partent directory\n"
-else
-include $(MAKERULES_DIR)/Makefile.rules
-endif
-
+++ /dev/null
-test_PROGRAMS = adm_utilization
-
-adm_utilization_SOURCES = adm_utilization.c ../admtest_utilization.c
-adm_utilization_LIBS = fwp
-
-CFLAGS=-Wall -O0 -g
+++ /dev/null
-12 64.6 0.511
-20 45.6 2.04
-30 64.1 2.56
-40 80.5 1.66
-50 94.8 3.45
-60 98.0 28.1
-70 98.4 53.1
-80 98.9 73.9
-90 98.4 89.1
-100 98.9 102
-110 98.9 108
-120 98.8 119
-130 98.7 128
-140 98.9 130
-150 99.7 137
-160 99.4 141
-170 100 145
-180 98.1 153
-190 101 151
-200 99.6 152
-250 99.5 165
-300 100 176
-350 98.7 180
-400 99.8 187
-450 100 189
-500 100 191
-550 98.9 194
-600 100 193
-650 100 198
-700 99.8 199
-750 100 199
-800 99.9 200
-850 98.6 205
-900 99.1 207
-950 99.3 204
-1000 99.8 203
-1050 102 198
-1100 100 204
-1150 98.6 207
-1200 102 204
-1250 99.4 206
-1300 97.8 208
-1350 99.0 207
-1400 97.4 209
-1450 99.7 208
-1460 98.7 210
-1470 100 208
-1480 99.5 198
-1490 100 197
-1500 101 198
-1510 100 201
-1520 100 198
-1550 99.7 198
-1600 103 195
-1650 98.4 203
-1700 99.2 200
-1750 101 201
-1800 101 200
-1850 100 203
-1900 101 199
-1950 99.5 201
-2000 99.8 208
+++ /dev/null
-12 70.5 0.64
-20 63.1 2.81
-30 87.3 2.56
-40 98.2 0.896
-50 98.3 2.56
-60 98.5 27.9
-70 98.3 53.0
-80 99.4 71.0
-90 98.6 87.6
-100 99.6 97.1
-110 98.8 110
-120 99.2 118
-130 99.0 125
-140 99.1 134
-150 99.3 135
-160 99.7 141
-170 99.1 144
-180 99.0 150
-190 100 154
-200 100 154
-250 99.4 164
-300 99.4 178
-350 99.1 183
-400 99.3 187
-450 99.5 190
-500 100 193
-550 99.2 193
-600 99.5 194
-650 99.2 195
-700 100 198
-750 100 197
-800 99.8 199
-850 99.3 201
-900 100 204
-950 100 202
-1000 99.8 204
-1050 100 204
-1100 100 205
-1150 99.0 206
-1200 100 207
-1250 99.3 207
-1300 97.9 208
-1350 100 206
-1400 96.3 211
-1450 99.6 205
-1460 98.3 206
-1470 97.4 212
-1480 98.8 199
-1490 99.9 195
-1500 101 197
-1510 100 197
-1520 96.7 203
-1550 100 198
-1600 100 200
-1650 99.3 200
-1700 101 200
-1750 97.8 202
-1800 99.0 203
-1850 96.8 205
-1900 98.4 205
-1950 102 203
-2000 99.5 203
+++ /dev/null
-/**
- * @file adm_utilization.c
- * @author Michal Sojka <sojkam1@fel.cvut.cz>
- *
- * @brief Test for utilization based admition control.
- *
- * This test tries to simulate results of the following test whose
- * results are available at:
- * http://rtime.felk.cvut.cz/frescor/images/b/bb/Packet_sizes_sat_comp.pdf
- * (http://rtime.felk.cvut.cz/frescor/index.php/Experiments#Experiments_2008.2F01)
- *
- * Brief description of the test: Measuring of saturation bandwidth of
- * AC_BE with respect to the size of packets in AC_VO, AC_VI and AC_BE
- * itself. In this test we have generated the following streams AC_VO:
- * 100 kbps, AC_VI: 100 kbps and AC_BE: 500 kbps (saturation). The
- * streams, where the packet size was not changed was formed by
- * packets of 800 bytes (UDP). The real bandwidth of AC_BE was
- * measured.
- */
-
-#include "../admtest.h"
-#include <fwp_ctable.h>
-#include <fwp_ac.h>
-#include <string.h>
-#include <fwp_utils.h>
-
-void insert_contract(struct fwp_ctable *ctable, enum ac_id_t ac, int bandwidth_bps, int packet_size)
-{
- struct fwp_ctable_entry entry;
- int period_usec;
-
- if (bandwidth_bps == 0) return;
-
- period_usec = SEC_TO_USEC*packet_size*8/bandwidth_bps;
-
- memset(&entry, 0, sizeof(entry));
- entry.contract.budget = packet_size;
- entry.contract.period_usec = period_usec;
- entry.contract.ac_id = ac;
-
- fwp_ctable_put(ctable, &entry);
-}
-
-int main()
-{
- int ac, size;
- struct fwp_ctable ctable;
-
- for (ac=FWP_AC_VO; ac <= FWP_AC_BE; ac++) {
- for (size=10; size < 2000; size+=10) {
- /* Find maximum BE badwidth by binary
- * chopping. */
- int min=0, max=500000, bw;
- int packet_size[] = {[FWP_AC_VO] = (ac == FWP_AC_VO) ? size : 800,
- [FWP_AC_VI] = (ac == FWP_AC_VI) ? size : 800,
- [FWP_AC_BE] = (ac == FWP_AC_BE) ? size : 800};
- enum contract_status_t cs;
- bw=(max+min+1)/2;
- while (min < max) {
- fwp_ctable_init(&ctable);
-
- /* Two equal contracts, one for each direction */
- insert_contract(&ctable, FWP_AC_VO, 100*Kbit, packet_size[FWP_AC_VO]);
- insert_contract(&ctable, FWP_AC_VO, 100*Kbit, packet_size[FWP_AC_VO]);
-
- insert_contract(&ctable, FWP_AC_VI, 100*Kbit, packet_size[FWP_AC_VI]);
- insert_contract(&ctable, FWP_AC_VI, 100*Kbit, packet_size[FWP_AC_VI]);
-
- insert_contract(&ctable, FWP_AC_BE, bw, packet_size[FWP_AC_BE]);
- insert_contract(&ctable, FWP_AC_BE, bw, packet_size[FWP_AC_BE]);
- cs = fwp_adm_test(&ctable);
- if (cs == FWP_CNT_REJECTED) {
- max = bw-1;
- } else {
- min = bw;
- }
- bw=(max+min+1)/2;
- }
- printf("%d %f\n", size, bw/1000.0);
- }
- printf("\n\n");
- }
- return 0;
-}
+++ /dev/null
-../../_compiled/bin-tests/adm_utilization > data && gnuplot plot_sat | ps2pdf - admutil_comp.pdf
+++ /dev/null
-# Usage: adm_utilization > data; gnuplot plot_sat|ps2pdf admutil_comp.pdf
-
-set terminal postscript color landscape
-#set output "admutil_comp.eps"
-
-set style line 1 lt 1 lc rgb "red"
-set style line 2 lt 1 lc rgb "green"
-set style line 3 lt 1 lc rgb "blue"
-
-set style data lines
-set grid
-set key right bottom nobox
-set title "Comparsion of utilization based test and reality"
-set xlabel "Packet sizes [bytes]"
-set ylabel "AC_BE bandwidth [kbps]"
-
-plot "data" index 0 with lines lt 1 lw 3 lc rgb "red" title "utilization test: AC_VO changed",\
- "data" index 1 with lines lt 1 lw 3 lc rgb "green" title "utilization test: AC_VI changed",\
- "data" index 2 with lines lt 1 lw 3 lc rgb "blue" title "utilization test: AC_BE changed",\
- "VO_packet_size_graph" using 1:3 with points lc rgb "red" title "reality: AC_VO changed",\
- "VI_packet_size_graph" using 1:3 with points lc rgb "green" title "reality: AC_VI changed",\
- "BE_packet_size_graph" using 1:3 with points lc rgb "blue" title "reality: AC_BE changed"