00001 /* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- 00002 * 00003 * Copyright (C) 2004 by USC/ISI 00004 * 00005 * All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms are permitted 00008 * provided that the above copyright notice and this paragraph are 00009 * duplicated in all such forms and that any documentation, advertising 00010 * materials, and other materials related to such distribution and use 00011 * acknowledge that the software was developed by the University of 00012 * Southern California, Information Sciences Institute. The name of the 00013 * University may not be used to endorse or promote products derived from 00014 * this software without specific prior written permission. 00015 * 00016 * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED 00017 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 00018 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00019 * 00020 * The copyright of this module includes the following 00021 * linking-with-specific-other-licenses addition: 00022 * 00023 * In addition, as a special exception, the copyright holders of 00024 * this module give you permission to combine (via static or 00025 * dynamic linking) this module with free software programs or 00026 * libraries that are released under the GNU LGPL and with code 00027 * included in the standard release of ns-2 under the Apache 2.0 00028 * license or under otherwise-compatible licenses with advertising 00029 * requirements (or modified versions of such code, with unchanged 00030 * license). You may copy and distribute such a system following the 00031 * terms of the GNU GPL for this module and the licenses of the 00032 * other code concerned, provided that you include the source code of 00033 * that other code when and as the GNU GPL requires distribution of 00034 * source code. 00035 * 00036 * Note that people who make modified versions of this module 00037 * are not obligated to grant this special exception for their 00038 * modified versions; it is their choice whether to do so. The GNU 00039 * General Public License gives permission to release a modified 00040 * version without this exception; this exception also makes it 00041 * possible to release a modified version which carries forward this 00042 * exception. 00043 * 00044 * @(#) $Header: /cvsroot/nsnam/ns-2/xcp/xcp.h,v 1.9 2006/05/30 20:30:30 pradkin Exp $ 00045 */ 00046 00047 #ifndef NS_XCP 00048 #define NS_XCP 00049 00050 #include "packet.h" 00051 #include "queue.h" 00052 #include "xcpq.h" 00053 00054 00055 enum {XCPQ=0, TCPQ=1, OTHERQ=2, MAX_QNUM}; 00056 00057 // code points for separating XCP/TCP flows 00058 #define CP_XCP 10 00059 #define CP_TCP 20 00060 #define CP_OTHER 30 00061 00062 00063 class XCPWrapQ : public Queue { 00064 public: 00065 XCPWrapQ(); 00066 int command(int argc, const char*const* argv); 00067 void recv(Packet*, Handler*); 00068 00069 protected: 00070 Queue *q_[MAX_QNUM]; 00071 00072 XCPQueue *xcpq_; // same as q_[XCPQ] 00073 00074 unsigned int routerId_; 00075 00076 int qToDq_; // current queue being dequed 00077 double wrrTemp_[MAX_QNUM]; // state of queue being serviced 00078 double queueWeight_[MAX_QNUM]; // queue weight for each queue (dynamic) 00079 00080 int spread_bytes_; 00081 bool tcp_xcp_on_; // true if XCP/TCP sharing is enables 00082 00083 // Modified functions 00084 virtual void enque(Packet* pkt); // high level enque function 00085 virtual Packet* deque(); // high level deque function 00086 00087 void addQueueWeights(int queueNum, int weight); 00088 int queueToDeque(); // returns qToDq 00089 int queueToEnque(int codePt); // returns queue based on codept 00090 void mark(Packet *p); // marks pkt based on flow type 00091 int getCodePt(Packet *p); // returns codept in pkt hdr 00092 void setVirtualQueues(); // setup virtual queues(for xcp/tcp) 00093 }; 00094 00095 #endif //NS_XCP