tcpperf.c
来自「用于嵌入式系统的TCP/IP协议栈及若干服务」· C语言 代码 · 共 96 行
C
96 行
/** Copyright (c) 1998-2001 by NETsilicon Inc.** This software is copyrighted by and is the sole property of* NETsilicon. All rights, title, ownership, or other interests* in the software remain the property of NETsilicon. This* software may only be used in accordance with the corresponding* license agreement. Any unauthorized use, duplication, transmission,* distribution, or disclosure of this software is expressly forbidden.** This Copyright notice may not be removed or modified without prior* written consent of NETsilicon.** NETsilicon, reserves the right to modify this software* without notice.** NETsilicon* 411 Waverley Oaks Road USA 781.647.1234* Suite 227 http://www.netsilicon.com* Waltham, MA 02452 AmericaSales@netsilicon.com*************************************************************************** $Name: Fusion 6.52 Fusion 6.51 $* $Date: 2001/09/20 10:21:44 $* $Source: M:/psisrc/stack/tcp/rcs/tcpperf.c $* $Revision: 1.12 $*************************************************************************** File Description: TCP - Transmission Control Protocol* Performance monitoring and optimization routines**************************************************************************/#include "std.h"#include "ip.h"#include "m.h"#include "tcp.h"#include "timer.h"#include "debug.h"#include "fnsproto.h"#define MIN_PERF_BYTES 8000 /* min # of bytes in a sample */#define MAX_PERF_INTERVAL 2000L /* max sampling interval */#define RETRY_SAMPLES 16 /* # of stable samples before forced * attempt to optimize again */local void tcp_sqadjust(tcpsv_t * svp);import u32 tcp_sq_max;/* periodic timer to sample performance and make improvements */export int tcp_perftimer (void * uarg){#define lsvp ((tcpsv_t *)uarg) int last_int; use_critical; critical; last_int = (int)(t_clicks - lsvp->sv_rsclicks); if ( lsvp->sv_sqcntdwn > 0 && (lsvp->sv_sqcntdwn -= last_int) <= 0 ) tcp_sqadjust(lsvp); lsvp->sv_rsclicks = t_clicks; normal; return 0;}/* tcp_sqadjust is called periodically following an attack of Source Quench * on a socket. The send queue max is gradually increased back to the * maximum allowed, as long as we don't get SQ'd again. The only reason * this code is in this module is that it is sort of a performance issue, * and the performance timer is a convenient mechanism to time the sq max * regrowth. */local void tcp_sqadjust (fast tcpsv_t * svp){ int new_sq_max; fast so_t * sop; sop = sv_valid_sop(svp, sop); if (!sop) return; new_sq_max = (&sop->so_sq)->gq_max << 1; if ( (new_sq_max = min(new_sq_max, (int)tcp_sq_max)) == (int)tcp_sq_max ) { /* Back to normal for now */ svp->sv_sqcntdwn = 0; } else /* Schedule next increase in one minute */ svp->sv_sqcntdwn = 60000 / MS_PER_TICK; gq_max_set(&sop->so_sq, new_sq_max);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?