/* $Id: mcl_tx_prof.cpp,v 1.2 2003/10/27 09:55:48 roca Exp $ */ /* * Copyright (c) 1999-2003 INRIA - Universite Paris 6 - All rights reserved * (main author: Vincent Roca - vincent.roca@inrialpes.fr) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ #include "mcl_includes.h" typedef struct { int layer_nb; /* max number of layers */ int datagram_sz; /* datagram size; the higher, the better */ int tx_rate; /* in packets per tick on the base layer */ int rlc_aggressive_cc;/* aggressive congestion ctrl setup for LAN tx*/ } tx_prof_t; /* * WARNING1: keep synchronized with mcl_lib.h * WARNING2: changing datagram_size must be done both at source AND receivers * by using the appropriate tx profile argument. */ static tx_prof_t tx_prof_tab[] = { /* lay datagram_size tx_rate aggr_cc*/ /* LOW_RATE_INTERNET */ {10, 576 - UDP_IPv4_HEADER_SIZE, 3, 0}, /* MID_RATE_INTERNET */ {10, 576 - UDP_IPv4_HEADER_SIZE, 20, 0}, /* HIGH_SPEED_INTERNET*/{6, 1024 - UDP_IPv4_HEADER_SIZE, 40, 0}, #if 0 /* HIGH_SPEED_LAN */ {6, 1500 - UDP_IPv4_HEADER_SIZE, 40, 1}, #endif /* HIGH_SPEED_LAN */ {1, 1500 - UDP_IPv4_HEADER_SIZE, 800, 0}, }; /* * set a pre-defined profile, modifying some lib parameters as required */ int mcl_set_tx_profile (mclcb_t *mclcb, int profile) { int val; int err; /*#ifdef DEBUG*/ #ifdef NEVERDEF int old_verbose = mclcb->verbose; mclcb->verbose=5; #endif TRACELVL(5, (mcl_stdout, "-> mcl_set_tx_profile: prof=%d\n", profile)) switch (profile) { case MCL_TX_PROFILE_LOW_RATE_INTERNET: case MCL_TX_PROFILE_MID_RATE_INTERNET: case MCL_TX_PROFILE_HIGH_SPEED_INTERNET: /*case MCL_TX_PROFILE_HIGH_SPEED_LAN: */ /* removed: see below */ if (!mclcb->single_layer_mode) { /* * nb: call mcl_ctl2 internal func as we are already * locked! * nb2: in single layer mode, by definition 1 layer only */ val = tx_prof_tab[profile].layer_nb; err = mcl_ctl2(mclcb, MCL_OPT_LAYER_NB, (void*)&val, sizeof(val)); if (err) goto error; } val = tx_prof_tab[profile].datagram_sz; err = mcl_ctl2(mclcb, MCL_OPT_DATAGRAM_SIZE, (void*)&val, sizeof(val)); if (err) goto error; val = tx_prof_tab[profile].tx_rate; if (mclcb->single_layer_mode) { /* * in that case, as we use a single layer rather * than tx_prof_tab[profile].layer_nb, increase * the tx rate on this layer so that is equals the * max cumulative tx rate of the profile. */ val = val * tx_prof_tab[profile].layer_nb; } err = mcl_ctl2(mclcb, MCL_OPT_TX_RATE, (void*)&val, sizeof(val)); if (err) goto error; #ifdef RLC /* * set the RLC LAN version which will impact the SP spacing, * death period... */ val = tx_prof_tab[profile].rlc_aggressive_cc; err = mcl_ctl2(mclcb, RLC_OPT_AGGRESSIVE_CC, (void*)&val, sizeof(val)); if (err) goto error; #endif break; case MCL_TX_PROFILE_HIGH_SPEED_LAN: /* * LAN case (no multicast routing), so use a single layer * and remove congestion control. */ mclcb->no_congestion_control = 1; mclcb->single_layer_mode = 1; val = 1; err = mcl_ctl2(mclcb, MCL_OPT_LAYER_NB, (void*)&val, sizeof(val)); if (err) goto error; val = tx_prof_tab[profile].datagram_sz; err = mcl_ctl2(mclcb, MCL_OPT_DATAGRAM_SIZE, (void*)&val, sizeof(val)); if (err) goto error; /* * here, as we use a single layer rather * than tx_prof_tab[profile].layer_nb, increase * the tx rate on this layer so that it equals the * max cumulative tx rate of the profile. */ val = tx_prof_tab[profile].tx_rate; err = mcl_ctl2(mclcb, MCL_OPT_TX_RATE, (void*)&val, sizeof(val)); if (err) goto error; break; default: PRINT_ERR((mcl_stderr, "mcl_set_tx_profile: profile %d not recognized\n", profile)) goto error; } TRACELVL(5, (mcl_stdout, "<- mcl_set_tx_profile:\n")) /*#ifdef DEBUG*/ #ifdef NEVERDEF mclcb->verbose=old_verbose; #endif return 0; error: TRACELVL(5, (mcl_stdout, "<- mcl_set_tx_profile: error\n")) return -1; }