📄 mpbufcal.c
字号:
/* mpBufCal.c - MP Buffer calculation source file *//* Copyright 1999 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01b,06aug02,jr fixed build warnings 01a,22feb01,sd created from routerware source base*//**$Log:: /Rtrware/devdrvrs/Mp/mpbufcal $ * * 4 2/08/99 12:12p Nishit * ppp_echo_request_sent() and * ppp_echo_request_received() return if * an unused port number is passed * * 3 4/30/98 3:02p Alex * Mp v4.2.0 check in * * 1 4/24/98 12:56a Release Engineer * code cleanup, code style changes, * linted, system level test * MP v4.2.0*//*DESCRIPTION: This module does the buffer requirement estimation. It computesthe buffer required for the Mp system, according to the method proposed byRFC 1717 and RFC 1990.This file contains functions to check if all the links are timed, to calculatethe longest delay among the delay of the links in the bundle and to estimatethe buffer requirement.INCLUDES: mp.h mpFramingLayerP.h*//* includes */#include "vxWorks.h"#include "ppp/mp.h"#include "private/ppp/mpFramingLayerP.h"#include "stdio.h"/******************************************************************************* if_all_links_are_timed - check if all the links in the bundle are timed** This function checks if all the links in the bundle are timed. This function * is used by the mp_estimate_buffer_requirement function during the buffer * calculation for the bundle. It checks all the links in the bundle to find if * all the links are timed. If any of the links in the bundle is NOT timed, then * it returns FALSE, else it returns TRUE.** RETURNS: TRUE/FALSE*/BOOL if_all_the_links_are_timed ( PFW_PLUGIN_OBJ_STATE * pMpFramingLayerState ) { UINT link_index; MP_FRAMING_LAYER_STACK_DATA * pStackData = (MP_FRAMING_LAYER_STACK_DATA *) pMpFramingLayerState->stackData ; for (link_index = 0x0000; link_index < pStackData->bundle.receiving_end.no_of_links; ++link_index) { if (pStackData->bundle.receiving_end.links[link_index].link_has_been_timed == FALSE) return (FALSE); } return (TRUE); }/******************************************************************************** find_longest_delay_of_all_links - find the longest delay of all the links in * the bundle** This function finds the longest delay of the links in the bundle. This * function is used by the mp_estimate_buffer_requirement function during the * buffer calculation for the bundle. The MAX delay among all the links in the * bundle is calculated.** RETURNS: delay value*/double find_longest_delay_of_all_links ( PFW_PLUGIN_OBJ_STATE * pMpFramingLayerState ) { UINT link_index; MP_FRAMING_LAYER_STACK_DATA * pStackData = (MP_FRAMING_LAYER_STACK_DATA *) pMpFramingLayerState->stackData ; double longest_delay = 0.0; for (link_index = 0x0000; link_index < pStackData->bundle.receiving_end.no_of_links; ++link_index) { if (pStackData->bundle.receiving_end.links[link_index].delay > longest_delay) longest_delay = pStackData->bundle.receiving_end.links[link_index].delay; } return (longest_delay); }/******************************************************************************** mp_estimate_buffer_requirement - calculate the buffer requirement for the * Bundle** This function calculates the buffer requirement for the bundle using the * method proposed in the RFC 1990. It uses find_longest_delay_of_all_links * function to find the longest delay of all the links in the bundle. It * calculates the data rate of the channel, relative delay of the links and * calculates the slippage as dataRateOfChannel multiplied by the relativeDelay * value. The estimated buffer size is calculated as twice the sum of slippage * and local MRU of all the links in the bundle.** RETURNS: N/A*/void mp_estimate_buffer_requirement ( PFW_PLUGIN_OBJ_STATE * pMpFramingLayerState ) { UINT link_index; MP_FRAMING_LAYER_STACK_DATA * pStackData = (MP_FRAMING_LAYER_STACK_DATA *) pMpFramingLayerState->stackData ; double estimated_buffer_size; double longest_delay_of_all_links; double link_slippage; double dataRateOfChannel; double relativeDelay; ULONG link_MRU; estimated_buffer_size = 0x00000000; /* bytes */ if (if_all_the_links_are_timed (pMpFramingLayerState) == TRUE) { longest_delay_of_all_links = find_longest_delay_of_all_links (pMpFramingLayerState); } else return; for (link_index = 0x0000; link_index < pStackData->bundle.receiving_end.no_of_links; ++link_index) { relativeDelay = longest_delay_of_all_links - pStackData->bundle.receiving_end.links[link_index].delay; dataRateOfChannel = pStackData->bundle.memberLinks[link_index].speed / NUMBER_OF_BITS_IN_A_BYTE; link_slippage = dataRateOfChannel * relativeDelay; link_MRU = pStackData->bundle.receiving_end.links[link_index].localMRU; estimated_buffer_size += (link_slippage + link_MRU); } estimated_buffer_size *= 2; /* ... SHOULD allocate at least twice that. RFC 1717. p12. */ pStackData->bundle.receiving_end.buffer.estimated_size = (ULONG) estimated_buffer_size; pStackData->bundle.receiving_end.buffer.size_estimated = TRUE; printf ("MP: MP (re-)estimates the buffer size for bundle %d \ to be %ld bytes", (int) pMpFramingLayerState->stackObj, \ pStackData->bundle.receiving_end.buffer.estimated_size); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -