SCTP Discussions

Text archives Help


Re: [SCTP-Discussion] The difference between ext_sendto() and sctp_sendx()


Chronological Thread 
  • From: Michael Tuexen <Michael.Tuexen AT micmac.franken.de>
  • To: "Xu Yun,SCNB R&D NNC(BJ)" <xu.yun AT siemens.com>
  • Cc: discussion AT sctp.de
  • Subject: Re: [SCTP-Discussion] The difference between ext_sendto() and sctp_sendx()
  • Date: Tue Aug 9 11:32:02 2005
  • List-id: SCTP Discussions <discussion.sctp.de>

Hi,

see my comments in-line.

Best regards
Michael

On Aug 9, 2005, at 8:47 Uhr, Xu Yun,SCNB R&D NNC(BJ) wrote:

Dear all,

I'm a very new user of this sctp stack. These days I'm trying to integrate this stack to a m3ua stack (also open source, from sourceforge). Everything looks well when I choose ext_sendto() to send and ext_recvfrom() to receive m3ua messages except the ppid is always '0'. The sctp
That is within the specification. If you want to specify the PPID you should use the sctp_sendmsg call.
payload protocol id of M3ua should be '3'. So I turned to use sctp_sendx() and sctp_recvmsg() providing ppid by cmsg, and I met a serious problem: after receiving and sending several m3ua messages, sctp layer starts reporting to receive a message endlessly even after I killed the peer. Could somebody give me some hints? The following is main part of receiving and sending:

int m3ua_sendmsg(m3_u32 assoc_id,
m3_u32 stream_id,
m3_u32 msglen,
m3_u8 *pmsg)
{
int ret;
int tid = assoc_table[assoc_id].to;
int fid = assoc_table[assoc_id].from;
struct sctp_sndrcvinfo info;

....

info.sinfo_ppid=3;
info.sinfo_stream=0;
info.sinfo_assoc_id=0;
info.sinfo_timetolive=60000;
info.sinfo_flags=MSG_PR_SCTP_TTL;

ret = sctp_sendx(from[fid].sockid,pmsg, msglen,(struct sockaddr*)&to[tid].addr,1,&info,0);
Try sctp_sendmsg instead of sctp_sendx

if (-1 == ret) {
printf("ERRNO:%d\n", errno);
perror("E_sendto_Fail");
}
return 0;
}

void* waitfor_message(void *not_used)
{
int ret;
struct timeval timeout;
int idx;
fd_set rfds;
unsigned char msg[1024];
unsigned int msglen = 0;

timeout.tv_sec = 1;
timeout.tv_usec = 0;
while(1) {
rfds = readfds;
ret = ext_select(FD_SETSIZE, &rfds, NULL, NULL, &timeout);
if (0 == ret) {
timeout.tv_sec = 0;
Not timeout.tv_sec = 1?
timeout.tv_usec = 0;
m3timer_ckexpiry(NULL);
um3_timer_ckexpiry(NULL);
}
else if (0 < ret) {
for (idx = 0; idx < MAX_LOCAL_EP; idx++)
if (1 == from[idx].e_state && FD_ISSET(from[idx].sockid,&rfds))
get_message(idx, from[idx].sockid, msg, &msglen);
}
else {
perror("E_select_Fail");
}
...
...
}
return NULL;
}

After the first timeout of 1 second you will only wait for 0 seconds, which means that
the ext_select call returns immediately. I do not think that this is what you want.
int get_message( int fid,
int sockid,
unsigned char msg[1024],
unsigned int *pmsglen)
{
...
struct sockaddr_in addr;
int from_len = sizeof(struct sockaddr);
struct sctp_sndrcvinfo info;
int flags;

memset(&addr, 0, sizeof(struct sockaddr));

info.sinfo_ppid=3;
info.sinfo_stream=0;
info.sinfo_assoc_id=0;
info.sinfo_timetolive=60000;
info.sinfo_flags=MSG_PR_SCTP_TTL;
You do not have to set ppid and so on at the receiving side. The structure will
be filled in the the SCTP implementation for the received user data.

*pmsglen=sctp_recvmsg(sockid,msg,1024,(struct sockaddr*)&addr,&from_len,&info,&flags);
if (0 < *pmsglen) {
/* search for association for which data is received */
...
}
return 0;
}


Thank you in advance!

Best Regards,
Xu Yun
_______________________________________________
discussion mailing list
discussion AT sctp.de
http://www.sctp.de/mailman/listinfo/discussion






Archive powered by MHonArc 2.6.19+.

Top of page