SCTP Discussions

Text archives Help


RE: [SCTP-Discussion] The difference between ext_sendto() and sct p_sendx()


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

Hello Michael,

Thanks for your hints. I've tried sctp_sendmsg and it runs as we expected.
But the receiving problem is still there: if I calls ext_recvfrom to receive
message everything runs well, but when I turns to call sctp_recvmsg I got
endless received messages.
After checking the source code of ext_recvfrom and sctp_recvmsg, the only
major difference between the two function is the argument
'receiveNotifications' of ext_recvmsg2() function. What's the difference
behind this argument?

BTW: In my last mail, I cut some unrelated code (including some lines about
timeout operation) when I pasted it, and it may make you confused :) So the
timeout should be the problem. I paste the waitfor_message() again:

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

timeout.tv_sec = 0;
timeout.tv_usec = 0;
while(1) {
if (0 == timeout.tv_sec && 0 == timeout.tv_usec) {
timeout.tv_sec = 1;
timeout.tv_usec = 0;
}
rfds = readfds;
ret = ext_select(FD_SETSIZE, &rfds, NULL, NULL, &timeout);
if (0 == ret) {
timeout.tv_sec = 0;
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 {
printf("ERRNO:%d\n", errno);
perror("E_select_Fail");
}
while (-1 != m3ua_mgmt_ntfy(&ntfy)) {
um3_process_mgmt_ntfy(&ntfy);
}
while (-1 != m3ua_user_ntfy(&u_ntfy)) {
um3_process_user_ntfy(&u_ntfy);
}
}
return NULL;
}

Best Regards,
Xu Yun


-----Original Message-----
From: Michael Tuexen
[mailto:Michael.Tuexen AT micmac.franken.de]

Sent: Tuesday, August 09, 2005 5:30 PM
To: Xu Yun,SCNB R&D NNC(BJ)
Cc:
discussion AT sctp.de
Subject: Re: [SCTP-Discussion] The difference between ext_sendto() and
sctp_sendx()

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