📄 fiber-delay.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. */#ifndef lintstatic const char rcsid[] = "@(#) $Header: /home/bwen/src/ns/ns-2/fiber-delay.cc,v 1.3 2000/09/01 04:22:44 bwen Exp $ (LBL)";#endif#include "fiber-delay.h"static class OBSFiberLinkDelayClass : public TclClass {public: OBSFiberLinkDelayClass() : TclClass("OBSFiberDelayLink") {} TclObject* create(int /* argc */, const char*const* /* argv */) { return (new OBSFiberLinkDelay()); }} class_fiber_delay_link;OBSFiberLinkDelay::OBSFiberLinkDelay() { bind("wvlen_num_", &wvlen_num_); bind("FDLdelay", &FDL_delay_);}void OBSFiberLinkDelay::recv(Packet* p, Handler* h){ double txt = txtime_fiber(p); double link_service_time; Scheduler& s = Scheduler::instance(); int prio; if (dynamic_) { Event* e = (Event*)p; e->time_= txt + delay_; itq_->enque(p); // for convinience, use a queue to store packets in // transit s.schedule(this, p, txt + delay_); } else //GMG -- changed this part of the function, to calc link service // time as prop del for DB, but prop+trans del for BCP (since // DB "cuts through" the node, while BCP is buffered and processed. // Note that a single DB trans del must be added at final edge node; // this is done separately and is not part of link serv time. // Also added potential FDL at end of link for DB { Debug::markTr( 1000, p ); hdr_ip *iph = hdr_ip::access (p); hdr_IPKT *ipkt = hdr_IPKT::access (p); ipkt->tx_delay_ = txt; //GMG - use this field // of the IPKT header // to store the trans delay so it is // accessible to the next node, which will // need the value. This is purely a // mechanism for the simulator; it is // much easier than having the next node // figure out which link object to get this // value from. if (iph->prio_ == 1) //BHP; set link service time = trans + prop del { link_service_time = txt + delay_; ipkt->FDL_delay_ = FDL_delay_; //GMG - use the FDL_delay_ field // of the IPKT header // to store the FDL delay so it is easily // accessible to the next node, which will // need the value. This is purely a // mechanism for the simulator; it is // much easier than having the next node // figure out which link object to get this // value from. } else //DB; set link service time = prop del + FDL at end of link. //Also, check whether to decrement ingress node electronic // buffer fill { if (ipkt->ebuf_ind) { prio = ipkt->prio_; ipkt->bc_ingress->bufsize_[prio] -= ipkt->C_burst_size(); ipkt->ebuf_ind = 0; } link_service_time = delay_ + FDL_delay_; } s.schedule(target_, p, link_service_time); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -