⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 classifier-edge.cc

📁 obs网络试验平台
💻 CC
字号:
/* Copyright (c) University of Maryland, Baltimore County, 2003. * Original Authors: Ramakrishna Shenai, Sunil Gowda and Krishna Sivalingam. * * This software is developed at the University of Maryland, Baltimore County under * grants from Cisco Systems Inc and the University of Maryland, Baltimore County. * * Permission to use, copy, modify, and distribute this software and its * documentation in source and binary forms for non-commercial purposes * and without fee is hereby granted, provided that the above copyright * notice appear in all copies and that both the copyright notice and * this permission notice appear in supporting documentation. and that * any documentation, advertising materials, and other materials related * to such distribution and use acknowledge that the software was * developed by the University of Maryland, Baltimore County.  The name of * the University may not be used to endorse or promote products derived from * this software without specific prior written permission. * * Copyright (C) 2000-2003 Washington State University. All rights reserved. * This software was originally developed at Alcatel USA and subsequently modified * at Washington State University, Pullman, WA  through research work which was * supported by Alcatel USA, Inc and Cisco Systems Inc. * The  following notice is in adherence to the Washington State University * copyright policy follows. * * License is granted to copy, to use, and to make and to use derivative * works for research and evaluation purposes, provided that Washington * State University is acknowledged in all documentation pertaining to any such * copy or derivative work. Washington State University grants no other * licenses expressed or implied. The Washington State University name * should not be used in any advertising without its written permission. * * WASHINGTON STATE UNIVERSITY MAKES NO REPRESENTATIONS CONCERNING EITHER * THE MERCHANTABILITY OF THIS SOFTWARE OR THE SUITABILITY OF THIS SOFTWARE * FOR ANY PARTICULAR PURPOSE.  The software is provided "as is" *  without express or implied warranty of any kind. These notices must * be retained in any copies of any part of this software. */#include "classifier-edge.h"#include "nodetrace.h"#include "address.h"#include "../common/stat-collector.h"/* Implementation of the edge classifier which is the entry_ * destination in the edge node. Edge classifier directs * incoming TCP/IPKT packets to an appropriates destination * or Edge port-classifier (see portclassifier-edge) object. * all performs scheduling of DBs * * version 2.0 07/12/2003 *///Constructor -- added by GMGEdgeClassifier:: EdgeClassifier() : BaseClassifier(){     bind ("bhpProcTime", &proc_time_);}//GMG -- added method to set size of electronic buffer for each priority//       class.  Invoked by OTcl method to set buffer size for each//       priority class.void EdgeClassifier::SetBufSize (int j, double bufsize){     char s[200];     if (j < 0 || j >= nqos_classes)     {        sprintf (s, "Invalid QoS class %d specified in setting edge classifier electronic buffer size", j);        Debug::debug(s);        exit(1);     }     bufsize_[j] = bufsize;}// recv methodvoid EdgeClassifier::recv( Packet *pkt, Handler *h = 0 ){    char s[100];    int tt;  // GMG -- added data packet type, for nodetrace             //        ('s' (send) or 'r' (receive) )    char* nodeaddress;  //GMG -- added node address for nodetrace    if( address_ == -1  || pkt == NULL ) {        Debug::debug( __FILE__, __LINE__, "address is invalid (or) packet could be NULL" );        exit( -1);    }    hdr_cmn *ch = hdr_cmn::access( pkt );    hdr_ip *iph = hdr_ip::access( pkt );    hdr_IPKT *ipkt = hdr_IPKT::access( pkt );    int des_addr = mshift( iph->daddr() );    if( ( ch->ptype() == PT_IPKT ) ){        if( des_addr == address_ ) {            // Debug::debug( "EdgeClassifier: recd IPKT at destination" );            //GMG -- we alter the statement below.  If this is            //the destination and the IPKT is a DB, then we need to add            //the DB trans delay and schedule it to go the the edge port            //classifier tx delay later.  For a BHP, it can go immediately,            //as teh tx delay was included in the link delay for BHP.            if (iph->prio_ == 1) // BHP               slot_[address_]->recv( pkt );            else            {               double sendTime = ipkt->tx_delay_;               Scheduler::instance().schedule( slot_[address_], pkt,                                                  sendTime);            }        }        else {            if( iph->prio_ == 1 )  {            //GMG -- added code to increment electronic buffer fill or,            //       if bufsize exceeded, to drop BHP and collect            //       statistics (note: need not drop DB here; when DB is            //       attempted to be sent, it will not be found in lookup            //       switch and will be dropped then                double newbuf = buffill_[ipkt->prio_] +                                                 ipkt->C_burst_size();                if (newbuf > bufsize_[ipkt->prio_])                {                   StatCollector &sc = StatCollector::instance();                   sc.updateEntry ("BHPDROP", sc.getValue("BHPDROP")+1.0 );                   drop(pkt);                   return;                }                else // increment elecronic buffer size                {                   buffill_[ipkt->prio_] = newbuf;                   handleControlPacket( pkt );                }            }            else if( iph->prio_ == 2 )  {                handleDataBurst( pkt );            }        }    }    else {        // sprintf( s, "recd a packet of type: %d", ch->ptype() );        // Debug::debug( s );        // GMG -- added node trace below        if (NodeTrace::trace_on_)        {           if (des_addr == address_)  //receive data packet              tt = 'r';           else              tt = 's';   	nodeaddress = Address::instance().print_nodeaddr(address_);           NodeTrace::format (tt, nodeaddress, pkt);           NodeTrace::dump ();           delete [] nodeaddress;        }        slot_[address_]->recv( pkt );    }}// Edge classifier class defnstatic class EdgeClassifierClass : public TclClass{    public:        EdgeClassifierClass() : TclClass( "Classifier/BaseClassifier/EdgeClassifier" ) {;}        TclObject* create( int, const char*const* ) {            return( new EdgeClassifier() );        }        virtual void bind();        virtual int method ( int argc, const char*const*argv );}class_EdgeClassifier;void EdgeClassifierClass::bind() {           TclClass::bind();           add_method ("ebuffersize");}// methodint EdgeClassifierClass::method( int ac, const char*const* av ){	  Tcl& tcl = Tcl::instance();    int argc = ac-2;    const char*const* argv = av + 2;    if( argc == 4 )    {        if( strcmp( argv[1], "ebuffersize" ) == 0 )        {            EdgeClassifier::SetBufSize ( atoi(argv[2]), atof(argv[3]) );            return (TCL_OK);	        }    }    return TclClass::method( ac, av );}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -