]> rtime.felk.cvut.cz Git - frescor/fna.git/commitdiff
start to do the unix fna
authorsangorrin <sangorrin@35b4ef3e-fd22-0410-ab77-dab3279adceb>
Fri, 26 Oct 2007 10:23:29 +0000 (10:23 +0000)
committersangorrin <sangorrin@35b4ef3e-fd22-0410-ab77-dab3279adceb>
Fri, 26 Oct 2007 10:23:29 +0000 (10:23 +0000)
git-svn-id: http://www.frescor.org/private/svn/frescor/fna/trunk@818 35b4ef3e-fd22-0410-ab77-dab3279adceb

13 files changed:
config.mk_example
rules.mk
src/fna_configuration.c
src_unix/Makefile [new file with mode: 0755]
src_unix/unix_fna.c [new file with mode: 0644]
src_unix/unix_fna.h [new file with mode: 0644]
tests/qemu/Makefile [new file with mode: 0755]
tests/qemu/base_disk.img [new file with mode: 0755]
tests/qemu/mkvirtualdisk [new file with mode: 0755]
tests/tests_rtep_fna/Makefile [new file with mode: 0755]
tests/tests_rtep_fna/test_c_rtep_fna.c [new file with mode: 0644]
tests/tests_rtep_fna/test_c_rtep_fna_with_frsh.c [new file with mode: 0644]
tests/tests_rtep_fna/test_c_rtep_frsh_fna.c [new file with mode: 0644]

index 3feb6cdd15950cc53d7f5ab09f953c83cbc0c279..a5fee75fd5a19fec1601170129062c94a3a7df3b 100644 (file)
@@ -5,8 +5,9 @@ PLATFORM_PATH = $(HOME)/marte
 # the path for exporting programs linux_arch -> ./
 EXPORT_PATH = $(HOME)/export
 
-# enable networks with their flag or 'no'
-RTEP_ENABLE = no # RTEP
+# enable networks with their flag (change DISABLED<->ENABLED)
+RTEP_ENABLE = RTEP_FNA_ENABLED
+UNIX_ENABLE = UNIX_FNA_DISABLED
 
 # the gcc to use
 CC = mgcc
@@ -17,6 +18,6 @@ FOSA_PATH = $(HOME)/frescor/fosa
 # the path to the FNA directory.
 FNA_PATH = $(HOME)/frescor/fna
 # the compilation flags
-CFLAGS = -Wall -g -D$(PLATFORM) -D$(RTEP_ENABLE) -I$(FNA_PATH)/include -I$(FRSH_PATH)/include
+CFLAGS = -Wall -g -D$(PLATFORM) -D$(RTEP_ENABLE) -D$(UNIX_ENABLE) -I$(FNA_PATH)/include -I$(FRSH_PATH)/include
 # the library flags
 LDFLAGS = -L$(FNA_PATH)/lib -lfna
index 47b5abfc338509c215e29c3b87399ffed9b970f4..f7567a7bc063568d119d2867067a11dc6968fa69 100644 (file)
--- a/rules.mk
+++ b/rules.mk
@@ -7,16 +7,18 @@ none:
        @exec echo -e "\n>> Building $@: ";
        @if [ -f $< ]; \
        then \
-               $(CC) $(CFLAGS) $< $(LDFLAGS); \
-               mv $(EXPORT_PATH)/mprogram $@ &> /dev/null; \
+               $(CC) $(CFLAGS) $< $(LDFLAGS) &> /dev/null; \
        fi; # -o $@ (fix marte mgcc)
        @exec echo ">> End Building $@";
 
 libfna.a:
        @exec echo -e "\n>> Compiling FNA library (lib/libfna.a):";
        @make -C $(FNA_PATH)/src all
-ifeq ($(RTEP_ENABLE), RTEP)
+ifeq ($(RTEP_ENABLE),RTEP_FNA_ENABLED)
                @make -C $(FNA_PATH)/src_rtep librtepfna.a
+endif
+ifeq ($(UNIX_ENABLE),UNIX_FNA_ENABLED)
+               @make -C $(FNA_PATH)/src_unix libunixfna.a
 endif
        @ar -rc libfna.a $(FNA_PATH)/src/*.o
        @mv libfna.a $(FNA_PATH)/lib/
index cd5247c0dc441095182ac98f6187e1708d9e8548..8884178ab21e60778f5161056e0c939f023b5ff2 100644 (file)
 
 #include "fna_configuration.h"
 
-#ifdef RTEP
+#ifdef RTEP_FNA_ENABLED
         #include "../src_rtep/rtep_fna.h" // for rtep_fna_operations
 #endif
 
-fna_operations_t  *fna_operations[FNA_MAX_NETWORKS] = {
-#ifdef RTEP
-        &rtep_fna_operations, // resource_id 0 (default) --> RTEP
-#else
-        NULL,
+#ifdef UNIX_FNA_ENABLED
+        #include "../src_unix/unix_fna.h" // for unix_fna_operations
 #endif
+
+
+fna_operations_t  *fna_operations[FNA_MAX_NETWORKS] = {
+        &rtep_fna_operations,
+        // &unix_fna_operations,
+        // NULL, // resource_id 0
         NULL, // resource_id 1
         NULL, // resource_id 2
         NULL  // resource_id 3
diff --git a/src_unix/Makefile b/src_unix/Makefile
new file mode 100755 (executable)
index 0000000..84e259d
--- /dev/null
@@ -0,0 +1,20 @@
+.PHONY: all objs libunixfna.a
+
+all: libunixfna.a
+include ../config.mk
+include ../rules.mk
+
+SRCS := $(wildcard *.c)
+OBJS := $(patsubst %.c,%.o,$(wildcard *.c))
+HDRS := $(wildcard $(FNA_PATH)/include/*.h)
+
+objs: $(OBJS)
+
+%.o: %.c $(SRCS) $(HDRS)
+       $(CC) $(CFLAGS) -c $<
+
+libunixfna.a: objs
+       @exec echo -e "\n>> Building UNIX FNA:";
+       @ar -rc libunixfna.a *.o
+       @mv libunixfna.a $(FNA_PATH)/lib
+       @exec echo ">> end Building UNIX FNA  [OK]"
diff --git a/src_unix/unix_fna.c b/src_unix/unix_fna.c
new file mode 100644 (file)
index 0000000..779fe21
--- /dev/null
@@ -0,0 +1,414 @@
+//----------------------------------------------------------------------
+//  Copyright (C) 2006 - 2007 by the FRESCOR consortium:
+//
+//    Universidad de Cantabria,              SPAIN
+//    University of York,                    UK
+//    Scuola Superiore Sant'Anna,            ITALY
+//    Kaiserslautern University,             GERMANY
+//    Univ. Politecnica  Valencia,           SPAIN
+//    Czech Technical University in Prague,  CZECH REPUBLIC
+//    ENEA                                   SWEDEN
+//    Thales Communication S.A.              FRANCE
+//    Visual Tools S.A.                      SPAIN
+//    Rapita Systems Ltd                     UK
+//    Evidence                               ITALY
+//
+//    See http://www.frescor.org
+//
+//        The FRESCOR project (FP6/2005/IST/5-034026) is funded
+//        in part by the European Union Sixth Framework Programme
+//        The European Union is not liable of any use that may be
+//        made of this code.
+//
+//
+//  based on previous work (FSF) done in the FIRST project
+//
+//   Copyright (C) 2005  Mälardalen University, SWEDEN
+//                       Scuola Superiore S.Anna, ITALY
+//                       Universidad de Cantabria, SPAIN
+//                       University of York, UK
+//
+// This file is part of FNA (Frescor Network Adaptation)
+//
+// FNA is free software; you can redistribute it and/or modify it
+// under terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option) any
+// later version.  FNA is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details. You should have received a
+// copy of the GNU General Public License along with FNA; see file
+// COPYING. If not, write to the Free Software Foundation, 675 Mass Ave,
+// Cambridge, MA 02139, USA.
+//
+// As a special exception, including FNA header files in a file,
+// instantiating FNA generics or templates, or linking other files
+// with FNA objects to produce an executable application, does not
+// by itself cause the resulting executable application to be covered
+// by the GNU General Public License. This exception does not
+// however invalidate any other reasons why the executable file might be
+// covered by the GNU Public License.
+// -----------------------------------------------------------------------
+
+//==============================================
+//  ******** ****     **     **
+//  **///// /**/**   /**    ****
+//  **      /**//**  /**   **//**
+//  ******* /** //** /**  **  //**
+//  **////  /**  //**/** **********
+//  **      /**   //****/**//////**
+//  **      /**    //***/**     /**
+//  /       //      /// //      //
+//
+// FNA(Frescor Network Adaptation layer), pronounced "efe ene a"
+//==============================================================
+#include <malloc.h>   /* for malloc and free */
+#include "unix_fna.h" /* function prototypes */
+
+#if 0
+#include <stdio.h>
+#define DEBUG(x,args...) printf("%s: " x, __func__ , ##args)
+#else
+#define DEBUG(x,args...)
+#endif
+
+//////////////////////////////////////////////////////////////////////
+//           INITIALIZATION
+//////////////////////////////////////////////////////////////////////
+
+/**
+ * unix_fna_init()
+ *
+ **/
+
+int unix_fna_init(const frsh_resource_id_t resource_id)
+{
+    DEBUG("starting unix fna\n");
+    return 0;
+}
+
+///////////////////////////////////////////////////////////////////
+//           VIRTUAL RESOURCES
+///////////////////////////////////////////////////////////////////
+
+/**
+ * unix_fna_contract_negotiate()
+ *
+ **/
+
+int unix_fna_contract_negotiate(const frsh_resource_id_t resource_id,
+                                const frsh_contract_t *contract,
+                                fna_vres_id_t *vres)
+{
+    return 0;
+}
+
+/**
+ * unix_fna_contract_renegotiate_sync()
+ *
+ **/
+
+int unix_fna_contract_renegotiate_sync(const frsh_resource_id_t resource_id,
+                                       const fna_vres_id_t vres,
+                                       const frsh_contract_t *new_contract)
+{
+    return 0;
+}
+
+/**
+ * unix_fna_contract_renegotiate_async()
+ *
+ **/
+
+int unix_fna_contract_renegotiate_async(const frsh_resource_id_t resource_id,
+                                        const fna_vres_id_t vres,
+                                        const frsh_contract_t *new_contract,
+                                        frsh_signal_t signal_to_notify,
+                                        frsh_signal_info_t signal_info)
+{
+   return 0;
+}
+
+/**
+ * unix_fna_vres_get_renegotiation_status()
+ *
+ **/
+
+int unix_fna_vres_get_renegotiation_status(const frsh_resource_id_t resource_id,
+                                           const fna_vres_id_t vres,
+                                           frsh_renegotiation_status_t *renegotiation_status)
+{
+   return 0;
+}
+
+/**
+ * unix_fna_vres_destroy()
+ *
+ **/
+
+int unix_fna_vres_destroy(const frsh_resource_id_t resource_id,
+                          const fna_vres_id_t vres)
+{
+    return 0;
+}
+
+/**
+ * unix_fna_vres_get_contract()
+ *
+ **/
+
+int unix_fna_vres_get_contract(const frsh_resource_id_t resource_id,
+                               const fna_vres_id_t vres,
+                               frsh_contract_t *contract)
+{
+   return 0;
+}
+
+/**
+ * unix_fna_vres_get_usage()
+ *
+ **/
+
+int unix_fna_vres_get_usage(const frsh_resource_id_t resource_id,
+                            const fna_vres_id_t vres,
+                            struct timespec *usage)
+{
+   return 0;
+}
+
+/**
+ * unix_fna_vres_get_remaining_budget()
+ *
+ **/
+
+int unix_fna_vres_get_remaining_budget(const frsh_resource_id_t resource_id,
+                                       const fna_vres_id_t vres,
+                                       struct timespec *remaining_budget)
+{
+   return 0;
+}
+
+/**
+ * unix_fna_vres_get_budget_and_period()
+ *
+ **/
+
+int unix_fna_vres_get_budget_and_period(const frsh_resource_id_t resource_id,
+                                        const fna_vres_id_t vres,
+                                        struct timespec *budget,
+                                        struct timespec *period)
+{
+   return 0;
+}
+
+///////////////////////////////////////////////////////////////////
+//           SPARE CAPACITY FUNCIONS
+///////////////////////////////////////////////////////////////////
+
+/**
+ * unix_fna_resource_get_capacity()
+ *
+ **/
+
+int unix_fna_resource_get_capacity(const frsh_resource_id_t resource_id,
+                                   const int importance,
+                                   uint32_t *capacity)
+{
+   return 0;
+}
+
+/**
+ * unix_fna_resource_get_total_weight()
+ *
+ **/
+
+int unix_fna_resource_get_total_weight(const frsh_resource_id_t resource_id,
+                                       const int importance,
+                                       int *total_weight)
+{
+   return 0;
+}
+
+/**
+ * unix_fna_vres_decrease_capacity()
+ *
+ **/
+
+int unix_fna_vres_decrease_capacity(const frsh_resource_id_t resource_id,
+                                    const fna_vres_id_t vres,
+                                    const struct timespec new_budget,
+                                    const struct timespec new_period)
+{
+   return 0;
+}
+
+///////////////////////////////////////////////////////////////////
+//           SEND RECEIVE OPERATIONS
+///////////////////////////////////////////////////////////////////
+
+/**
+ * unix_fna_send_sync()
+ *
+ **/
+
+int unix_fna_send_sync(const fna_endpoint_data_t *endpoint,
+                       const void *msg,
+                       const size_t size)
+{
+   return 0;
+}
+
+/**
+ * unix_fna_send_async()
+ *
+ **/
+
+int unix_fna_send_async(const fna_endpoint_data_t *endpoint,
+                        const void *msg,
+                        const size_t size)
+{
+    return 0;
+}
+
+/**
+ * unix_fna_receive_sync()
+ *
+ **/
+
+int unix_fna_receive_sync(const fna_endpoint_data_t *endpoint,
+                          void *buffer,
+                          const size_t buffer_size,
+                          size_t *received_bytes,
+                          frsh_network_address_t *from)
+{
+    return 0;
+}
+
+/**
+ * unix_fna_receive_async()
+ *
+ **/
+
+int unix_fna_receive_async(const fna_endpoint_data_t *endpoint,
+                           void *buffer,
+                           const size_t buffer_size,
+                           size_t *received_bytes,
+                           frsh_network_address_t *from)
+{
+   return 0;
+}
+
+/**
+ * unix_fna_send_endpoint_get_status()
+ *
+ **/
+
+int unix_fna_send_endpoint_get_status(const fna_endpoint_data_t *endpoint,
+                                      int *number_of_pending_messages,
+                                      frsh_endpoint_network_status_t *network_status,
+                                      frsh_protocol_status_t *protocol_status)
+{
+   return 0;
+}
+
+/**
+ * unix_fna_receive_endpoint_created()
+ *
+ **/
+int unix_fna_receive_endpoint_created(const fna_endpoint_data_t *endpoint)
+{
+   return 0;
+}
+
+/**
+ * unix_fna_receive_endpoint_get_pending_messages
+ *
+ **/
+
+int unix_fna_receive_endpoint_get_status(const fna_endpoint_data_t *endpoint,
+                                         int *number_of_pending_messages,
+                                         frsh_endpoint_network_status_t *network_status,
+                                         frsh_protocol_status_t *protocol_status)
+{
+   return 0;
+}
+
+//////////////////////////////////////////////////////////////////////
+//           NETWORK CONFIGURATION FUNCTIONS
+//////////////////////////////////////////////////////////////////////
+
+/**
+ * unix_fna_network_get_max_message_size()
+ *
+ **/
+
+int unix_fna_network_get_max_message_size(const frsh_resource_id_t resource_id,
+                                          const frsh_network_address_t destination,
+                                          size_t *max_size)
+{
+    return 0;
+}
+
+/**
+ * unix_fna_network_bytes_to_budget()
+ *
+ **/
+
+int unix_fna_network_bytes_to_budget(const frsh_resource_id_t resource_id,
+                                     const size_t nbytes,
+                                     struct timespec *budget)
+{
+    return 0;
+}
+
+/**
+ * unix_fna_network_budget_to_bytes()
+ *
+ **/
+
+int unix_fna_network_budget_to_bytes(const frsh_resource_id_t resource_id,
+                                     const struct timespec *budget,
+                                     size_t *nbytes)
+{
+    return 0;
+}
+
+/**
+ * unix_fna_network_get_min_eff_budget()
+ *
+ **/
+
+int unix_fna_network_get_min_eff_budget(const frsh_resource_id_t resource_id,
+                                        struct timespec *budget)
+{
+   return 0;
+}
+
+// GLOBAL variable to install the network protocol in FRESCOR
+
+fna_operations_t unix_fna_operations = {
+    .fna_init = unix_fna_init,
+    .fna_contract_negotiate = unix_fna_contract_negotiate,
+    .fna_contract_renegotiate_sync = unix_fna_contract_renegotiate_sync,
+    .fna_contract_renegotiate_async = unix_fna_contract_renegotiate_async,
+    .fna_vres_get_renegotiation_status = unix_fna_vres_get_renegotiation_status,
+    .fna_vres_destroy = unix_fna_vres_destroy,
+    .fna_vres_get_contract = unix_fna_vres_get_contract,
+    .fna_vres_get_usage = unix_fna_vres_get_usage,
+    .fna_vres_get_remaining_budget = unix_fna_vres_get_remaining_budget,
+    .fna_vres_get_budget_and_period = unix_fna_vres_get_budget_and_period,
+    .fna_resource_get_capacity = unix_fna_resource_get_capacity,
+    .fna_resource_get_total_weight = unix_fna_resource_get_total_weight,
+    .fna_vres_decrease_capacity = unix_fna_vres_decrease_capacity,
+    .fna_send_sync = unix_fna_send_sync,
+    .fna_send_async = unix_fna_send_async,
+    .fna_receive_sync = unix_fna_receive_sync,
+    .fna_receive_async = unix_fna_receive_async,
+    .fna_send_endpoint_get_status = unix_fna_send_endpoint_get_status,
+    .fna_receive_endpoint_created = unix_fna_receive_endpoint_created,
+    .fna_receive_endpoint_get_status = unix_fna_receive_endpoint_get_status,
+    .fna_network_get_max_message_size = unix_fna_network_get_max_message_size,
+    .fna_network_bytes_to_budget = unix_fna_network_bytes_to_budget,
+    .fna_network_budget_to_bytes = unix_fna_network_budget_to_bytes,
+    .fna_network_get_min_eff_budget = unix_fna_network_get_min_eff_budget
+};
diff --git a/src_unix/unix_fna.h b/src_unix/unix_fna.h
new file mode 100644 (file)
index 0000000..7d890ca
--- /dev/null
@@ -0,0 +1,73 @@
+//----------------------------------------------------------------------
+//  Copyright (C) 2006 - 2007 by the FRESCOR consortium:
+//
+//    Universidad de Cantabria,              SPAIN
+//    University of York,                    UK
+//    Scuola Superiore Sant'Anna,            ITALY
+//    Kaiserslautern University,             GERMANY
+//    Univ. Politecnica  Valencia,           SPAIN
+//    Czech Technical University in Prague,  CZECH REPUBLIC
+//    ENEA                                   SWEDEN
+//    Thales Communication S.A.              FRANCE
+//    Visual Tools S.A.                      SPAIN
+//    Rapita Systems Ltd                     UK
+//    Evidence                               ITALY
+//
+//    See http://www.frescor.org
+//
+//        The FRESCOR project (FP6/2005/IST/5-034026) is funded
+//        in part by the European Union Sixth Framework Programme
+//        The European Union is not liable of any use that may be
+//        made of this code.
+//
+//
+//  based on previous work (FSF) done in the FIRST project
+//
+//   Copyright (C) 2005  Mälardalen University, SWEDEN
+//                       Scuola Superiore S.Anna, ITALY
+//                       Universidad de Cantabria, SPAIN
+//                       University of York, UK
+//
+// This file is part of FNA (Frescor Network Adaptation)
+//
+// FNA is free software; you can redistribute it and/or modify it
+// under terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option) any
+// later version.  FNA is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details. You should have received a
+// copy of the GNU General Public License along with FNA; see file
+// COPYING. If not, write to the Free Software Foundation, 675 Mass Ave,
+// Cambridge, MA 02139, USA.
+//
+// As a special exception, including FNA header files in a file,
+// instantiating FNA generics or templates, or linking other files
+// with FNA objects to produce an executable application, does not
+// by itself cause the resulting executable application to be covered
+// by the GNU General Public License. This exception does not
+// however invalidate any other reasons why the executable file might be
+// covered by the GNU Public License.
+// -----------------------------------------------------------------------
+
+//==============================================
+//  ******** ****     **     **
+//  **///// /**/**   /**    ****
+//  **      /**//**  /**   **//**
+//  ******* /** //** /**  **  //**
+//  **////  /**  //**/** **********
+//  **      /**   //****/**//////**
+//  **      /**    //***/**     /**
+//  /       //      /// //      //
+//
+// FNA(Frescor Network Adaptation layer), pronounced "efe ene a"
+//==============================================================
+
+#ifndef _UNIX_FNA_H_
+#define _UNIX_FNA_H_
+
+#include "fna.h" // for fna_operations_t
+
+extern fna_operations_t unix_fna_operations;
+
+#endif // _UNIX_FNA_H_
diff --git a/tests/qemu/Makefile b/tests/qemu/Makefile
new file mode 100755 (executable)
index 0000000..4467937
--- /dev/null
@@ -0,0 +1,55 @@
+include ../../config.mk
+
+export:
+       @cp $(EXPORT_PATH)/mprogram $(EXPORT_PATH)/mprogram_right
+       @cp $(EXPORT_PATH)/mprogram $(EXPORT_PATH)/mprogram_left
+       @cp $(EXPORT_PATH)/mprogram $(EXPORT_PATH)/mprogram_middle
+
+create_emulator_imgs:
+       @cp base_disk.img master.img
+       @cp base_disk.img slave.img
+       @cp base_disk.img other_slave.img
+
+qemu_1:
+       @cp $(EXPORT_PATH)/mprogram .
+       @mv slave.img disk.img
+       @./mkvirtualdisk
+       @mv disk.img slave.img
+       qemu -hda slave.img &
+
+qemu_2:
+       @cp $(EXPORT_PATH)/mprogram .
+       @mv slave.img disk.img
+       @./mkvirtualdisk
+       @mv disk.img slave.img
+       @mv master.img disk.img
+       @./mkvirtualdisk
+       @mv disk.img master.img
+       qemu -hda slave.img -net nic,macaddr=00:0E:0C:5B:1D:BD,model=rtl8139 -net socket,mcast=230.0.0.1:1234 &
+# qemu -hda slave.img -net nic,macaddr=00:02:44:35:66:5B,model=rtl8139 -net socket,mcast=230.0.0.1:1234 &
+       @sleep 2
+       qemu -hda master.img -net nic,macaddr=00:0E:0C:5B:1E:28,model=rtl8139 -net socket,mcast=230.0.0.1:1234
+# qemu -hda master.img -net nic,macaddr=00:02:44:3B:6A:BE,model=rtl8139 -net socket,mcast=230.0.0.1:1234
+
+qemu_3:
+       @cp $(EXPORT_PATH)/mprogram .
+       @mv master.img disk.img
+       @./mkvirtualdisk
+       @mv disk.img master.img
+       @mv slave.img disk.img
+       @./mkvirtualdisk
+       @mv disk.img slave.img
+       @mv other_slave.img disk.img
+       @./mkvirtualdisk
+       @mv disk.img other_slave.img
+       qemu -hda master.img -net nic,macaddr=00:0E:0C:5B:1E:28,model=rtl8139 -net socket,mcast=230.0.0.1:1234 &
+       qemu -hda slave.img -net nic,macaddr=00:0E:0C:5B:1D:BD,model=rtl8139 -net socket,mcast=230.0.0.1:1234 &
+       qemu -hda other_slave.img -net nic,macaddr=00:02:44:3C:08:21,model=rtl8139 -net socket,mcast=230.0.0.1:1234 &
+
+clean:
+       @exec echo -e "\n>> Cleaning up IMAGES:";
+       @rm -fv master.img
+       @rm -fv slave.img
+       @rm -fv other_slave.img
+       @rm -fv mprogram
+       @exec echo "  [OK]"
\ No newline at end of file
diff --git a/tests/qemu/base_disk.img b/tests/qemu/base_disk.img
new file mode 100755 (executable)
index 0000000..b6daadc
Binary files /dev/null and b/tests/qemu/base_disk.img differ
diff --git a/tests/qemu/mkvirtualdisk b/tests/qemu/mkvirtualdisk
new file mode 100755 (executable)
index 0000000..47ceb20
--- /dev/null
@@ -0,0 +1,5 @@
+losetup -o32256 /dev/loop/0 disk.img &&
+mount -o loop /dev/loop0  mnt &&
+cp -f mprogram mnt/mprogram &&
+umount mnt &&
+losetup -d /dev/loop/0
diff --git a/tests/tests_rtep_fna/Makefile b/tests/tests_rtep_fna/Makefile
new file mode 100755 (executable)
index 0000000..5503a11
--- /dev/null
@@ -0,0 +1,6 @@
+include ../../config.mk
+include ../../rules.mk
+
+CFLAGS += -I$(FNA_PATH)/src_rtep/ -I$(PLATFORM_PATH)/drivers/rt-ep/
+LDFLAGS += -L$(FNA_PATH)/lib -lrtepfna -L$(PLATFORM_PATH)/drivers/rt-ep -lrtep \
+       -L$(FRSH_PATH)/lib -lfrsh -L$(FOSA_PATH)/lib -lfosa_$(PLATFORM) -lm -lfna
diff --git a/tests/tests_rtep_fna/test_c_rtep_fna.c b/tests/tests_rtep_fna/test_c_rtep_fna.c
new file mode 100644 (file)
index 0000000..5b7ee42
--- /dev/null
@@ -0,0 +1,235 @@
+//----------------------------------------------------------------------
+//  Copyright (C) 2006 - 2007 by the FRESCOR consortium:
+//
+//    Universidad de Cantabria,              SPAIN
+//    University of York,                    UK
+//    Scuola Superiore Sant'Anna,            ITALY
+//    Kaiserslautern University,             GERMANY
+//    Univ. Politecnica  Valencia,           SPAIN
+//    Czech Technical University in Prague,  CZECH REPUBLIC
+//    ENEA                                   SWEDEN
+//    Thales Communication S.A.              FRANCE
+//    Visual Tools S.A.                      SPAIN
+//    Rapita Systems Ltd                     UK
+//    Evidence                               ITALY
+//
+//    See http://www.frescor.org
+//
+//        The FRESCOR project (FP6/2005/IST/5-034026) is funded
+//        in part by the European Union Sixth Framework Programme
+//        The European Union is not liable of any use that may be
+//        made of this code.
+//
+//
+//  based on previous work (FSF) done in the FIRST project
+//
+//   Copyright (C) 2005  Mälardalen University, SWEDEN
+//                       Scuola Superiore S.Anna, ITALY
+//                       Universidad de Cantabria, SPAIN
+//                       University of York, UK
+//
+// This file is part of FNA (Frescor Network Adaptation)
+//
+// FNA is free software; you can redistribute it and/or modify it
+// under terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option) any
+// later version.  FNA is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details. You should have received a
+// copy of the GNU General Public License along with FNA; see file
+// COPYING. If not, write to the Free Software Foundation, 675 Mass Ave,
+// Cambridge, MA 02139, USA.
+//
+// As a special exception, including FNA header files in a file,
+// instantiating FNA generics or templates, or linking other files
+// with FNA objects to produce an executable application, does not
+// by itself cause the resulting executable application to be covered
+// by the GNU General Public License. This exception does not
+// however invalidate any other reasons why the executable file might be
+// covered by the GNU Public License.
+// -----------------------------------------------------------------------
+
+/*
+ * test_c_rtep_fna.c
+ *
+ * Goal:
+ *
+ * The goal of this program is to test the RTEP implementation of the functions
+ * defined at fna.h without passing through the FRSH interface.
+ *
+ * Algorithm:
+ *
+ * We have two nodes, a sender and a receiver. The sender negotiates a contract,
+ * send info to the receiver, then renegotiates the contract and finally it
+ * cancels the contract.
+ *
+ */
+
+#include <assert.h> // for assert
+#include <stdio.h> // for printf
+#include <time.h> // for timespec
+
+#include "frsh_core.h" // for frsh_contract_set_xxx
+#include "frsh_core_types.h" // for FRSH_RESOURCE_ID_DEFAULT
+#include "frsh_distributed_types.h" // for frsh_network_address_t, frsh_stream_id_t
+
+#include "fna.h" // for fna_vres_id_t
+#include "frsh_fna.h" // for frsh_rtep_*
+#include "rtep_fna.h" // for rtep_fna_operations
+
+#include "rtep.h" // for rtep_station_id_t, rtep_channel_t
+
+int main ()
+{
+    int err;
+    rtep_station_id_t me, normal_station, multicast_station;
+    frsh_network_address_t frsh_address;
+    char multicast_name[] = "broadcast";
+    size_t max_size, max_multicast_size, budget_bytes, nbytes;
+    struct timespec budget_timespec, period_max;
+    frsh_contract_t frsh_contract;
+    fna_vres_id_t vres;
+    fna_endpoint_data_t endpoint;
+    const int MSG_BUFFER_MX = 10;
+    char msg_buffer[MSG_BUFFER_MX];
+    int msg_size;
+    int msg_counter;
+
+    printf("--------------------------------------------------\n");
+    printf("1.- fna_init\n");
+    printf("--------------------------------------------------\n");
+    err = rtep_fna_operations.fna_init(FRSH_RESOURCE_ID_DEFAULT);
+    assert(err == 0);
+
+    printf("--------------------------------------------------\n");
+    printf("2.- fna_network_get_max_message_size\n");
+    printf("--------------------------------------------------\n");
+   // get broadcast address for FRESCOR
+    multicast_station = rtep_get_station_id_by_name
+            ((uint8_t *)multicast_name, sizeof(multicast_name)-1);
+
+    err = frsh_rtep_map_network_address
+            (FRSH_RESOURCE_ID_DEFAULT, multicast_station, &frsh_address);
+    assert (err == 0);
+
+   // maximum size per message for a broadcast address
+    err=rtep_fna_operations.fna_network_get_max_message_size
+            (FRSH_RESOURCE_ID_DEFAULT, frsh_address, &max_multicast_size);
+    printf("Max multicast message size: %d\n", max_multicast_size);
+    assert (err == 0);
+    assert (max_multicast_size == MULTICAST_MTU);
+
+   // now the same with a normal address (i.e: 2)
+    normal_station = 2;
+    err=frsh_rtep_map_network_address
+            (FRSH_RESOURCE_ID_DEFAULT, normal_station, &frsh_address);
+    assert (err == 0);
+
+   // maximum size per message for a normal address
+    err=rtep_fna_operations.fna_network_get_max_message_size
+            (FRSH_RESOURCE_ID_DEFAULT, frsh_address, &max_size);
+    printf("Max message size: %d\n", max_size);
+    assert (err == 0);
+    assert (max_size == MAX_RTEP_MTU);
+
+    printf("--------------------------------------------------\n");
+    printf("3.- fna_network_budget_to_bytes\n");
+    printf("--------------------------------------------------\n");
+    nbytes = 1700;
+    err=rtep_fna_operations.fna_network_bytes_to_budget
+            (FRSH_RESOURCE_ID_DEFAULT, nbytes, &budget_timespec);
+    assert (err == 0);
+
+    err=rtep_fna_operations.fna_network_budget_to_bytes
+            (FRSH_RESOURCE_ID_DEFAULT, &budget_timespec, &budget_bytes);
+    assert (err == 0);
+    printf("%d user bytes -> %d budget bytes\n", nbytes, budget_bytes);
+
+    printf("--------------------------------------------------\n");
+    printf("4.- fna_network_get_min_effective_budget\n");
+    printf("--------------------------------------------------\n");
+    err=rtep_fna_operations.fna_network_get_min_eff_budget
+            (FRSH_RESOURCE_ID_DEFAULT, &budget_timespec);
+    assert (err == 0);
+
+    err=rtep_fna_operations.fna_network_budget_to_bytes
+            (FRSH_RESOURCE_ID_DEFAULT, &budget_timespec, &budget_bytes);
+    assert (err == 0);
+    printf("Minimum effective budget: %d\n", budget_bytes);
+
+    // send or receive
+    me = rtep_get_station_id();
+
+    if (me == 1) {
+
+        printf("--------------------------------------------------\n");
+        printf("5.- fna_contract_negotiate\n");
+        printf("--------------------------------------------------\n");
+
+        period_max.tv_sec = 3;
+        period_max.tv_nsec = 0;
+
+        // Create the contract
+        frsh_contract.workload = FRSH_WT_INDETERMINATE;
+        frsh_contract.granularity = FRSH_DEFAULT_GRANULARITY;
+        frsh_contract.weight = FRSH_DEFAULT_WEIGHT;
+        frsh_contract.importance = FRSH_DEFAULT_IMPORTANCE;
+        frsh_contract.resource_id = FRSH_RESOURCE_ID_DEFAULT;
+        frsh_contract.resource_type = FRSH_RT_NETWORK;
+
+        frsh_contract.budget_min = budget_timespec;
+        frsh_contract.period_max = period_max;
+        frsh_contract.d_equals_t = true;
+        frsh_contract.preemption_level = 4;
+
+        // Negotiate the contract
+        err = rtep_fna_operations.fna_contract_negotiate
+                (FRSH_RESOURCE_ID_DEFAULT, &frsh_contract, &vres);
+        assert (err == 0);
+        printf("Contract accepted\n");
+
+        // Bind the vres to an endpoint
+        endpoint.endpoint_type = FRSH_SEND_ENDPOINT_TYPE;
+        endpoint.vres = vres;
+        endpoint.is_bound = true;
+        endpoint.destination = 2; // only for send_endpoints
+        endpoint.resource_id = FRSH_RESOURCE_ID_DEFAULT;
+        endpoint.stream_id = 7;
+
+        msg_counter = 0;
+
+        while(1) {
+            sleep(4);
+            printf("sending message\n");
+
+            msg_counter = msg_counter + 1;
+            msg_size = snprintf(msg_buffer, MSG_BUFFER_MX-1, "MSG %d", msg_counter);
+
+            err = rtep_fna_operations.fna_send_async
+                   (&endpoint, msg_buffer, msg_size);
+            assert (err == 0);
+        }
+    } else {
+        size_t received_bytes;
+        frsh_network_address_t from;
+
+        endpoint.endpoint_type = FRSH_RECEIVE_ENDPOINT_TYPE;
+        endpoint.is_bound = false;
+        endpoint.resource_id = FRSH_RESOURCE_ID_DEFAULT;
+        endpoint.stream_id = 7;
+
+        while(1) {
+            printf("blocking to receive\n");
+            err = rtep_fna_operations.fna_receive_sync
+                    (&endpoint, msg_buffer, MSG_BUFFER_MX, &received_bytes, &from);
+            assert (err == 0);
+
+            msg_buffer[received_bytes] = '\0';
+
+            printf("msg received: %s\n", msg_buffer);
+        }
+    }
+
+    return 0;
+}
diff --git a/tests/tests_rtep_fna/test_c_rtep_fna_with_frsh.c b/tests/tests_rtep_fna/test_c_rtep_fna_with_frsh.c
new file mode 100644 (file)
index 0000000..5b11473
--- /dev/null
@@ -0,0 +1,236 @@
+//----------------------------------------------------------------------
+//  Copyright (C) 2006 - 2007 by the FRESCOR consortium:
+//
+//    Universidad de Cantabria,              SPAIN
+//    University of York,                    UK
+//    Scuola Superiore Sant'Anna,            ITALY
+//    Kaiserslautern University,             GERMANY
+//    Univ. Politecnica  Valencia,           SPAIN
+//    Czech Technical University in Prague,  CZECH REPUBLIC
+//    ENEA                                   SWEDEN
+//    Thales Communication S.A.              FRANCE
+//    Visual Tools S.A.                      SPAIN
+//    Rapita Systems Ltd                     UK
+//    Evidence                               ITALY
+//
+//    See http://www.frescor.org
+//
+//        The FRESCOR project (FP6/2005/IST/5-034026) is funded
+//        in part by the European Union Sixth Framework Programme
+//        The European Union is not liable of any use that may be
+//        made of this code.
+//
+//
+//  based on previous work (FSF) done in the FIRST project
+//
+//   Copyright (C) 2005  Mälardalen University, SWEDEN
+//                       Scuola Superiore S.Anna, ITALY
+//                       Universidad de Cantabria, SPAIN
+//                       University of York, UK
+//
+// This file is part of FNA (Frescor Network Adaptation)
+//
+// FNA is free software; you can redistribute it and/or modify it
+// under terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option) any
+// later version.  FNA is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details. You should have received a
+// copy of the GNU General Public License along with FNA; see file
+// COPYING. If not, write to the Free Software Foundation, 675 Mass Ave,
+// Cambridge, MA 02139, USA.
+//
+// As a special exception, including FNA header files in a file,
+// instantiating FNA generics or templates, or linking other files
+// with FNA objects to produce an executable application, does not
+// by itself cause the resulting executable application to be covered
+// by the GNU General Public License. This exception does not
+// however invalidate any other reasons why the executable file might be
+// covered by the GNU Public License.
+// -----------------------------------------------------------------------
+
+/*
+ * test_c_rtep_fna.c
+ *
+ * Goal:
+ *
+ * The goal of this program is to test the RTEP implementation of the functions
+ * defined at fna.h without passing through the FRSH interface.
+ *
+ * Algorithm:
+ *
+ * We have two nodes, a sender and a receiver. The sender negotiates a contract,
+ * send info to the receiver, then renegotiates the contract and finally it
+ * cancels the contract.
+ *
+ */
+
+#include <assert.h> // for assert
+#include <stdio.h> // for printf
+#include <time.h> // for timespec
+
+#include "frsh_core.h" // for frsh_contract_set_xxx
+#include "frsh_core_types.h" // for FRSH_RESOURCE_ID_DEFAULT
+#include "frsh_distributed_types.h" // for frsh_network_address_t, frsh_stream_id_t
+
+#include "fna.h" // for fna_vres_id_t
+#include "frsh_fna.h" // for frsh_rtep_*
+#include "rtep_fna.h" // for rtep_fna_operations
+
+#include "rtep.h" // for rtep_station_id_t, rtep_channel_t
+
+int main ()
+{
+    int err;
+    rtep_station_id_t me, normal_station, multicast_station;
+    frsh_network_address_t frsh_address;
+    char multicast_name[] = "broadcast";
+    size_t max_size, max_multicast_size, budget_bytes, nbytes;
+    struct timespec budget_timespec, period_max;
+    frsh_contract_t frsh_contract;
+    fna_vres_id_t vres;
+    fna_endpoint_data_t endpoint;
+    const int MSG_BUFFER_MX = 10;
+    char msg_buffer[MSG_BUFFER_MX];
+    int msg_size;
+    int msg_counter;
+
+    printf("--------------------------------------------------\n");
+    printf("1.- fna_init\n");
+    printf("--------------------------------------------------\n");
+    err = frsh_init();
+//     err = rtep_fna_operations.fna_init(FRSH_RESOURCE_ID_DEFAULT);
+    assert(err == 0);
+
+    printf("--------------------------------------------------\n");
+    printf("2.- fna_network_get_max_message_size\n");
+    printf("--------------------------------------------------\n");
+   // get broadcast address for FRESCOR
+    multicast_station = rtep_get_station_id_by_name
+            ((uint8_t *)multicast_name, sizeof(multicast_name)-1);
+
+    err = frsh_rtep_map_network_address
+            (FRSH_RESOURCE_ID_DEFAULT, multicast_station, &frsh_address);
+    assert (err == 0);
+
+   // maximum size per message for a broadcast address
+    err=rtep_fna_operations.fna_network_get_max_message_size
+            (FRSH_RESOURCE_ID_DEFAULT, frsh_address, &max_multicast_size);
+    printf("Max multicast message size: %d\n", max_multicast_size);
+    assert (err == 0);
+    assert (max_multicast_size == MULTICAST_MTU);
+
+   // now the same with a normal address (i.e: 2)
+    normal_station = 2;
+    err=frsh_rtep_map_network_address
+            (FRSH_RESOURCE_ID_DEFAULT, normal_station, &frsh_address);
+    assert (err == 0);
+
+   // maximum size per message for a normal address
+    err=rtep_fna_operations.fna_network_get_max_message_size
+            (FRSH_RESOURCE_ID_DEFAULT, frsh_address, &max_size);
+    printf("Max message size: %d\n", max_size);
+    assert (err == 0);
+    assert (max_size == MAX_RTEP_MTU);
+
+    printf("--------------------------------------------------\n");
+    printf("3.- fna_network_budget_to_bytes\n");
+    printf("--------------------------------------------------\n");
+    nbytes = 1700;
+    err=rtep_fna_operations.fna_network_bytes_to_budget
+            (FRSH_RESOURCE_ID_DEFAULT, nbytes, &budget_timespec);
+    assert (err == 0);
+
+    err=rtep_fna_operations.fna_network_budget_to_bytes
+            (FRSH_RESOURCE_ID_DEFAULT, &budget_timespec, &budget_bytes);
+    assert (err == 0);
+    printf("%d user bytes -> %d budget bytes\n", nbytes, budget_bytes);
+
+    printf("--------------------------------------------------\n");
+    printf("4.- fna_network_get_min_effective_budget\n");
+    printf("--------------------------------------------------\n");
+    err=rtep_fna_operations.fna_network_get_min_eff_budget
+            (FRSH_RESOURCE_ID_DEFAULT, &budget_timespec);
+    assert (err == 0);
+
+    err=rtep_fna_operations.fna_network_budget_to_bytes
+            (FRSH_RESOURCE_ID_DEFAULT, &budget_timespec, &budget_bytes);
+    assert (err == 0);
+    printf("Minimum effective budget: %d\n", budget_bytes);
+
+    // send or receive
+    me = rtep_get_station_id();
+
+    if (me == 1) {
+
+        printf("--------------------------------------------------\n");
+        printf("5.- fna_contract_negotiate\n");
+        printf("--------------------------------------------------\n");
+
+        period_max.tv_sec = 3;
+        period_max.tv_nsec = 0;
+
+        // Create the contract
+        frsh_contract.workload = FRSH_WT_INDETERMINATE;
+        frsh_contract.granularity = FRSH_DEFAULT_GRANULARITY;
+        frsh_contract.weight = FRSH_DEFAULT_WEIGHT;
+        frsh_contract.importance = FRSH_DEFAULT_IMPORTANCE;
+        frsh_contract.resource_id = FRSH_RESOURCE_ID_DEFAULT;
+        frsh_contract.resource_type = FRSH_RT_NETWORK;
+
+        frsh_contract.budget_min = budget_timespec;
+        frsh_contract.period_max = period_max;
+        frsh_contract.d_equals_t = true;
+        frsh_contract.preemption_level = 4;
+
+        // Negotiate the contract
+        err = rtep_fna_operations.fna_contract_negotiate
+                (FRSH_RESOURCE_ID_DEFAULT, &frsh_contract, &vres);
+        assert (err == 0);
+        printf("Contract accepted\n");
+
+        // Bind the vres to an endpoint
+        endpoint.endpoint_type = FRSH_SEND_ENDPOINT_TYPE;
+        endpoint.vres = vres;
+        endpoint.is_bound = true;
+        endpoint.destination = 2; // only for send_endpoints
+        endpoint.resource_id = FRSH_RESOURCE_ID_DEFAULT;
+        endpoint.stream_id = 7;
+
+        msg_counter = 0;
+
+        while(1) {
+            sleep(4);
+            printf("sending message\n");
+
+            msg_counter = msg_counter + 1;
+            msg_size = snprintf(msg_buffer, MSG_BUFFER_MX-1, "MSG %d", msg_counter);
+
+            err = rtep_fna_operations.fna_send_async
+                   (&endpoint, msg_buffer, msg_size);
+            assert (err == 0);
+        }
+    } else {
+        size_t received_bytes;
+        frsh_network_address_t from;
+
+        endpoint.endpoint_type = FRSH_RECEIVE_ENDPOINT_TYPE;
+        endpoint.is_bound = false;
+        endpoint.resource_id = FRSH_RESOURCE_ID_DEFAULT;
+        endpoint.stream_id = 7;
+
+        while(1) {
+            printf("blocking to receive\n");
+            err = rtep_fna_operations.fna_receive_sync
+                    (&endpoint, msg_buffer, MSG_BUFFER_MX, &received_bytes, &from);
+            assert (err == 0);
+
+            msg_buffer[received_bytes] = '\0';
+
+            printf("msg received: %s\n", msg_buffer);
+        }
+    }
+
+    return 0;
+}
diff --git a/tests/tests_rtep_fna/test_c_rtep_frsh_fna.c b/tests/tests_rtep_fna/test_c_rtep_frsh_fna.c
new file mode 100644 (file)
index 0000000..b7da0f2
--- /dev/null
@@ -0,0 +1,184 @@
+//----------------------------------------------------------------------
+//  Copyright (C) 2006 - 2007 by the FRESCOR consortium:
+//
+//    Universidad de Cantabria,              SPAIN
+//    University of York,                    UK
+//    Scuola Superiore Sant'Anna,            ITALY
+//    Kaiserslautern University,             GERMANY
+//    Univ. Politecnica  Valencia,           SPAIN
+//    Czech Technical University in Prague,  CZECH REPUBLIC
+//    ENEA                                   SWEDEN
+//    Thales Communication S.A.              FRANCE
+//    Visual Tools S.A.                      SPAIN
+//    Rapita Systems Ltd                     UK
+//    Evidence                               ITALY
+//
+//    See http://www.frescor.org
+//
+//        The FRESCOR project (FP6/2005/IST/5-034026) is funded
+//        in part by the European Union Sixth Framework Programme
+//        The European Union is not liable of any use that may be
+//        made of this code.
+//
+//
+//  based on previous work (FSF) done in the FIRST project
+//
+//   Copyright (C) 2005  Mälardalen University, SWEDEN
+//                       Scuola Superiore S.Anna, ITALY
+//                       Universidad de Cantabria, SPAIN
+//                       University of York, UK
+//
+// This file is part of FNA (Frescor Network Adaptation)
+//
+// FNA is free software; you can redistribute it and/or modify it
+// under terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option) any
+// later version.  FNA is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details. You should have received a
+// copy of the GNU General Public License along with FNA; see file
+// COPYING. If not, write to the Free Software Foundation, 675 Mass Ave,
+// Cambridge, MA 02139, USA.
+//
+// As a special exception, including FNA header files in a file,
+// instantiating FNA generics or templates, or linking other files
+// with FNA objects to produce an executable application, does not
+// by itself cause the resulting executable application to be covered
+// by the GNU General Public License. This exception does not
+// however invalidate any other reasons why the executable file might be
+// covered by the GNU Public License.
+// -----------------------------------------------------------------------
+
+/*
+ * test_c_rtep_frsh_fna.c
+ *
+ * Goal:
+ *
+ * The goal of this program is to test the RTEP functions defined at frsh_fna.h
+ * which is the public part of frsh_fna.h. The interface of this public part
+ * is dependent of the underlying network protocol. We are not trying here to
+ * make a very intense test but a simple and basic one to check the correct
+ * behaviour of the functions.
+ *
+ * Algorithm:
+ *
+ * First we check the conversions between frsh and rtep addresses and streams.
+ * Then, we check the renegotiation functions for the period of the internal
+ * negotiation messages. And finally, we check the renegotiation functions for
+ * the internal service thread.
+ *
+ */
+
+#include <assert.h> // for assert
+#include <stdio.h> // for printf
+#include <stdbool.h> // for bool
+
+#include "frsh_core_types.h" // for FRSH_RESOURCE_ID_DEFAULT
+#include "frsh_distributed_types.h" // frsh_network_address_t, frsh_stream_id_t
+
+#include "rtep_fna.h" // for rtep_fna_operations.fna_init
+#include "rtep.h" // for rtep_station_id_t, rtep_channel_t
+
+#include "frsh_fna.h" // for frsh_rtep_*
+
+int main ()
+{
+    int err;
+    rtep_station_id_t rtep_station = 3;
+    frsh_network_address_t frsh_address;
+    rtep_channel_t in_stream = 7;
+    frsh_stream_id_t out_stream;
+    struct timespec neg_period = {2,0};
+    struct timespec get_period = {0,0};
+//     struct timespec rtep_serv_thread_budget = {1,0};
+//     struct timespec rtep_serv_thread_period = {5,0};
+//     bool serv_thread_renegotiation_accepted = false;
+//     struct timespec current_serv_thread_budget = {0,0};
+//     struct timespec current_serv_thread_period = {0,0};
+
+    printf("1.- fna_init\n");
+    err=rtep_fna_operations.fna_init(FRSH_RESOURCE_ID_DEFAULT);
+    assert(err == 0);
+
+    printf("2.- frsh_rtep_map_network_address\n");
+    err=frsh_rtep_map_network_address
+            (FRSH_RESOURCE_ID_DEFAULT, rtep_station, &frsh_address);
+    assert(err == 0);
+    printf("rtep_address:%d -> frsh_address:%d\n", rtep_station, frsh_address);
+    assert(rtep_station == frsh_address);
+
+    printf("3.- frsh_rtep_map_stream_id\n");
+    err=frsh_rtep_map_stream_id
+            (FRSH_RESOURCE_ID_DEFAULT, in_stream, &out_stream);
+    assert(err == 0);
+    printf("rtep_channel:%d -> frsh_stream:%d\n", in_stream, out_stream);
+    assert(in_stream == out_stream);
+
+    printf("4.- frsh_rtep_negotiation_messages_vres_renegotiate period\n");
+    err=frsh_rtep_negotiation_messages_vres_get_period
+            (FRSH_RESOURCE_ID_DEFAULT, &get_period);
+    assert(err == 0);
+    printf("period before renegotiation: sec=%d nsec=%d\n",
+            get_period.tv_sec, get_period.tv_nsec);
+
+    err=frsh_rtep_negotiation_messages_vres_renegotiate
+            (FRSH_RESOURCE_ID_DEFAULT, &neg_period);
+    if (err == 0) {
+        printf("renegotiation accepted (period negotiated: sec=%d nsec=%d)\n",
+               neg_period.tv_sec, neg_period.tv_nsec);
+    } else {
+        printf("renegotiation not accepted\n");
+    }
+    assert (err == 0);
+
+    err=frsh_rtep_negotiation_messages_vres_get_period
+            (FRSH_RESOURCE_ID_DEFAULT, &get_period);
+    assert(err == 0);
+    printf("period after renegotiation: sec=%d nsec=%d\n",
+           get_period.tv_sec, get_period.tv_nsec);
+
+// TODO: uncomment step 5 when internal thread has a frescor contract
+// printf("5.- frsh_rtep_service_thread_vres_renegotiate\n");
+//
+// err=frsh_rtep_service_thread_vres_get_budget_and_period
+//         (FRSH_RESOURCE_ID_DEFAULT,
+//             &current_serv_thread_budget,
+//             &current_serv_thread_period);
+// assert(err == 0);
+// printf("service thread budget (before renegotiation): sec=%d nsec=%d\n",
+//         current_serv_thread_budget.tv_sec,
+//         current_serv_thread_budget.tv_nsec);
+// printf("service thread period (before renegotiation): sec=%d nsec=%d\n",
+//         current_serv_thread_period.tv_sec,
+//         current_serv_thread_period.tv_nsec);
+//
+// err=frsh_rtep_service_thread_vres_renegotiate
+//         (FRSH_RESOURCE_ID_DEFAULT,
+//             &rtep_serv_thread_budget,
+//             &rtep_serv_thread_period,
+//             &serv_thread_renegotiation_accepted);
+// assert(err == 0);
+//
+// if (serv_thread_renegotiation_accepted) {
+//     printf("service_thread renegotiation accepted\n");
+// } else {
+//     printf("service_thread renegotiation not accepted\n");
+// }
+// assert (err == 0);
+//
+// err=frsh_rtep_service_thread_vres_get_budget_and_period
+//         (FRSH_RESOURCE_ID_DEFAULT,
+//             &current_serv_thread_budget,
+//             &current_serv_thread_period);
+// assert(err == 0);
+// printf("service thread budget (after renegotiation): sec=%d nsec=%d\n",
+//         current_serv_thread_budget.tv_sec,
+//         current_serv_thread_budget.tv_nsec);
+// printf("service thread period (after renegotiation): sec=%d nsec=%d\n",
+//         current_serv_thread_period.tv_sec,
+//         current_serv_thread_period.tv_nsec);
+
+    printf("\nEND of the TEST\n");
+    return 0;
+}