Log In
New Account
  
 
Home My Page Project Tree Code Snippets Project Openings NUTSS
 
 
Summary Tracker Lists CVS Files
 

CVS | Administration

Diff for /libnutss/examples/slinks_variable_load.c between versions 1.19 and 1.20

version 1.19, 2007/07/10 03:21:17 version 1.20, 2007/07/11 04:31:46
Line 15 Line 15
   
 #define randint(N) ((int)(rand() / (((double)RAND_MAX + 1) / (N))))  #define randint(N) ((int)(rand() / (((double)RAND_MAX + 1) / (N))))
 #define assert(p) if(!(p)) { printf("Assertion '%s' FAILED!\n", #p); exit(1); }  #define assert(p) if(!(p)) { printf("Assertion '%s' FAILED!\n", #p); exit(1); }
#defineredundancy 5 #defineREDUNDANCY (4*(100/percent))
 
 int count_char(char*,char);
   
 typedef struct flow {  typedef struct flow {
     int duration;      int duration;
Line 39  void *recvthread(void *arg) {  Line 41  void *recvthread(void *arg) { 
     buf[0] = 0;      buf[0] = 0;
   
     while(time < limit) {      while(time < limit) {
        sleep(1);  
        if(swaplinks_recvfrom(swp, tmp, sizeof(tmp), 0, &peer, &len) > 0) {         if(swaplinks_recvfrom(swp, tmp, sizeof(tmp), 0, &peer, &len) > 0) {
       time++; delta = 0;        time++; delta = 0;
       // parse new flow        // parse new flow
Line 125  void *recvthread(void *arg) {  Line 126  void *recvthread(void *arg) { 
 int main(int argc, char **argv) {  int main(int argc, char **argv) {
     struct sockaddr_ns reg;      struct sockaddr_ns reg;
     char tmp[256], nbrs[4096];      char tmp[256], nbrs[4096];
   int time = 0, duration, weight,sendcount = 0;    int time = 0, duration, weight,percent, sendcount = 0;
     pthread_t tid;      pthread_t tid;
   
     if (argc > 6) {      if (argc > 6) {
         num = atoi(argv[1]);          num = atoi(argv[1]);
         peers = atoi(argv[2]);          peers = atoi(argv[2]);
         limit = atoi(argv[3]);          limit = atoi(argv[3]);
       duration = atoi(argv[4]);        percent = atoi(argv[4]);
       weight = atoi(argv[5]);        duration = atoi(argv[5]);
       maxload = atoi(argv[6]);        weight = atoi(argv[6]);
         maxload = atoi(argv[7]);
     }      }
     else {      else {
       printf("Usage:\n  slinks_variable_load node_number peers_number time_limitflow_duration flow_weight max_load\n");        printf("Usage:\n  slinks_variable_load node_number peers_number time_limitpercent_to_send flow_duration flow_weight max_load\n");
         exit(1);          exit(1);
     }      }
   
Line 164  int main(int argc, char **argv) {  Line 166  int main(int argc, char **argv) { 
   
     swaplinks_init();      swaplinks_init();
   
   sleep(randint(10)); //    sleep(randint(5));
   
     swp = swaplinks_new("cloud9", &reg, peers, peers);      swp = swaplinks_new("cloud9", &reg, peers, peers);
   
Line 173  int main(int argc, char **argv) {  Line 175  int main(int argc, char **argv) { 
   
     pthread_create(&tid, NULL, recvthread, swp);      pthread_create(&tid, NULL, recvthread, swp);
   
   sleep(2); //    sleep(2);
   
     snprintf(tmp, sizeof(tmp), "%d;%d;0;", duration, weight);      snprintf(tmp, sizeof(tmp), "%d;%d;0;", duration, weight);
   
   while (time++ <redundancy*limit) { // (i-- != 0) {    while (time++ <REDUNDANCY*limit) { // (i-- != 0) {
swaplinks_sendtoany(swp, tmp, strlen(tmp)+1, 0); if(randint(100) < percent) swaplinks_sendtoany(swp, tmp, strlen(tmp)+1, 0);
//if(s) fprintf(s,"   %d sent request %d\n",num,time); //if(s) fprintf(s,"   %d sent request %d\n",num,time);
         swaplinks_get_neighbors(swp, nbrs, 4096);          swaplinks_get_neighbors(swp, nbrs, 4096);
       if(g) fprintf(g,"%s\n --- \n",nbrs);        if(g) fprintf(g,"%d\n",count_char(nbrs,','));
       sleep(2);        nbrs[0] = 0;
         sleep(1);
     }      }
   
       if(s) fprintf(s,"%d DONE SENDING\n",num);    if(g) fclose(g);
   if(s) fprintf(s,"%d DONE SENDING\n",num);
       pthread_join(tid, NULL);    pthread_join(tid, NULL);
 
     if(s) fprintf(s,"%d SHUTTING DOWN\n",num);      if(s) fprintf(s,"%d SHUTTING DOWN\n",num);
   
   if(num == 1) system("echo \" \" | mail -s\"node one finished sending!\" ths22@cs.cornell.edu"); //    if(num == 1) system("echo \" \" | mail -s\"node one finished sending!\" ths22@cs.cornell.edu");
   
     return 0;      return 0;
 }  }
   
   int count_char(char *s, char h) {
       int i, l = strlen(s), c = 0;
       for(i = 0; i < l; i++)
           if(s[i] == h) c++;
       return c;
   }

Removed from v.1.19  
changed lines
  Added in v.1.20


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>
 

GForge.cis.cornell.edu is brought to you by

Cornell Computing and Information Science


Powered By GForge Collaborative Development Environment