00001 /* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */ 00002 00003 /* 00004 * Copyright 2002, Statistics Research, Bell Labs, Lucent Technologies and 00005 * The University of North Carolina at Chapel Hill 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions are met: 00009 * 00010 * 1. Redistributions of source code must retain the above copyright 00011 * notice, this list of conditions and the following disclaimer. 00012 * 2. Redistributions in binary form must reproduce the above copyright 00013 * notice, this list of conditions and the following disclaimer in the 00014 * documentation and/or other materials provided with the distribution. 00015 * 3. The name of the author may not be used to endorse or promote 00016 * products derived from this software without specific prior written 00017 * permission. 00018 * 00019 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 00020 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00021 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00022 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 00023 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00024 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00025 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00026 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 00027 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00028 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00029 * POSSIBILITY OF SUCH DAMAGE. 00030 */ 00031 00032 /* 00033 * Reference 00034 * Stochastic Models for Generating Synthetic HTTP Source Traffic 00035 * J. Cao, W.S. Cleveland, Y. Gao, K. Jeffay, F.D. Smith, and M.C. Weigle 00036 * IEEE INFOCOM 2004. 00037 * 00038 * Documentation available at http://dirt.cs.unc.edu/packmime/ 00039 * 00040 * Contacts: Michele Weigle (mcweigle@cs.unc.edu), 00041 * Kevin Jeffay (jeffay@cs.unc.edu) 00042 */ 00043 00044 #ifndef ns_packmimeOL_h 00045 #define ns_packmimeOL_h 00046 00047 #include <sys/types.h> 00048 #include <sys/stat.h> 00049 #include <stdio.h> 00050 #include <stdlib.h> 00051 #include <math.h> 00052 00053 #include "config.h" 00054 #include "random.h" 00055 #include "trafgen.h" 00056 #include "ranvar.h" 00057 00058 /* 00059 * Constant bit rate traffic source. Parameterized by interval, (optional) 00060 * random noise in the interval, and packet size. 00061 */ 00062 00063 class PackMimeOpenLoop : public TrafficGenerator { 00064 public: 00065 PackMimeOpenLoop(); 00066 virtual double next_interval(int&); 00067 //HACK so that udp agent knows interpacket arrival time within a burst 00068 int command(int argc, const char*const* argv); 00069 00070 00071 protected: 00072 virtual void start(); 00073 void init(); 00074 int size_; 00075 int seqno_; 00076 int64_t maxpkts_; 00077 00078 // statistics objects 00079 RandomVariable* pm_pac_ia_; 00080 RandomVariable* pm_pac_size_; 00081 00082 // helper methods 00083 TclObject* lookup_obj(const char* name) { 00084 TclObject* obj = Tcl::instance().lookup(name); 00085 if (obj == NULL) 00086 fprintf(stderr, "Bad object name %s\n", name); 00087 return obj; 00088 } 00089 00090 inline int lookup_rv (RandomVariable*& rv, const char* name) { 00091 if (rv != NULL) 00092 Tcl::instance().evalf ("delete %s", rv->name()); 00093 rv = (RandomVariable*) lookup_obj (name); 00094 return rv ? (TCL_OK) : (TCL_ERROR); 00095 } 00096 }; 00097 00098 #endif