2 * @file frescan_bwres_analysis.h
4 * @brief FRESCAN bandwith reservation layer: mode change protocol
10 * @author Daniel Sangorrin <daniel.sangorrin@unican.es>
14 * This module contains the mode change protocol
18 * -----------------------------------------------------------------------
19 * Copyright (C) 2006 - 2008 FRESCOR consortium partners:
21 * Universidad de Cantabria, SPAIN
22 * University of York, UK
23 * Scuola Superiore Sant'Anna, ITALY
24 * Kaiserslautern University, GERMANY
25 * Univ. Politécnica Valencia, SPAIN
26 * Czech Technical University in Prague, CZECH REPUBLIC
28 * Thales Communication S.A. FRANCE
29 * Visual Tools S.A. SPAIN
30 * Rapita Systems Ltd UK
33 * See http://www.frescor.org for a link to partners' websites
35 * FRESCOR project (FP6/2005/IST/5-034026) is funded
36 * in part by the European Union Sixth Framework Programme
37 * The European Union is not liable of any use that may be
40 * This file is part of FRESCAN
42 * FRESCAN is free software; you can redistribute it and/or modify
43 * it under the terms of the GNU General Public License as published by
44 * the Free Software Foundation; either version 2, or (at your option)
47 * FRESCAN is distributed in the hope that it will be useful, but
48 * WITHOUT ANY WARRANTY; without even the implied warranty of
49 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
50 * General Public License for more details.
52 * You should have received a copy of the GNU General Public License
53 * distributed with FRESCAN; see file COPYING. If not, write to the
54 * Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
57 * As a special exception, including FRESCAN header files in a file,
58 * instantiating FRESCAN generics or templates, or linking other files
59 * with FRESCAN objects to produce an executable application, does not
60 * by itself cause the resulting executable application to be covered
61 * by the GNU General Public License. This exception does not
62 * however invalidate any other reasons why the executable file might be
63 * covered by the GNU Public License.
64 * -----------------------------------------------------------------------
68 #include "frescan_bwres_mode_change.h"
69 #include "frescan_data.h"
70 #include <misc/linux_list.h>
73 * frescan_bwres_mode_change_protocol() - performs the mode change
75 * Follow the mode change protocol described in the paper.
79 int frescan_bwres_mode_change_protocol(frescan_request_data_t *req_data)
83 frescan_sa_vres_t *vres;
84 frsh_sa_vres_data_t *sa_vres_data;
85 frsh_sa_time_t max_period_in_budget_dec;
86 frsh_sa_time_t max_period_in_budget_inc;
87 frescan_request_data_t tmp_req_data;
89 for(node=0; node<FRESCAN_MX_NODES; node++) {
90 INIT_LIST_HEAD(&the_networks[req_data->net].
91 mode_change_budget_inc_list_head[node]);
93 INIT_LIST_HEAD(&the_networks[req_data->net].
94 mode_change_budget_dec_list_head[node]);
97 max_period_in_budget_dec = (frsh_sa_time_t)0;
98 max_period_in_budget_inc = (frsh_sa_time_t)0;
102 &the_networks[req_data->net].scenario.vres_head.list,
105 sa_vres_data = &the_networks[req_data->net].
106 scenario.fsa_scenario.sa_vres_alloc
107 [vres->fsa_vres_global_id];
109 vres->mode_change_type = 0;
111 if (sa_vres_data->c > vres->old_c) {
112 vres->mode_change_type |= FRESCAN_SA_BUDGET_INC;
114 if (sa_vres_data->t > max_period_in_budget_inc) {
115 max_period_in_budget_inc = sa_vres_data->t;
119 (&(vres->mode_change_list),
120 &(the_networks[req_data->net].
121 mode_change_budget_inc_list_head[vres->node]));
123 vres->mode_change_type |= FRESCAN_SA_BUDGET_DEC;
125 if (sa_vres_data->t > max_period_in_budget_dec) {
126 max_period_in_budget_dec = sa_vres_data->t;
130 (&(vres->mode_change_list),
131 &(the_networks[req_data->net].
132 mode_change_budget_dec_list_head[vres->node]));
135 if (sa_vres_data->t > vres->old_t) {
136 vres->mode_change_type |= FRESCAN_SA_PERIOD_INC;
138 vres->mode_change_type |= FRESCAN_SA_PERIOD_DEC;
141 if (sa_vres_data->p > vres->old_p) {
142 vres->mode_change_type |= FRESCAN_SA_PRIO_INC;
144 vres->mode_change_type |= FRESCAN_SA_PRIO_DEC;
147 vres->old_c = sa_vres_data->c;
148 vres->old_t = sa_vres_data->t;
149 vres->old_p = sa_vres_data->p;
152 // mode change for B- members
153 for(node=0; node<FRESCAN_MX_NODES; node++) { // TODO: end with master
154 list_for_each_entry(vres,
155 &the_networks[req_data->net].
156 mode_change_budget_dec_list_head[node],
159 if (node == FRESCAN_NEG_MASTER_NODE) {
161 the_servers_pool[req_data->net][vres->ss].params = ...
169 if (req_data->request_node != FRESCAN_NEG_MASTER_NODE) {
170 DEBUG(FRESCAN_MANAGER_ENABLE_DEBUG,
172 req_data->type = FRESCAN_REP_NEG;
173 ret = frescan_messages_send_request(req_data);
176 tmp_req_data.type = FRESCAN_REP_CHANGE;
177 tmp_req_data.node = ...;
179 ret = frescan_messages_send_request(&tmp_req_data);
180 if (ret != 0) return -1;
185 if (node == FRESCAN_NEG_MASTER_NODE) {
188 clock_nanosleep(absolute, beginning+period
190 list_del lo que ha disminuido
194 // wait the time needed to keep schedulability
197 // mode change for B+ members