SCTP Discussions

Text archives Help


Re: [SCTP-Discussion] Inbound streams with socketapi


Chronological Thread 
  • From: Michael Tüxen <Michael.Tuexen AT micmac.franken.de>
  • To: amish.chana AT orange.co.uk
  • Cc: discussion AT sctp.de
  • Subject: Re: [SCTP-Discussion] Inbound streams with socketapi
  • Date: Wed Mar 12 23:52:00 2003
  • List-id: SCTP Discussions <discussion.sctp.de>

Hi Amish,

which version of the socketapilib are you using? I've tested the attached version of
a client with the 1.0.1 version of the lib and it works.

Does the attached client shows also the problem you are describing? Please
note that a new version of the socketapilib with a lot of bug fixes will be
released soon.

Best regards
Michael

#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <ext_socket.h>
#include <unistd.h>

int main (int argc, const char * argv[]) {
int fd, i, j, n, size;
struct sockaddr_in local_addr, remote_addr;
struct sockaddr_storage addr_storage[2];
struct sctp_initmsg init_params;
struct sockaddr_storage *addrs;
struct sctp_paddrparams peer_params;
struct sctp_rtoinfo RTOInfo;
struct sctp_paddrinfo paddrinfo;
char addrbuf[INET6_ADDRSTRLEN];
const char *ap;

for (i=0; i < 2; i++ ) {
if ((fd = ext_socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP)) < 0)
perror("ext_socket");

init_params.sinit_num_ostreams = 123;
init_params.sinit_max_instreams = 127;
init_params.sinit_max_attempts = 0;
init_params.sinit_max_init_timeo = 0;

if (ext_setsockopt(fd, IPPROTO_SCTP, SCTP_INITMSG, (const void *)
&init_params, sizeof(init_params))< 0)
perror("ext_setsockopt");

/* bind addresses */
bzero(&addr_storage, sizeof(addr_storage));

bzero(&local_addr, sizeof(local_addr));
#if !defined (LINUX)
local_addr.sin_len = sizeof(local_addr);
#endif
local_addr.sin_family = AF_INET;
if (inet_aton("192.168.1.1", &local_addr.sin_addr) != 1)
printf("inet_aton failed");
local_addr.sin_port = htons(1000+i);
bcopy((const void *) &local_addr, (void *) &(addr_storage[0]),
sizeof(local_addr));

if (inet_aton("192.168.2.1", &local_addr.sin_addr) != 1)
printf("inet_aton failed");

bcopy((const void *) &local_addr, (void *) &(addr_storage[1]),
sizeof(local_addr));

if (ext_bindx(fd, (struct sockaddr_storage *)&addr_storage, 2,
SCTP_BINDX_ADD_ADDR) < 0)
perror("ext_bindx");

/* prepare remote address */
bzero(&remote_addr, sizeof(remote_addr));
#if !defined (LINUX)
remote_addr.sin_len = sizeof(remote_addr);
#endif
remote_addr.sin_family = AF_INET;
if (inet_aton("192.168.1.254", &remote_addr.sin_addr) != 1)
printf("inet_aton failed");
remote_addr.sin_port = htons(9);

printf("Starting connect ...");
fflush(stdout);
if (ext_connect(fd, (const struct sockaddr *)&remote_addr,
sizeof(remote_addr)) < 0)
perror("ext_connect");
printf(" done.\n");
fflush(stdout);
size = sizeof(RTOInfo);
if (ext_getsockopt(fd, IPPROTO_SCTP, SCTP_RTOINFO, &RTOInfo, &size) <
0)
perror("getsockopt");
printf("Initial SRTO: %u\n", RTOInfo.srto_initial);
printf("Min SRTO: %u\n", RTOInfo.srto_min);
printf("Max SRTO: %u\n\n", RTOInfo.srto_max);

RTOInfo.srto_min = 100;
RTOInfo.srto_max = 500;
size = sizeof(RTOInfo);
if (ext_setsockopt(fd, IPPROTO_SCTP, SCTP_RTOINFO, &RTOInfo, size) <
0)
perror("getsockopt");

size = sizeof(RTOInfo);
if (ext_getsockopt(fd, IPPROTO_SCTP, SCTP_RTOINFO, &RTOInfo, &size) <
0)
perror("getsockopt");
printf("Initial SRTO: %u\n", RTOInfo.srto_initial);
printf("Min SRTO: %u\n", RTOInfo.srto_min);
printf("Max SRTO: %u\n\n", RTOInfo.srto_max);
fflush(stdout);

if ((n=sctp_getpaddrs(fd, 0, &addrs)) < 0)
perror("sctp_getpaddrs");
for(j=0; j < n; j++) {
peer_params.spp_assoc_id = 0;
memcpy((void *) &(peer_params.spp_address), (const void *)
&addrs[j], sizeof(struct sockaddr_storage));
peer_params.spp_hbinterval = 100;
peer_params.spp_pathmaxrxt = 2;
size = sizeof(peer_params);
if (sctp_opt_info(fd, 0, SCTP_SET_PEER_ADDR_PARAMS, (void
*)&peer_params, &size) < 0)
perror("sctp_opt_info");
}

for(;;) {
printf("============================\n\n");
for(j=0; j < n; j++) {
memcpy((void *) &(paddrinfo.spinfo_address), (const void *)
&addrs[j], sizeof(struct sockaddr_storage));
size = sizeof(paddrinfo);
if (ext_getsockopt(fd, IPPROTO_SCTP, SCTP_GET_PEER_ADDR_INFO,
&paddrinfo, &size) < 0)
perror("getsockopt");
switch (addrs[j].ss_family) {
case AF_INET:
ap = inet_ntop(AF_INET, &((struct sockaddr_in
*)&addrs[j])->sin_addr, addrbuf, INET6_ADDRSTRLEN);
break;
case AF_INET6:
ap = inet_ntop(AF_INET6, &((struct sockaddr_in6
*)&addrs[j])->sin6_addr, addrbuf, INET6_ADDRSTRLEN);
break;
}
#define SCTP_ACTIVE 0
printf("Towards %s\n", ap);
printf("State: %s\n", (paddrinfo.spinfo_state==SCTP_ACTIVE) ?
"active" : "inactive");
printf("CWND: %u\n", paddrinfo.spinfo_cwnd);
printf("SRTT: %u\n", paddrinfo.spinfo_srtt);
printf("RTO: %u\n", paddrinfo.spinfo_rto);
printf("MTU: %u\n", paddrinfo.spinfo_mtu);
memset((void *)&peer_params, 0, sizeof(peer_params));
peer_params.spp_assoc_id = 0;
memcpy((void *) &(peer_params.spp_address), (const void *)
&addrs[j], sizeof(struct sockaddr_storage));
size = sizeof(peer_params);
if (ext_getsockopt(fd, IPPROTO_SCTP,
SCTP_GET_PEER_ADDR_PARAMS, &peer_params, &size) < 0)
perror("getsockopt");
printf("HB: %u\n\n", peer_params.spp_hbinterval);
fflush(stdout);
}
sleep(1);
}
if (ext_close(fd) < 0)
perror("ext_close");
}
sleep(10);
return 0;
}


On Wednesday, Mar 12, 2003, at 13:31 Europe/Berlin, amish.chana AT orange.co.uk wrote:


Hi,

I have the following block of code with the socketapi.
Irrespective of the number of streams I assign the initmsg.sinit_max_instreams
below the INIT message always requests 1 stream.

Thank you in advance for any assistance,
Amish



------------------------------------------------------------
if ((fd = ext_socket(PF_INET, SOCK_SEQPACKET, IPPROTO_SCTP)) < 0)
perror("socket call failed");

if(ext_bind(fd, (struct sockaddr *)&src_addr, sizeof(src_addr)) < 0)
perror("bind call failed");

initmsg.sinit_num_ostreams = 5;
initmsg.sinit_max_instreams = 5;
initmsg.sinit_max_attempts = 0;
initmsg.sinit_max_init_timeo = 0;

if (ext_setsockopt(fd, IPPROTO_SCTP, SCTP_INITMSG, (void *)&initmsg,
sizeof(struct sctp_initmsg)) < 0)
perror("setsockopt call failed");

if(ext_connect(fd,(struct sockaddr *) &dest_addr,sizeof(dest_addr)) < 0)
perror("connect call failed");





*********************************************************************** ********
Important.
Confidentiality: This communication is intended for the above-named person and
may be confidential and/or legally privileged. Any opinions expressed in this
communication are not necessarily those of the company. If it has come to you
in error you must take no action based on it, nor must you copy or show it to
anyone; please delete/destroy and inform the sender immediately.

Monitoring/Viruses
Orange may monitor all incoming and outgoing emails in line with current
legislation. Although we have taken steps to ensure that this email and
attachments are free from any virus, we advise that in keeping with good
computing practice the recipient should ensure they are actually virus free.

Orange PCS Limited is a subsidiary of Orange SA and is registered in England No
2178917, with its address at St James Court, Great Park Road, Almondsbury Park,
Bradley Stoke, Bristol BS32 4QJ.
*********************************************************************** ********

_______________________________________________
discussion mailing list
discussion AT sctp.de
http://www.sctp.de/mailman/listinfo/discussion




Archive powered by MHonArc 2.6.19+.

Top of page