//
// Copyright 2003, Juan Segarra Flor
//
// This is part of videocache
//
// Videocache is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Videocache is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Foobar; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//

#include <iostream.h>
#include <stdlib.h>
#include <math.h>

/******* additional data to be shown **********************/
#define SHOWLINKUTILIZATION
//#define SHOWBATCH
#define SHOWDELAYS
//#define SHOWSTATLOAD
//#define SHOWMULTICAST
//#define SHOWADVANCEMENTS
//#define SHOWSTATISTICALREQ  //shows all request, not only the valid ones
#define SHOWDELAYTOOLONG
/**********************************************************/


#define TREE_DEPTH 2
#define CHILDREN_EACH_NODE 1
#define NUMVIDEOS 1000
#define MAXTRACES 1
#define LINK_BW 1500000 // kbps
#define USERLINK_BW 1500000  // kbps
#define USERS_EACH_NODE 50000
#define TIMESLOT 60  // seconds
#define REQPROCESSTIME 0 // timeslots (time of processing the request and performing advancements)
#define MAX_ACCEPTED_DELAY 20 // timeslots. More delay cancels the request

// reallocation
#define REDISTRTIME 720
#define DOWNSTREAM 1
#define UPSTREAM 2
//#define REALLMETHOD DOWNSTREAM // undefine to deactivate reallocation

// uncoment ONE of the following three batching techniques
#define STATICBATCH   // do always an explicit static batching
//#define DYNAMICBATCH  // do a dynamic batching (see implementation)
//  #define MEANVIDEODURATION 86.4 // min  // (dynamic bandwidth)
//  #define MEANVIDEOBW 1843.97 // kbps (dynamic bandwidth)
//  #define BATCHFUTUREREF 60 // timeslots in future (dynamic batching)
//#define CONGESTIONBATCH // do static batching only if network is congested
#define BATCHTIME 0 // timeslot units (static and congestion batching)

#define MAXTIME 1440  // minutes (1440 = 1 day)
#define REQPERDAY 1
#define MULTICAST
#define CACHESIZE 100000 // Mb
//#define INCREMENT_SIZE 0 // Mb

#define STREAMMERGING
#define SENDTOFILLLINK
#define MINTHRESHOLD 0 //960 // time of day to activate advancing [0-1440]
#define MAXTHRESHOLD 1440 //1320 // time of day to deactivate advancing [0-1440]
#define MAXDISKBW 25000//200000 // kbps used for a limit of bandwidth in each video
// seagate scsi ultra 160 wide 15K rpm: avg. 61 Mb/s = 500 Mbps

// VIDEO SENDING POLICIES
#define UNPOPULARFIRST 0
#define POPULARFIRST 1
//#define ALLPROPORTIONAL 2

// PART SENDING POLICIES
#define FIRSTPARTSFIRST 0
#define BALANCELINKS 1
#define LATESTPARTSFIRST 2
#define BALANCETRANSM 3

#define SENDALGORITHM UNPOPULARFIRST
#define PARTSENDALGORITHM FIRSTPARTSFIRST 

// function to obtain the size of each cache in Mb
long sizefunction(int treedepth,int level);

// function to calculate weight values
double weightfunction(double popularity,int duration,long rate);

#define WEIGHTEDPARTS 0
#define WEIGHTEDVIDEOS 1
#define WEIGHTEDRESERVE 2
#define WEIGHTEDRESERVE2 3

#define FILLALGORITHM WEIGHTEDPARTS


