📄 wfq.h~
字号:
/* * Copyright (c) 1998 The University of Bonn * All rights reserved. * * Permission to use and copy this software in source and binary forms * is hereby granted, provided that the above copyright notice, this * paragraph and the following disclaimer are retained in any copies * of any part of this software and that the University of Bonn is * acknowledged in all documentation pertaining to any such copy * or derivative work. The name of the University of Bonn may not * be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL * THE UNIVERSITY OF BONN BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */#ifndef ns_wfq_h#define ns_wfq_h#include "queue.h"#include "address.h"#include "ip.h"/* The number of hashbuckets for the classifier should be adapted to the actual simulation scenarios. */#define HASHBUCKETS 19/* A maximum of 1,000,000 flows should be enough even for the largest scenarios. */#define FLOWNUM 10000000/* * WFQClass is used to define the bandwidth that a flow receives. * The user can set the parameters 'bw_' and 'limit_' to specify the * bandwidth and the queue size (for the queue 'q_') for the flows that * are assigned to this class. */class WFQClass : public Queue { public: WFQClass(); int command(int argc, const char*const* argv); inline double get_bw() { return bw_; } inline double get_next_time() { return next_time_; } inline double get_last_time() { return last_time_; } inline void set_next_time(double time) { next_time_ = time; } inline void set_last_time(double time) { last_time_ = time; } inline int length() { return size_; } inline int limit() { return qlim_; } inline void set_limit(int limit) { qlim_ = limit; } inline void set_bw(double bw) { bw_ = bw; } void enque(Packet *p); Packet *deque(); inline Packet *head() { return q_->head(); } void calculate_next_time(); WFQClass *next_; protected: PacketQueue *q_; double bw_; double next_time_; double last_time_; int off_cmn_; int qlim_; int size_;};/* It was necessary to write a hash table class for WFQ. Otherwise, the HashClassifier in ns would have to be used, but that would slow the simulation down considerably, because one call to Tcl would be necessary for each lookup, since the lookup functions in the HashClassifier can only be called from Tcl. Depending on the flows and links in the simulation, that could mean a few thousand calls to Tcl per link per simulated second. This Hashtable does not perform any sanity checks (like trying to insert the same value twice) since it can be assumed that the Hashtable is not going to be used directly by a user in simulation scenarios, but only by other classes in ns which will perform these checks themselves. */class Hashtable { public: Hashtable(int buckets); int add(TclObject *obj); void insert(TclObject *obj, int value); void remove(int value); TclObject *lookup(int value); protected: struct node { int value; TclObject *obj; node *next; }; node **table_; int buckets_;};class WFQ : public Queue { public: WFQ(); int length(); int command(int argc, const char*const* argv);protected: int greater(double t1, double t2); void enque(Packet*); void insert(WFQClass *element); void reinsert(WFQClass *element); Packet* deque(); WFQClass *queue_list_; int off_ip_; int off_cmn_; int num_classes_; /* The number of WFQ classes in the link. */ int num_flows_; /* The number of flows bound to the WFQ classes. */ int num_drops_; /* The number of dropped non-best-effort packets */ int size_drops_; /* The sum of the sizes of the num_drops_ packets */ int wf2q_; /* Should packets from unknown flows be mapped to the best effort class 0? */ int best_effort_; /* Are non-best-effort classes able to 'borrow' bandwidth from the best-effort class? */ int borrow_; /* Are packets classified by their src id and flow id or by their priority field? */ int prio_; /* A hash classifier is used to determine which class a packet belongs to. It might make sense to have separate classifiers for src/fid classifying and for priority classifying to allow for switching between these two modes during simulation runtime, but that would be a waste of memory and will not be done unless it becomes necessary later.*/ Hashtable *hash;};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -