- From: "Oon Heok Kee" <oonheokkee78 AT hotmail.com>
- To: discussion AT sctp.de
- Subject: [SCTP-Discussion] How to modify certain parameters?
- Date: Tue Aug 27 16:02:01 2002
- List-id: SCTP Discussions <discussion.sctp.de>
Hi,
I'm presently running on kernel 2.4.18-3, installed with socketapi-1.0.0
and sctplib-1.0.0-pre19.
I have a small piece of echo-server program running on SCTP. It's
presently running with a single pair of in and out stream. I would like to
know how I can modify certain parameters, in particular:
no. of in/out streams supported
no. of retransmission
level of reliability
and other stuff like that so that I can have some packets delivered with
higher reliability and more number of streams in 1 association. Is there any
central configuration file where all these configuration parameters are
located? It would be good if anyone can give me an example of how to change
the configurations.
I have also checked my program on Ethereal, and it seems like I'm always
getting an error on the Adler32 checksum. The program works perfectly
though. Are there any known errors on this?
Thank you very much, and hope to hear from any of the good Samaritans out
there... :)
Regards,
Oon, Heok Kee
P.S. I've attached my codes below, and I hope it helps...
***********************************************************
/**** Echo Server Example ****/
/* SCTP server */
/* Compile this file with "gcc -o sctp_server sctp_server.c -lsctpsocket
-lsctp -lglib -lstdc++ -lpthread". */
#include <stdio.h> /* for printf() and fprintf() */
#include <sys/socket.h> /* for socket(), bind(), and connect() */
#include <arpa/inet.h> /* for sockaddr_in and inet_ntoa() */
#include <stdlib.h> /* for atoi() */
#include <string.h> /* for memset() */
#include <unistd.h> /* for close() */
#include <sys/types.h>
#include <sys/time.h>
#include <ext_socket.h>
#include <net/route.h>
#include <net/if.h>
#include <netinet/in.h>
#include <sctp.h>
#define MAXPENDING 5 /* Maximum outstanding connection requests */
#define RCVBUFSIZE 16 /* Size of receive buffer */
void DieWithError(char *errorMessage)
{
perror(errorMessage);
exit(1);
}
void HandleSCTPClient(int clntSocket)
{
char *echoBuffer/*[RCVBUFSIZE]*/; /* Buffer for echo string */
int recvMsgSize; /* Size of received message */
printf("Receiving message from client...\n\n");
printf("Message received: ");
do{
recvMsgSize = 0;
if ((recvMsgSize = ext_recv(clntSocket, echoBuffer, (RCVBUFSIZE-1), 0)) <
0)
DieWithError("recv() failed");
echoBuffer[recvMsgSize] = '\0';
printf("%s", echoBuffer);
if (ext_send(clntSocket, echoBuffer, recvMsgSize, 0) !=
recvMsgSize)
DieWithError("send() failed");
} while (recvMsgSize > 0);
/*free(&echoBuffer);*/
printf("\n\nClosing connection... ");
ext_close(clntSocket); /* Close client socket */
printf("Connection closed.\n\n");
}
int main(int argc, char *argv[])
{
int fd;
int servSock; /* Socket descriptor for server */
int clntSock; /* Socket descriptor for client */
struct sockaddr_in echoServAddr; /* Local address */
struct sockaddr_in echoClntAddr; /* Client address */
struct sctp_assoc_change *sac;
unsigned int clntLen; /* Length of client address */
unsigned short echoServPort; /* Server port */
if (argc != 2) /* Test for correct number of arguments */
{
fprintf(stderr, "Usage: %s <Server Port>\n", argv[0]);
exit(1);
}
echoServPort = atoi(argv[1]); /* First arg: local port */
printf("\nCreating socket... ");
/* Create socket for incoming connections */
if ((servSock = ext_socket(PF_INET, SOCK_STREAM, IPPROTO_SCTP))<0)
DieWithError("socket() failed");
printf("Socket created.\n\n");
/* Construct local address structure */
/* Zero out structure */
memset(&echoServAddr, 0, sizeof(echoServAddr));
echoServAddr.sin_family = AF_INET;/* Internet addr. family */
/* Any incoming interface */
echoServAddr.sin_addr.s_addr = htonl(INADDR_ANY);
echoServAddr.sin_port = htons(echoServPort); /* Local port */
printf("Binding to address... ");
/* Bind to the local address */
if (ext_bind(servSock, (struct sockaddr *) &echoServAddr,
sizeof(echoServAddr)) < 0)
DieWithError("bind() failed");
printf("Address bounded.\n\n");
/* Mark the socket so it will listen for incoming conn. */
if (ext_listen(servSock, MAXPENDING) < 0)
DieWithError("listen() failed");
for (;;) /* Run forever */
{
/* Set the size of the in-out parameter */
clntLen = sizeof(echoClntAddr);
printf("Waiting for connection... ");
/* Wait for a client to connect */
if ((clntSock = ext_accept(servSock, (struct sockaddr *) &echoClntAddr,
&clntLen)) < 0)
DieWithError("accept() failed");
printf("Connected.\n\n");
/* clntSock is connected to a client! */
printf("Handling client %s\n\n",
inet_ntoa(echoClntAddr.sin_addr));
HandleSCTPClient(clntSock);
}
}
********************************************************************
_________________________________________________________________
Chat with friends online, try MSN Messenger:
http://messenger.msn.com
- [SCTP-Discussion] How to modify certain parameters?, Oon Heok Kee, 08/27/2002
Archive powered by MHonArc 2.6.19+.