gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r1684 - in GNUnet/src: applications/tbench server


From: grothoff
Subject: [GNUnet-SVN] r1684 - in GNUnet/src: applications/tbench server
Date: Sun, 14 Aug 2005 23:58:34 -0700 (PDT)

Author: grothoff
Date: 2005-08-14 23:58:32 -0700 (Sun, 14 Aug 2005)
New Revision: 1684

Modified:
   GNUnet/src/applications/tbench/peer1.conf
   GNUnet/src/applications/tbench/peer1udp.conf
   GNUnet/src/applications/tbench/peer2.conf
   GNUnet/src/applications/tbench/peer2udp.conf
   GNUnet/src/applications/tbench/tbench.c
   GNUnet/src/server/connection.c
   GNUnet/src/server/handler.c
Log:
sync

Modified: GNUnet/src/applications/tbench/peer1.conf
===================================================================
--- GNUnet/src/applications/tbench/peer1.conf   2005-08-15 06:58:23 UTC (rev 
1683)
+++ GNUnet/src/applications/tbench/peer1.conf   2005-08-15 06:58:32 UTC (rev 
1684)
@@ -25,8 +25,8 @@
 [LOAD]
 INTERFACES          = eth0
 BASICLIMITING       = YES
-MAXNETUPBPSTOTAL    = 50000
-MAXNETDOWNBPSTOTAL  = 50000
+MAXNETUPBPSTOTAL    = 50000000
+MAXNETDOWNBPSTOTAL  = 50000000
 MAXCPULOAD         = 100
 
 [TCP]

Modified: GNUnet/src/applications/tbench/peer1udp.conf
===================================================================
--- GNUnet/src/applications/tbench/peer1udp.conf        2005-08-15 06:58:23 UTC 
(rev 1683)
+++ GNUnet/src/applications/tbench/peer1udp.conf        2005-08-15 06:58:32 UTC 
(rev 1684)
@@ -25,8 +25,8 @@
 [LOAD]
 INTERFACES          = eth0
 BASICLIMITING       = YES
-MAXNETUPBPSTOTAL    = 50000
-MAXNETDOWNBPSTOTAL  = 50000
+MAXNETUPBPSTOTAL    = 50000000
+MAXNETDOWNBPSTOTAL  = 50000000
 MAXCPULOAD         = 100
 
 [TCP]

Modified: GNUnet/src/applications/tbench/peer2.conf
===================================================================
--- GNUnet/src/applications/tbench/peer2.conf   2005-08-15 06:58:23 UTC (rev 
1683)
+++ GNUnet/src/applications/tbench/peer2.conf   2005-08-15 06:58:32 UTC (rev 
1684)
@@ -25,8 +25,8 @@
 [LOAD]
 INTERFACES          = eth0
 BASICLIMITING       = YES
-MAXNETUPBPSTOTAL    = 50000
-MAXNETDOWNBPSTOTAL  = 50000
+MAXNETUPBPSTOTAL    = 50000000
+MAXNETDOWNBPSTOTAL  = 50000000
 MAXCPULOAD         = 100
 
 [TCP]

Modified: GNUnet/src/applications/tbench/peer2udp.conf
===================================================================
--- GNUnet/src/applications/tbench/peer2udp.conf        2005-08-15 06:58:23 UTC 
(rev 1683)
+++ GNUnet/src/applications/tbench/peer2udp.conf        2005-08-15 06:58:32 UTC 
(rev 1684)
@@ -25,8 +25,8 @@
 [LOAD]
 INTERFACES          = eth0
 BASICLIMITING       = YES
-MAXNETUPBPSTOTAL    = 50000
-MAXNETDOWNBPSTOTAL  = 50000
+MAXNETUPBPSTOTAL    = 50000000
+MAXNETDOWNBPSTOTAL  = 50000000
 MAXCPULOAD         = 100
 
 [TCP]

Modified: GNUnet/src/applications/tbench/tbench.c
===================================================================
--- GNUnet/src/applications/tbench/tbench.c     2005-08-15 06:58:23 UTC (rev 
1683)
+++ GNUnet/src/applications/tbench/tbench.c     2005-08-15 06:58:32 UTC (rev 
1684)
@@ -130,13 +130,13 @@
 static int handleTBenchReq(const PeerIdentity * sender,
                           const P2P_MESSAGE_HEADER * message) {
   P2P_MESSAGE_HEADER * reply;
-  P2P_tbench_MESSAGE * msg;
+  const P2P_tbench_MESSAGE * msg;
 
   if ( ntohs(message->size) < sizeof(P2P_tbench_MESSAGE)) {
     BREAK();
     return SYSERR;
   }
-  msg = (P2P_tbench_MESSAGE*) message;
+  msg = (const P2P_tbench_MESSAGE*) message;
   if (crc32N(&msg[1],
             ntohs(message->size) - sizeof(P2P_tbench_MESSAGE))
       != ntohl(msg->crc)) {
@@ -146,7 +146,7 @@
 
 #if DEBUG_TBENCH
   LOG(LOG_DEBUG,
-      "Received message %u from iteration %u/%u\n",
+      "Received request %u from iteration %u/%u\n",
       htonl(msg->packetNum),
       htonl(msg->iterationNum),
       htonl(msg->nounce));
@@ -169,13 +169,13 @@
  */
 static int handleTBenchReply(const PeerIdentity * sender,
                             const P2P_MESSAGE_HEADER * message) {
-  P2P_tbench_MESSAGE * pmsg;
+  const P2P_tbench_MESSAGE * pmsg;
 
   if (ntohs(message->size) < sizeof(P2P_tbench_MESSAGE)) {
     BREAK();
     return SYSERR;
   }
-  pmsg = (P2P_tbench_MESSAGE*) message;
+  pmsg = (const P2P_tbench_MESSAGE*) message;
   if (crc32N(&pmsg[1],
             ntohs(message->size) - sizeof(P2P_tbench_MESSAGE))
       != ntohl(pmsg->crc)) {
@@ -184,7 +184,7 @@
   }
 #if DEBUG_TBENCH
   LOG(LOG_DEBUG,
-      "Received message %u from iteration %u/%u\n",
+      "Received response %u from iteration %u/%u\n",
       htonl(pmsg->packetNum),
       htonl(pmsg->iterationNum),
       htonl(pmsg->nounce));
@@ -300,7 +300,6 @@
     p2p->crc
       = htonl(crc32N(&p2p[1],
                     size - sizeof(P2P_tbench_MESSAGE)));
-
     MUTEX_UNLOCK(&lock); /* allow receiving */
 
     cronTime(&startTime);
@@ -319,8 +318,10 @@
       p2p->packetNum = htonl(packetNum);
 #if DEBUG_TBENCH
       LOG(LOG_DEBUG,
-         "Sending message %u in iteration %u\n",
-         packetNum, iteration);
+         "Sending message %u of size %u in iteration %u\n",
+         packetNum, 
+         size,
+         iteration);
 #endif
       coreAPI->unicast(&msg->receiverId,
                       &p2p->header,

Modified: GNUnet/src/server/connection.c
===================================================================
--- GNUnet/src/server/connection.c      2005-08-15 06:58:23 UTC (rev 1683)
+++ GNUnet/src/server/connection.c      2005-08-15 06:58:32 UTC (rev 1684)
@@ -486,7 +486,7 @@
  * What is the available downstream bandwidth (in bytes
  * per minute)?
  */
-static long long max_bpm;
+static unsigned long long max_bpm;
 
 /**
  * Registered Send-Notify handlers.
@@ -1275,8 +1275,9 @@
   }
   if ( (be->status != STAT_UP) ||
        (be->sendBufferSize == 0) ||
-       (be->inSendBuffer == YES) )
+       (be->inSendBuffer == YES) ) {
     return; /* must not run */
+  }
   be->inSendBuffer = YES;
 
   if ( (OK != ensureTransportConnected(be)) ||
@@ -1815,6 +1816,7 @@
   long long decrementSB;
   long long * adjustedRR;
   int didAssign;
+  int firstRound;
 
   MUTEX_LOCK(&lock);
   cronTime(&now);
@@ -1829,21 +1831,28 @@
     return;
   }
 
-  /* if time difference is too small, we don't have enough
-     sample data and should NOT update the limits */
+  activePeerCount = forAllConnectedHosts(NULL, NULL); 
+  if (activePeerCount == 0) {
+    MUTEX_UNLOCK(&lock);
+    return; /* nothing to be done here. */
+  }
+
+
+ /* if time difference is too small, we don't have enough
+     sample data and should NOT update the limits;
+     however, if we have FAR to few peers, reschedule
+     aggressively (since we are unlikely to get close
+     to the limits anyway) */
   timeDifference = now - lastRoundStart;
-  if (timeDifference < MIN_SAMPLE_TIME) {
+  if ( (timeDifference < MIN_SAMPLE_TIME) &&
+       (activePeerCount > CONNECTION_MAX_HOSTS_ / 16) ) {
     MUTEX_UNLOCK(&lock);
     return; /* don't update too frequently, we need at least some
               semi-representative sampling! */
   }
 
   /* build an array containing all BEs */
-  activePeerCount = forAllConnectedHosts(NULL, NULL);
-  if (activePeerCount == 0) {
-    MUTEX_UNLOCK(&lock);
-    return; /* nothing to be done here. */
-  }
+
   entries = MALLOC(sizeof(BufferEntry*)*activePeerCount);
   utl.pos = 0;
   utl.e = entries;
@@ -1876,7 +1885,6 @@
     minCon = activePeerCount;
   schedulableBandwidth 
     = max_bpm - minCon * MIN_BPM_PER_PEER;
-
   adjustedRR = MALLOC(sizeof(long long) * activePeerCount);
 
   /* reset idealized limits; if we want a smoothed-limits
@@ -1957,6 +1965,8 @@
      (unencrypted) traffic that we're not quite accounting for anyway,
      that's probably not so bad. */
   didAssign = YES;
+  /* in the first round we cap by 2* previous utilization */
+  firstRound = YES;
   while ( (schedulableBandwidth > CONNECTION_MAX_HOSTS_ * 100) &&
          (activePeerCount > 0) &&
          (didAssign == YES) ) {
@@ -1964,11 +1974,13 @@
     decrementSB = 0;
     for (u=0;u<activePeerCount;u++) {
       /* always allow allocating MIN_BPM_PER_PEER */
-      if (entries[u]->idealized_limit < adjustedRR[u] * 2) {
+      if ( (firstRound == NO) ||
+          (entries[u]->idealized_limit < adjustedRR[u] * 2) ) {
        unsigned int share;
 
        share = entries[u]->idealized_limit + (unsigned int) (shares[u] * 
schedulableBandwidth);
-       if (share > adjustedRR[u] * 2)
+       if ( (share > adjustedRR[u] * 2) &&
+            (firstRound == YES) )
          share = adjustedRR[u] * 2;
        if (share > entries[u]->idealized_limit) {
          decrementSB += share - entries[u]->idealized_limit;
@@ -1984,11 +1996,13 @@
       /* assign also to random "worthless" (zero-share) peers */
       for (u=0;u<activePeerCount;u++) {
        unsigned int v = perm[u]; /* use perm to avoid preference to 
low-numbered slots */
-       if (entries[v]->idealized_limit / 2 < adjustedRR[u]) {
+       if ( (firstRound == NO) ||
+            (entries[v]->idealized_limit / 2 < adjustedRR[u]) ) {
          unsigned int share;
 
          share = entries[v]->idealized_limit + (unsigned int) 
(schedulableBandwidth);
-         if (share > adjustedRR[u] * 2)
+         if ( (firstRound == YES) &&
+              (share > adjustedRR[u] * 2) )
            share = adjustedRR[u] * 2;
          schedulableBandwidth -= share - entries[v]->idealized_limit;
          entries[v]->idealized_limit = share;
@@ -2008,8 +2022,13 @@
        FREE(perm);
        perm = NULL;
       }
-      break;
     } /* didAssign == NO? */
+    if (firstRound == YES) {
+      /* keep some bandwidth off the market 
+        for new connections */
+      schedulableBandwidth /= 2;
+    }
+    firstRound = NO;
   } /* while bandwidth to distribute */
 
 
@@ -2527,7 +2546,7 @@
  * accordingly.
  */
 static void connectionConfigChangeCallback() {
-  long new_max_bpm;
+  unsigned long long new_max_bpm;
   unsigned int i;
 
   MUTEX_LOCK(&lock);
@@ -2538,15 +2557,16 @@
   if (new_max_bpm == 0)
     new_max_bpm = 50000 * 60; /* assume 50 kbps */
   if (max_bpm != new_max_bpm) {
-    int newMAXHOSTS = 0;
+    unsigned int newMAXHOSTS = 0;
 
     max_bpm = new_max_bpm;
     newMAXHOSTS
       = max_bpm / (MIN_BPM_PER_PEER*2);
-    /* => for 1000 bps, we get 12 (rounded DOWN to 8) connections! */
-
+    /* => for 1000 bps, we get 12 (rounded DOWN to 8) connections! */    
     if (newMAXHOSTS < 2)
       newMAXHOSTS = 2; /* strict minimum is 2 */
+    if (newMAXHOSTS > 256)
+      newMAXHOSTS = 256; /* limit, before we run out of sockets! */
     i = 1;
     while (i <= newMAXHOSTS)
       i*=2;

Modified: GNUnet/src/server/handler.c
===================================================================
--- GNUnet/src/server/handler.c 2005-08-15 06:58:23 UTC (rev 1683)
+++ GNUnet/src/server/handler.c 2005-08-15 06:58:32 UTC (rev 1684)
@@ -391,7 +391,7 @@
 
       if ( (ptyp >= max_registeredType) ||
           (NULL == handlers[ptyp][0]) ) {
-       LOG(LOG_DEBUG,
+       LOG(LOG_EVERYTHING,
            "Encrypted message of type '%d' not understood (no handler 
registered).\n",
            ptyp);
        continue; /* no handler registered, go to next part */
@@ -412,7 +412,7 @@
 
       if ( (ptyp >= plaintextmax_registeredType) ||
           (NULL == plaintextHandlers[ptyp][0]) ) {
-       LOG(LOG_DEBUG,
+       LOG(LOG_EVERYTHING,
            "Plaintext message of type '%d' not understood (no handler 
registered).\n",
            ptyp);
        continue; /* no handler registered, go to next part */





reply via email to

[Prev in Thread] Current Thread [Next in Thread]