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

📄 aggcbqegress-est.cc.cc

📁 在网络的边缘路由器中并不能完全接受所到的包
💻 CC
📖 第 1 页 / 共 2 页
字号:

#include "aggcbqegress-est.h"

double AggCbqEgress_Est::arrivalenvelope0[17][2];
double AggCbqEgress_Est::serviceenvelope0[17][2];
double AggCbqEgress_Est::arrivalenvelope1[17][2];
double AggCbqEgress_Est::serviceenvelope1[17][2];

//creating a circular list for storing the maxarrivaltime and minservicetime for every second
//for the last 10seconds

struct maxmintimelist0
{
  double maxminarrayoftime0[17][2];
  maxmintimelist0* next;
};
typedef struct maxmintimelist0 maxmintimelist0;

maxmintimelist0 *headoflist0,*tailoflist0,*navigatelist0,*nodeoflist0;

struct maxmintimelist1
{
  double maxminarrayoftime1[17][2];
  maxmintimelist1* next;
};
typedef struct maxmintimelist1 maxmintimelist1;

maxmintimelist1 *headoflist1,*tailoflist1,*navigatelist1,*nodeoflist1;

static class AggCbqEgress_EstClass : public TclClass {
public:
	AggCbqEgress_EstClass() : TclClass("Est/AggCbqEgress") {}
	TclObject* create(int, const char*const*) {
		return (new AggCbqEgress_Est());
	}
} class_aecbq_est;

AggCbqEgress_Est::AggCbqEgress_Est() {

	/* assume period_, T_ and M_ get set in Tcl */
        bind("lifetimeofflow_", &lifetimeofflow_);
        bind("simulationtime_", &simulationtime_);
        bind("T_", &T_);
	bind("M_", &M_);
}

void AggCbqEgress_Est::createmaxmintimelist0(double a[][2])
{
    nodeoflist0 = (maxmintimelist0*)malloc(sizeof(maxmintimelist0));
    for(int i = 0;i < 17;i++)
    {
       nodeoflist0->maxminarrayoftime0[i][0] = a[i][0];
       nodeoflist0->maxminarrayoftime0[i][1] = a[i][1];
    }
    nodeoflist0->next = NULL;
    
    headoflist0 = headoflist0->next;
    free(tailoflist0->next);
    tailoflist0->next = nodeoflist0;
    tailoflist0 = tailoflist0->next;
    tailoflist0->next = headoflist0;
}

void AggCbqEgress_Est::createmaxmintimelist1(double a[][2])
{
    nodeoflist1 = (maxmintimelist1*)malloc(sizeof(maxmintimelist1));
    for(int i = 0;i < 17;i++)
    {
       nodeoflist1->maxminarrayoftime1[i][0] = a[i][0];
       nodeoflist1->maxminarrayoftime1[i][1] = a[i][1];
    }
    nodeoflist1->next = NULL;
        
    headoflist1 = headoflist1->next;
    free(tailoflist1->next);
    tailoflist1->next = nodeoflist1;
    tailoflist1 = tailoflist1->next;
    tailoflist1->next = headoflist1;
}

void AggCbqEgress_Est::initializemaxminlist0(void)
{
  int p;
  int q;
  headoflist0 = NULL;
  tailoflist0 = NULL;
  navigatelist0 = NULL;
  nodeoflist0 = NULL;
  for(p = 0;p < 10;p++)
  {
      nodeoflist0 = (maxmintimelist0*)malloc(sizeof(maxmintimelist0));
      for(q = 0;q < 17;q++)
      {
         nodeoflist0->maxminarrayoftime0[q][0] = 0.0;
         nodeoflist0->maxminarrayoftime0[q][1] = 0.0;
      }   
      nodeoflist0->next = NULL;
        
      if(headoflist0==NULL)
      {
         headoflist0 = nodeoflist0;
         tailoflist0 = nodeoflist0;
         navigatelist0 = nodeoflist0;
      }
      else
      {
         navigatelist0->next = nodeoflist0;
         navigatelist0 = navigatelist0->next;
         tailoflist0 = navigatelist0;
      }
  }
  tailoflist0->next = headoflist0;
}       

void AggCbqEgress_Est::initializemaxminlist1(void)
{
  int p;
  int q;
  headoflist1 = NULL;
  tailoflist1 = NULL;
  navigatelist1 = NULL;
  nodeoflist1 = NULL;
  for(p = 0;p < 10;p++)
  {
      nodeoflist1 = (maxmintimelist1*)malloc(sizeof(maxmintimelist1));
      for(q = 0;q < 17;q++)
      {
         nodeoflist1->maxminarrayoftime1[q][0] = 0.0;
         nodeoflist1->maxminarrayoftime1[q][1] = 0.0;
      }
      nodeoflist1->next = NULL;   
 
      if(headoflist1 == NULL)
      {
         headoflist1 = nodeoflist1;
         tailoflist1 = nodeoflist1;
         navigatelist1 = nodeoflist1;
      }  
      else
      {
         navigatelist1->next = nodeoflist1;
         navigatelist1 = navigatelist1->next;
         tailoflist1 = navigatelist1;
      }
  }
  tailoflist1->next = headoflist1;
}



void AggCbqEgress_Est::printmaxmintimelist0(void)
{
   navigatelist0 = headoflist0;
   int j = 0;
   int i;
   while (navigatelist0->next != headoflist0)
   {
      printf("The list for table %d is ------------------- \n",j);
      for(i = 0; i < 17; i++)
      {
        printf(" Row %d --------- arrivaltime %f         servicetime
%f\n",i,navigatelist0->maxminarrayoftime0[i][0],navigatelist0->maxminarrayoftime0[i][1]); 
      }
      navigatelist0 = navigatelist0->next;
      j++;
   }
   
   if(navigatelist0->next == headoflist0)
   {
      printf("The list for table %d is ------------------- \n",j);
      for(i = 0; i < 17; i++)
      {
        printf(" Row %d --------- arrivaltime %f         servicetime
%f\n",i,navigatelist0->maxminarrayoftime0[i][0],navigatelist0->maxminarrayoftime0[i][1]);
       }
    }
}

void AggCbqEgress_Est::printmaxmintimelist1(void)
{         
   navigatelist1 = headoflist1;
   int j = 0;
   int i;
   while (navigatelist1->next != headoflist1)
   {   
      printf("The list for table %d is ------------------- \n",j);  
      for(i = 0; i < 17; i++)
      { 
        printf(" Row %d --------- arrivaltime %f         servicetime
%f\n",i,navigatelist1->maxminarrayoftime1[i][0],navigatelist1->maxminarrayoftime1[i][1]);
      }
      navigatelist1 = navigatelist1->next;
      j++;
   }
          
   if(navigatelist1->next == headoflist1)
   {     
      printf("The list for table %d is ------------------- \n",j);
      for(i = 0; i < 17; i++)
      {
        printf(" Row %d --------- arrivaltime %f         servicetime
%f\n",i,navigatelist1->maxminarrayoftime1[i][0],navigatelist1->maxminarrayoftime1[i][1]);
       }
    }
}

void AggCbqEgress_Est::extractarrivalservicetimesintoarray()
{
     temp = Trace::measure;

     // extracting the arrival and service times for the packets into an array for computing  

     int count = Trace::snoopqueuecount;

     printf("\n The number of packets which arrived in the 1sec interval are %d \n",count);
 
     int i;
     int ii;
     int ii1 = 0;
     int ii2 = 0;

     for(i=0;i <= count;i++)
     {
 
       if(temp[i].getclassofpacket() == 0)
       {
          arrayoftimes0[ii1][0] = temp[i].getarrivaltime();
          arrayoftimes0[ii1++][1] = temp[i].getservicetime();
       }
       else 
       {
         if(temp[i].getclassofpacket() == 1)
         {
           arrayoftimes1[ii2][0] = temp[i].getarrivaltime();
           arrayoftimes1[ii2++][1] = temp[i].getservicetime();
         } 
       }
     }

     for(ii = ii1;ii < NUMOFPACKS;ii++)
     {
       arrayoftimes0[ii][0] = 0.0;
       arrayoftimes0[ii][1] = 0.0;
       
     }

     for(ii = ii2;ii < NUMOFPACKS;ii++)
     {
       arrayoftimes1[ii][0] = 0.0;
       arrayoftimes1[ii][1] = 0.0;
     }
 
     //for(i = 0;i <= ii1;i++)
     //{
     //  printf(" row %d ------ arrivaltime = %f    servicetime = %f\n",i,arrayoftimes0[i][0],arrayoftimes0[i][1]);
     //}

     //for(i = 0;i <= ii2;i++)
     //{ 
     //  printf(" row %d ------ arrivaltime = %f    servicetime = %f\n",i,arrayoftimes1[i][0],arrayoftimes1[i][1]);
     //} 

     // end of extracting
}

void AggCbqEgress_Est::computationofminarrivalmaxservicetimes0()
{ 
   int i;
   int p;
   int j;
   int k;
   int flag;
   double minarrivaltime;
   double maxservicetime;

   //--------- computation of minimum arrival time ------------
 
   p = 0;
   j = 0; 
   while(p < 17)
   {
      // The variable j keeps track of how many packets to consider....i.e 1k,2k,4k....
      j = (int)pow(2,p);
      minarrivaltime = 9999;
      for(i = 0; i < NUMOFPACKS-j; i++)
      {
         if(arrayoftimes0[i+j][0] == 0.0)
         {
             break;
         }
         temparrivaltime = arrayoftimes0[i+j][0] - arrayoftimes0[i][0];
         if(minarrivaltime > temparrivaltime)
         {
            minarrivaltime = temparrivaltime;
         }
      }
      maxmintimes0[p][0] = minarrivaltime;
      p++;
    }

    // ---------- end of computation of minimum arrival time -------

    //----------- computation of maximum service time -------------

    p = 0;
    j = 0;
    
    while(p < 17)
    {
       //printf("\n in side the while loop the value of p is %d \n",p);

       j = (int)pow(2,p) - 1;
       maxservicetime = 0.0;

       // this for loop is to extract the max servicetime for packets
       // of size 2 to the power p

       for(i = 0; i < NUMOFPACKS - j; i++)
       {
          if(arrayoftimes0[i+j][1] == 0)
          {
             break;
          }
          k = j;
          flag = 0;

          tempservicetime = arrayoftimes0[i+k][1] - arrayoftimes0[i][0];

          //this tempservicetime should be considered only if there is
          //backlog in the network for (pow(2,p) - 1) packets

          while(k != 0)
          {
             if(arrayoftimes0[i+k][0] < arrayoftimes0[i+k-1][1])
             {
                flag = 1;
             }
             else
             {
                flag = 0;
                break; 
             }
             k--;
          }//end of the while for k

          if(j == 0)
          {   
            flag = 1;
          }   
          if(flag == 1)  
          {
             if(maxservicetime < tempservicetime)
             {   
                maxservicetime = tempservicetime;
             }
          }
       }//end of the for loop for i
           
       maxmintimes0[p][1] = maxservicetime;
       p++;
   }//end of the while for p

  //------------ end of computation --------------------

}

void AggCbqEgress_Est::computationofminarrivalmaxservicetimes1()
{ 
   int i;
   int p;
   int j;
   int k;
   int flag;
   double minarrivaltime;
   double maxservicetime;

   //--------- computation of minimum arrival time ------------
 
   p = 0;
   j = 0; 
   while(p < 17)
   {
      // The variable j keeps track of how many packets to consider....i.e 1k,2k,4k....
      j = (int)pow(2,p);
      minarrivaltime = 9999;
      for(i = 0; i < NUMOFPACKS-j; i++)
      {
         if(arrayoftimes1[i+j][0] == 0.0)
         {
             break;
         }
         temparrivaltime = arrayoftimes1[i+j][0] - arrayoftimes1[i][0];
         if(minarrivaltime > temparrivaltime)
         {
            minarrivaltime = temparrivaltime;
         }
      }
      maxmintimes1[p][0] = minarrivaltime;
      p++;
    }

    // ---------- end of computation of minimum arrival time -------

    //----------- computation of maximum service time -------------

    p = 0;
    j = 0;
    
    while(p < 17)
    {
       //printf("\n in side the while loop the value of p is %d \n",p);

       j = (int)pow(2,p) - 1;
       maxservicetime = 0.0;

       // this for loop is to extract the max servicetime for packets
       // of size 2 to the power p

       for(i = 0; i < NUMOFPACKS - j; i++)
       {
          if(arrayoftimes1[i+j][1] == 0)
          {
             break;
          }
          k = j;
          flag = 0;

          tempservicetime = arrayoftimes1[i+k][1] - arrayoftimes1[i][0];

          //this tempservicetime should be considered only if there is
          //backlog in the network for (pow(2,p) - 1) packets

          while(k != 0)
          {
             if(arrayoftimes1[i+k][0] < arrayoftimes1[i+k-1][1])
             {
                flag = 1;
             }
             else
             {
                flag = 0;
                break; 
             }
             k--;
          }//end of the while for k

          if(j == 0)
          {   
            flag = 1;
          }   
          if(flag == 1)  
          {
             if(maxservicetime < tempservicetime)
             {   
                maxservicetime = tempservicetime;
             }
          }
       }//end of the for loop for i
           
       maxmintimes1[p][1] = maxservicetime;
       p++;
   }//end of the while for p

⌨️ 快捷键说明

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