October 13th, 2012 03:05 AM
#1
SCTPDrv looking for help
Hello, I have used SCTPDrv of Brucec. I need to send BICC traffic through SCTP and stream id, payload type and sequence-id of sctp is impotent for me. I see that the driver can send stream-id up to 9 without any problem; but as soon as the stream-id exceeds 9 the sctp_send function returns error. The WSAGetLastError returns the error code 10022 (WSAEINVAL : some invalid item has been found). I want to know if any factor can restrict the stream-id. Is bandwidth of network interface or any other factor causes the limitation? Please help me resolve this problem.
I put a peace of the code that I have used for transferring SCTP data-payload bellow.
Regards
void CSctpDrvTestDlg::OnBnClickedClient()
{
int error = 0;
struct addrinfo hints, *res, *res0;
SOCKET sfd = INVALID_SOCKET;
char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV];
char buf[BUFSIZE];
int len;
struct sockaddr_storage from;
socklen_t fromlen;
WSADATA wsaData;
int ret = 0;
ret = WSAStartup(MAKEWORD(2, 2), &wsaData);
if (ret != 0) {
err(1, "WSAStartup");
/*NOTREACHED*/
}
memset(&hints, 0, sizeof(hints));
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
error = getaddrinfo("172.18.4.105",
"10000",
&hints, &res0);
if (error) {
errx(1, "%s", gai_strerror(error));
/*NOTREACHED*/
}
for (res = res0; res; res = res->ai_next) {
res->ai_protocol = IPPROTO_SCTP;
sfd = socket(res->ai_family,
res->ai_socktype,
res->ai_protocol);
if (sfd == INVALID_SOCKET) {
warn("socket");
continue;
}
error = getnameinfo(res->ai_addr, (socklen_t)res->ai_addrlen,
hbuf, NI_MAXHOST,
sbuf, NI_MAXSERV,
NI_NUMERICHOST | NI_NUMERICSERV);
if (error) {
errx(1, "%s", gai_strerror(error));
/*NOTREACHED*/
}
fprintf(stderr, "Connecting to [%s]:%s ...\n", hbuf, sbuf);
try{
if (connect(sfd,
res->ai_addr,
(int)res->ai_addrlen)
< 0) {
warn("Connection to [%s]:%s", hbuf, sbuf);
closesocket(sfd);
sfd = INVALID_SOCKET;
continue;
}
}
catch(...)
{
int d=-1;
}
fprintf(stderr, "Connecting Completed.\n");
break;
}
int assocId = sctp_getassocid(sfd, res0->ai_addr);
freeaddrinfo(res0);
if (sfd == INVALID_SOCKET) {
WSACleanup();
}
int i=1;
struct sctp_initmsg initm;
initm.sinit_max_instreams = 20;
initm.sinit_num_ostreams = 20;
setsockopt(sfd, IPPROTO_SCTP, SCTP_INITMSG, (char*)&initm, sizeof(initm));
for (int k = 0; k<4; k++)
{
memset(buf, 0, sizeof(buf));
memcpy(buf, "salam", 6);
sctp_sndrcvinfo* sndRcvInfo = new sctp_sndrcvinfo();
sndRcvInfo->sinfo_flags = 3;
sndRcvInfo->sinfo_assoc_id = assocId;
sndRcvInfo->sinfo_context = 1;
sndRcvInfo->sinfo_ppid = 0x3000000;
sndRcvInfo->sinfo_stream=9;
sndRcvInfo->sinfo_timetolive = 100;
long ret = sctp_send(sfd, buf, strlen(buf), sndRcvInfo, 0);
if(ret<0)
{
int a = WSAGetLastError();
return;
}
memset(buf, 0, BUFSIZE*sizeof(char));
fromlen = sizeof(from);
len = sctp_recvmsg(sfd, buf, BUFSIZE*sizeof(char), (struct sockaddr *)&from, &fromlen, sndRcvInfo, 0 );
if (len < 0) {
err(1, "recvfrom");
/*NOTREACHED*/
}
fprintf(stderr, "SERVER: %s", buf);
}
closesocket(sfd);
WSACleanup();
}
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width
Bookmarks