Example #1
0
void dataArriveNotif(unsigned int assocID, unsigned short streamID, unsigned int len,
                     unsigned short streamSN,unsigned int TSN, unsigned int protoID,
                     unsigned int unordered, void* ulpDataPtr)
{
    unsigned char chunk[MAXIMUM_PAYLOAD_LENGTH];
    unsigned int length;
    int index=0, result;
    unsigned short ssn;
    unsigned int the_tsn;

    if (vverbose) {
      fprintf(stdout, "%-8x: Data arrived (%u bytes on stream %u, %s)\n",
                      assocID, len, streamID, (unordered==SCTP_ORDERED_DELIVERY)?"ordered":"unordered");
      fflush(stdout);
    }
    /* read it */
    length = sizeof(chunk);
    SCTP_receive(assocID, streamID, chunk, &length, &ssn, &the_tsn, SCTP_MSG_DEFAULT);

    /* update counter */
    ((struct ulp_data *) ulpDataPtr)->nrOfReceivedChunks += 1;
    ((struct ulp_data *) ulpDataPtr)->nrOfReceivedBytes  += length;

    /* and send it */
    if (sendToAll) {
        for (index=0; index < MAXIMUM_NUMBER_OF_ASSOCIATIONS; index++) {
            if ((ulpData[index].maximumStreamID != -1)&&
                (!(ulpData[index].ShutdownReceived))) {
                result = SCTP_send(ulpData[index].assocID,
                                   (unsigned short)min(streamID, (unsigned int)(ulpData[index].maximumStreamID)),
                                   chunk, length,
                                   protoID,
                                   SCTP_USE_PRIMARY, SCTP_NO_CONTEXT, timeToLive, unordered, SCTP_BUNDLING_DISABLED);
                if (vverbose) {
                    fprintf(stdout, "%-8x: Data sent (%u bytes on stream %u, %s) Result: %d\n",
                                    ulpData[index].assocID, len, min(streamID, (unsigned int)ulpData[index].maximumStreamID),
                                    (unordered==SCTP_ORDERED_DELIVERY)?"ordered":"unordered", result);
                    fflush(stdout);
                }
            }
        }
    } else {
        result = SCTP_send(assocID,
                           (unsigned short)min(streamID, (unsigned int)(((struct ulp_data *) ulpDataPtr)->maximumStreamID)),
                           chunk, length,
                           protoID,
                           SCTP_USE_PRIMARY, SCTP_NO_CONTEXT, timeToLive, unordered, SCTP_BUNDLING_DISABLED);
        if (vverbose) {
            fprintf(stdout, "%-8x: Data sent (%u bytes on stream %u, %s) Result: %d\n",
                            ulpData[index].assocID, len, min(streamID, (unsigned int)(((struct ulp_data *) ulpDataPtr)->maximumStreamID)),
                            (unordered==SCTP_ORDERED_DELIVERY)?"ordered":"unordered", result);
            fflush(stdout);
        }
    }
}
Example #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;
    }
}
Example #3
0
void queueStatusChangeNotif(unsigned int assocID, int queueType, int queueID, int queueLength, void* ulpDataPtr)
{
   unsigned char chunk[MAXIMUM_PAYLOAD_LENGTH];
   unsigned short streamID = 0;
   struct timeval now, diffTime;
   double seconds, throughput;

   if (vverbose) {
       fprintf(stdout, "%-8x: Queue status change notification: Type %d, ID %d, Length %d\n",
                       assocID, queueType, queueID, queueLength);
       fflush(stdout);
   }

   if (queueType == SCTP_SEND_QUEUE && queueLength <= SEND_QUEUE_SIZE) {
      memset(chunk, 0, sizeof(chunk));

      while(stopSending!=1 && (!(((struct ulp_data *)ulpDataPtr)->ShutdownReceived)) &&
            (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)) {
         if (vverbose) {
            fprintf(stdout, "%-8x: %u bytes sent.\n", assocID, chunkLength);
            fflush(stdout);
         }
         if (rotateStreams) {
            streamID = (streamID + 1) % (((struct ulp_data *)ulpDataPtr)->maximumStreamID+1);
         }
         ((struct ulp_data *)ulpDataPtr)->nrOfSentChunks += 1;
         ((struct ulp_data *)ulpDataPtr)->nrOfSentBytes  += chunkLength;
      }
   }
   if ((stopSending == 1) && (queueLength == 0)) {
      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", ((struct ulp_data *)ulpDataPtr)->nrOfSentChunks, chunkLength, seconds);
      throughput = (double)((struct ulp_data *)ulpDataPtr)->nrOfSentChunks * (double)chunkLength / seconds / 1024.0;
      fprintf(stdout, "Throughput was %f KB/sec.\n", throughput);
   }
}
Example #4
0
void clientDataArriveNotif(unsigned int assocID, unsigned short streamID, unsigned int len,
                           unsigned short streamSN,unsigned int TSN, unsigned int protoID,
                           unsigned int unordered, void* ulpDataPtr)
{
    unsigned char chunk[MAXIMUM_PAYLOAD_LENGTH];
    unsigned int length;
    unsigned short ssn;
    unsigned int the_tsn;

    chunkCount++;
    length = sizeof(chunk);
    SCTP_receive(assocID, streamID, chunk, &length, &ssn, &the_tsn, SCTP_MSG_DEFAULT);
    SCTP_send(assocID,
              streamID,
              chunk, length,
              protoID,
              SCTP_USE_PRIMARY, SCTP_NO_CONTEXT, SCTP_INFINITE_LIFETIME, unordered, SCTP_BUNDLING_DISABLED);

    if (chunkCount > ende)     SCTP_shutdown(assocID);
}
Example #5
0
void* clientCommunicationUpNotif(unsigned int assocID, int status,
                           unsigned int noOfPaths,
                           unsigned short noOfInStreams, unsigned short noOfOutStreams,
                           int associationSupportsPRSCTP, void* dummy)
{
    unsigned int  packetNumber;
    unsigned char chunk[MAXIMUM_PAYLOAD_LENGTH];

    /* send the initial packets */
    memset(chunk, 0xFF, sizeof(chunk));
    for(packetNumber=1; packetNumber <= numberOfInitialPackets; packetNumber++) {
        SCTP_send(assocID,
                  0,
                  chunk, chunkLength,
                  SCTP_GENERIC_PAYLOAD_PROTOCOL_ID,
                  SCTP_USE_PRIMARY, SCTP_NO_CONTEXT, SCTP_INFINITE_LIFETIME,
                  (sendUnordered)?SCTP_UNORDERED_DELIVERY:SCTP_ORDERED_DELIVERY,
                  SCTP_BUNDLING_DISABLED);
    }
    return NULL;
}
Example #6
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;
}
Example #7
0
void serverDataArriveNotif(unsigned int assocID, unsigned short streamID, unsigned int len,
                           unsigned short streamSN,unsigned int TSN, unsigned int protoID,
                           unsigned int unordered, void* ulpDataPtr)
{
    unsigned char chunk[MAXIMUM_PAYLOAD_LENGTH];
    unsigned int length;
    unsigned short ssn;
    unsigned int the_tsn;

    /* read it */
    length = sizeof(chunk);
    SCTP_receive(assocID, streamID, chunk, &length, &ssn, &the_tsn, SCTP_MSG_DEFAULT);

    /* update counter */
    ((struct ulp_data *) ulpDataPtr)->nrOfReceivedChunks += 1;
    ((struct ulp_data *) ulpDataPtr)->nrOfReceivedBytes  += length;

    /* and send it */
    SCTP_send(assocID,
              (unsigned short)min(streamID, ((struct ulp_data *) ulpDataPtr)->maximumStreamID),
              chunk, length,
              protoID,
              SCTP_USE_PRIMARY, SCTP_NO_CONTEXT, SCTP_INFINITE_LIFETIME, unordered, SCTP_BUNDLING_DISABLED);
}
Example #8
0
void dataArriveNotif(unsigned int assocID, unsigned short streamID, unsigned int len,
                     unsigned short streamSN,unsigned int TSN, unsigned int protoID,
                     unsigned int unordered, void* ulpDataPtr)
{
    unsigned char chunk[MAXIMUM_PAYLOAD_LENGTH];
    unsigned int length;
    unsigned short ssn;
    unsigned int tsn;

    if (vverbose) {
      fprintf(stdout, "%-8x: Data arrived (%u bytes on stream %u, %s)\n",
                      assocID, len, streamID, (unordered==SCTP_ORDERED_DELIVERY)?"ordered":"unordered");
      fflush(stdout);
    }
    /* read it */
    length = MAXIMUM_PAYLOAD_LENGTH;
    SCTP_receive(assocID, streamID, chunk, &length,&ssn, &tsn, SCTP_MSG_DEFAULT);
    /* and send it */
    SCTP_send(assocID,
              (unsigned short)min(streamID, ((struct ulp_data *) ulpDataPtr)->maximumStreamID),
              chunk, length,
              protoID,
              SCTP_USE_PRIMARY, SCTP_NO_CONTEXT, timeToLive, unordered, SCTP_BUNDLING_DISABLED);
}
Example #9
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;
   }
}