Beispiel #1
0
void* serverCommunicationUpNotif(unsigned int assocID, int status,
                                 unsigned int noOfPaths,
                                 unsigned short noOfInStreams, unsigned short noOfOutStreams,
                                 int associationSupportsPRSCTP, void* dummy)
{
    int index;

    /* look for a free ULP data */
    for (index=0; index < MAXIMUM_NUMBER_OF_ASSOCIATIONS; index++) {
        if (ulpData[index].maximumStreamID == -1)
            break;
    }

    /* if found */
    if (index < MAXIMUM_NUMBER_OF_ASSOCIATIONS) {
        /* use it */
        ulpData[index].maximumStreamID = noOfOutStreams - 1;
        ulpData[index].assocID = assocID;
        return &ulpData[index];
    } else {
        /* abort assoc due to lack of resources */
        SCTP_abort(assocID);
        return NULL;
    }
}
Beispiel #2
0
void* communicationUpNotif(unsigned int assocID, int status,
                           unsigned int noOfPaths,
                           unsigned short noOfInStreams, unsigned short noOfOutStreams,
                           int associationSupportsPRSCTP, void* dummy)
{
    unsigned int index, packetNumber;
    unsigned char chunk[MAXIMUM_PAYLOAD_LENGTH];
    SCTP_PathStatus pathStatus;
    unsigned short pathID;
    unsigned short streamID = 0;

    if (verbose) {
        fprintf(stdout, "%-8x: Communication up (%u paths:", assocID, noOfPaths);
        for (pathID=0; pathID < noOfPaths; pathID++){
            SCTP_getPathStatus(assocID, pathID, &pathStatus);
            fprintf(stdout, " %s", pathStatus.destinationAddress);
        }
        fprintf(stdout, ")\n");
        fprintf(stdout, "%-8x:                  %u incoming, %u outgoing streams.\n",
                assocID, noOfInStreams, noOfOutStreams);
        fflush(stdout);
    }

    /* look for a free ULP data */
    for (index=0; index < MAXIMUM_NUMBER_OF_ASSOCIATIONS; index++) {
        if (ulpData[index].maximumStreamID == -1)
            break;
    }

    /* if found */
    if (index < MAXIMUM_NUMBER_OF_ASSOCIATIONS) {
        /* use it */
        ulpData[index].maximumStreamID    = noOfOutStreams - 1;
        ulpData[index].assocID            = assocID;
        ulpData[index].nrOfReceivedChunks = 0;
        ulpData[index].nrOfReceivedBytes  = 0;
        ulpData[index].ShutdownReceived   = 0;

        /* send the initial packets */
        memset(chunk, 0, sizeof(chunk));
        for(packetNumber=1; packetNumber <= numberOfInitialPackets; packetNumber++) {
            SCTP_send(assocID,
                      streamID,
                      chunk, chunkLength,
                      SCTP_GENERIC_PAYLOAD_PROTOCOL_ID,
                      SCTP_USE_PRIMARY, SCTP_NO_CONTEXT, timeToLive,
                      (sendUnordered)?SCTP_UNORDERED_DELIVERY:SCTP_ORDERED_DELIVERY,
                      SCTP_BUNDLING_DISABLED);
            if (rotateStreams) {
                streamID = (streamID + 1) % noOfOutStreams;
            }
        }
        return &ulpData[index];
    } else {
        /* abort assoc due to lack of resources */
        SCTP_abort(assocID);
        return NULL;
    }
}
Beispiel #3
0
void
stdinCallback(char *readBuffer, int length)
{
    if (length == 0) {
        SCTP_unregisterStdinCallback();
        if (useAbort) {
            SCTP_abort(associationID);
        } else {
            SCTP_shutdown(associationID);
        }
    }
    if (length > 0) {
        SCTP_send(associationID,
                  currentStream,
                  (unsigned char*)readBuffer, length,
                  SCTP_GENERIC_PAYLOAD_PROTOCOL_ID,
                  SCTP_USE_PRIMARY, SCTP_NO_CONTEXT,
                  timeToLive, SCTP_ORDERED_DELIVERY, SCTP_BUNDLING_DISABLED);
    }
    if (rotateStreams) currentStream = (currentStream + 1)%numberOutStreams;
}
Beispiel #4
0
void* communicationUpNotif(unsigned int assocID, int status,
                           unsigned int noOfPaths,
                           unsigned short noOfInStreams, unsigned short noOfOutStreams,
                           int associationSupportsPRSCTP, void* dummy)
{
   unsigned int index;
   unsigned char chunk[MAXIMUM_PAYLOAD_LENGTH];
   SCTP_PathStatus pathStatus;
   unsigned short pathID;
   unsigned short streamID = 0;
   unsigned long packetNumber;
   struct timeval now, diffTime;
   double seconds, throughput;


   if (verbose) {
      fprintf(stdout, "%-8x: Communication up (%u paths:", assocID, noOfPaths);
      for (pathID=0; pathID < noOfPaths; pathID++){
          SCTP_getPathStatus(assocID, pathID, &pathStatus);
          fprintf(stdout, " %s", pathStatus.destinationAddress);
      }
      fprintf(stdout, ")\n");
      fprintf(stdout, "%-8x:                  %u incoming, %u outgoing streams.\n",
              assocID, noOfInStreams, noOfOutStreams);
      fflush(stdout);
   }

   /* look for a free ULP data */
   for (index=0; index < MAXIMUM_NUMBER_OF_ASSOCIATIONS; index++) {
      if (ulpData[index].maximumStreamID == -1)
         break;
   }

   /* if found */
   if (index < MAXIMUM_NUMBER_OF_ASSOCIATIONS) {
      /* use it */
      ulpData[index].maximumStreamID    = noOfOutStreams - 1;
      ulpData[index].assocID            = assocID;
      ulpData[index].nrOfReceivedChunks = 0;
      ulpData[index].nrOfReceivedBytes  = 0;
      ulpData[index].ShutdownReceived   = 0;
      ulpData[index].nrOfSentChunks = 0;
      ulpData[index].nrOfSentBytes  = 0;

      if (numberOfInitialPackets > 0 && startAssociation) {
         /* send the initial packets */
         memset(chunk, 0, sizeof(chunk));
         gettimeofday(&startTime, NULL);
         for(packetNumber=1; packetNumber <= numberOfInitialPackets; packetNumber++) {
         SCTP_send(assocID,
            streamID,
            chunk, chunkLength,
            SCTP_GENERIC_PAYLOAD_PROTOCOL_ID,
            SCTP_USE_PRIMARY, SCTP_NO_CONTEXT, timeToLive,
            SCTP_ORDERED_DELIVERY,
            SCTP_BUNDLING_DISABLED);
         if (rotateStreams) {
            streamID = (streamID + 1) % noOfOutStreams;
         }
         ulpData[index].nrOfSentChunks += 1;
              ulpData[index].nrOfSentBytes  += chunkLength;
         }
         SCTP_shutdown(assocID);
         if (verbose) {
            fprintf(stdout, "%ld messages of size %d sent.\n",
               packetNumber-1, chunkLength);
         }
      }
      else if (measurementTime > 0) {
         memset(chunk, 0, sizeof(chunk));
         ulpData[index].stopTimerID = SCTP_startTimer(measurementTime, &stopSendingFunction, (void *) &ulpData[index], NULL);
         gettimeofday(&startTime, NULL);
         while((SCTP_send(assocID, streamID, chunk, chunkLength, SCTP_GENERIC_PAYLOAD_PROTOCOL_ID,
                          SCTP_USE_PRIMARY, SCTP_NO_CONTEXT, timeToLive,
                          SCTP_ORDERED_DELIVERY, SCTP_BUNDLING_DISABLED) == SCTP_SUCCESS) && stopSending!=1) {
            if (vverbose) {
             fprintf(stdout, "%-8x: %u bytes sent.\n", assocID, chunkLength);
             fflush(stdout);
            }
            if (rotateStreams) {
               streamID = (streamID + 1) % noOfOutStreams;
            }

            ulpData[index].nrOfSentChunks += 1;
            ulpData[index].nrOfSentBytes  += chunkLength;
         }
         if (stopSending == 1) {
            SCTP_shutdown(assocID);
            gettimeofday(&now, NULL);
            timersub(&now, &startTime, &diffTime);
            seconds = diffTime.tv_sec + (double)diffTime.tv_usec/1000000;
            fprintf(stdout, "%s of %ld messages of length %u took %f seconds.\n",
               "Sending", ulpData[index].nrOfSentChunks, chunkLength, seconds);
            throughput = (double)ulpData[index].nrOfSentChunks * (double)chunkLength / seconds / 1024.0;
            fprintf(stdout, "Throughput was %f KB/sec.\n", throughput);
         }
      }
      return &ulpData[index];
   } else {
      /* abort assoc due to lack of resources */
      SCTP_abort(assocID);
      return NULL;
   }
}