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

📄 tcpbuffer.cc

📁 COPE the first practical network coding scheme which is developped on click
💻 CC
字号:
/* * tcpbuffer.{cc,hh} -- provides a TCP buffer * Benjie Chen * * Copyright (c) 2001 Massachusetts Institute of Technology * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, subject to the conditions * listed in the Click LICENSE file. These conditions include: you must * preserve this copyright notice, and you cannot mention the copyright * holders in advertising related to the Software without their permission. * The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This * notice is a summary of the Click LICENSE file; the license in that file is * legally binding. */#include <click/config.h>#include <click/confparse.hh>#include <clicknet/ip.h>#include <clicknet/tcp.h>#include "tcpbuffer.hh"CLICK_DECLSTCPBuffer::TCPBuffer()  : Element(1, 1), _chain(0){}TCPBuffer::~TCPBuffer(){}intTCPBuffer::configure(Vector<String> &conf, ErrorHandler *errh){  _skip = false;  return cp_va_parse(conf, this, errh,                      cpOptional, cpBool, "skip missing packets", &_skip, cpEnd);}intTCPBuffer::initialize(ErrorHandler *){  _start_push = false;  _start_pull = false;  return 0;}voidTCPBuffer::cleanup(CleanupStage){  TCPBufferElt *elt = _chain;  while (elt) {    TCPBufferElt *t = elt;    elt = elt->next();    Packet *p = t->kill_elt();    p->kill();  }  assert(_chain == 0);}voidTCPBuffer::push(int, Packet *p){  unsigned sn = seqno(p);  if (!_start_push)    _initial_seq = sn;  else if (_start_pull && SEQ_LT(sn,_first_seq)) {    p->kill();    return;  }  new TCPBufferElt(&_chain, p);}voidTCPBuffer::dump(){  click_chatter("seq0 %u, seq %u", _initial_seq, _first_seq);  TCPBufferElt *elt = _chain;  while(elt) {    Packet *pp = elt->packet();    click_chatter("elt %p (%p): %u", elt, pp, seqno(pp));    elt = elt->next();  }}Packet *TCPBuffer::pull(int){  if (_chain) {    Packet *p = _chain->packet();    if (!_start_pull || _skip || seqno(p)==_first_seq) {      _chain->kill_elt();      _first_seq = seqno(p) + seqlen(p);      _start_pull = true;      return p;    }  }  return 0;}CLICK_ENDDECLSEXPORT_ELEMENT(TCPBuffer)

⌨️ 快捷键说明

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