problems with multicast

Amos Tibaldi <[email protected]> Sat, 27 Mar 2010 21:36:39 +0100
Newsgroups gmane.comp.gnu.ccrtp.devel
Message-ID <[email protected]>
--===============1173980596==
Content-Type: multipart/alternative;
	boundary="_91675451-b108-437e-9910-e63a30ebc062_"

--_91675451-b108-437e-9910-e63a30ebc062_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable


Hello=2C

I am trying to send and receive multicast packet over rtp=3B=20
I have configured 2 PCs connected with ethernet and have issued the command=
 "ip r add 224.0.0.0/4 dev eth0" on both the PCs.
The sender program sends correctly the packets (I can see them with wiresha=
rk on the receiver machine)=2C but the receiver program cannot receive them=
.
What could be the problem? I attach the code....
Thanks in advance...
------------------------rtpsender.cpp
#include <cstdio>
#include <ctime>
#include <ccrtp/rtp.h>

using namespace ost=3B
using namespace std=3B

class ccRTPImageSender: public Thread
{
private:
    static const int RECEIVER_PORT =3D 1235=3B
    static const int TRANSMITTER_PORT =3D 46016=3B
    RTPSession *socket=3B
    InetMcastAddress local_ip=3B
    uint32 ssrc=3B
public:
    ccRTPImageSender(){
        local_ip =3D "224.0.0.1"=3B
        socket =3D new RTPSession(local_ip=2C TRANSMITTER_PORT)=3B
        ssrc =3D socket->getLocalSSRC()=3B
    }
    ~ccRTPImageSender(){
        terminate()=3B
        delete socket=3B
    }
    void run(void){   =20
        socket->setSchedulingTimeout(20000)=3B
        socket->setExpireTimeout(3000000)=3B
        socket->addDestination(local_ip=2C RECEIVER_PORT)=3B
        uint32 timestamp =3D 0=3B
        socket->setPayloadFormat(StaticPayloadFormat(sptMP2T))=3B
        socket->startRunning()=3B
        for( int i =3D 0 =3B true =3Bi++ ){
cout << "sending" <<endl=3B
            unsigned char salute[50]=3B
            snprintf((char *)salute=2C50=2C "Hello=2C brave gnu world (#%u)=
!"=2Ci)=3B
            time_t sending_time =3D time(NULL)=3B
            if ( 0 =3D=3D i ){
                timestamp =3D socket->getCurrentTimestamp()=3B
            } else {
                timestamp +=3D socket->getCurrentRTPClockRate()=3B
            }   =20

            socket->putData(timestamp=2Csalute=2C
                    strlen((char *)salute)+1)=3B
            Thread::sleep(1000)=3B
        }
    }
}=3B

int main(int argc=2C char *argv[])
{
    ccRTPImageSender *transmitter =3D new ccRTPImageSender=3B
    transmitter->start()=3B
    cin.get()=3B
    delete transmitter=3B
    return 0=3B
}

-----------------------rtpreceiver.cpp
#include <cstdio>
#include <ctime>
#include <stdlib.h>
#include <ccrtp/rtp.h>

using namespace ost=3B
using namespace std=3B


class ccRTPImageReceiver
{
private:
    static const int RECEIVER_PORT =3D 1235=3B
    static const int TRANSMITTER_PORT =3D 46016=3B
    RTPSession *socket=3B
    InetMcastAddress local_ip=3B
    uint32 ssrc=3B
public:
    ccRTPImageReceiver(){
        local_ip =3D "224.0.0.1"=3B
        socket =3D new RTPSession(local_ip=2C RECEIVER_PORT)=3B
        ssrc =3D socket->getLocalSSRC()=3B
        socket->setSchedulingTimeout(20000)=3B
        socket->setExpireTimeout(3000000)=3B

InetHostAddress vaio =3D "10.10.10.11"=3B
        socket->addDestination(vaio=2C TRANSMITTER_PORT)=3B
        socket->setPayloadFormat(StaticPayloadFormat(sptMP2T))=3B
        socket->startRunning()=3B
    }
    ~ccRTPImageReceiver(){
        terminate()=3B
        delete socket=3B
    }
    void * getData(){   =20
        const AppDataUnit *adu =3D NULL=3B
        while ( NULL =3D=3D adu ) {
            Thread::sleep(10)=3B
            adu =3D socket->getData(socket->getFirstTimestamp())=3B
        }
        char * buffer =3D (char *) malloc(3000)=3B
        strcpy((char*)buffer=2C (const char*)adu->getData())=3B
        delete adu=3B
        return (void*) buffer=3B
    }
    void deleteData(void * data)
    {
        free(data)=3B
    }
}=3B

int main(int argc=2C char *argv[])
{
    ccRTPImageReceiver receiver=3B
    for(=3B true=3B )
    {
        void * theData =3D receiver.getData()=3B
        printf("Rec: %s\n"=2C (char*) theData)=3B
        receiver.deleteData(theData)=3B
    }
    cin.get()=3B
    return 0=3B
}

 		 	   		 =20
_________________________________________________________________
Personalizza il tuo Messenger con nuove e divertenti Emoticon
http://www.pimpit.it/emoticon.html=

--_91675451-b108-437e-9910-e63a30ebc062_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<html>
<head>
<style><!--
.hmmessage P
{
margin:0px=3B
padding:0px
}
body.hmmessage
{
font-size: 10pt=3B
font-family:Verdana
}
--></style>
</head>
<body class=3D'hmmessage'>
Hello=2C<br><br>I am trying to send and receive multicast packet over rtp=
=3B <br>I have configured 2 PCs connected with ethernet and have issued the=
 command "ip r add 224.0.0.0/4 dev eth0" on both the PCs.<br>The sender pro=
gram sends correctly the packets (I can see them with wireshark on the rece=
iver machine)=2C but the receiver program cannot receive them.<br>What coul=
d be the problem? I attach the code....<br>Thanks in advance...<br>--------=
----------------rtpsender.cpp<br>#include &lt=3Bcstdio&gt=3B<br>#include &l=
t=3Bctime&gt=3B<br>#include &lt=3Bccrtp/rtp.h&gt=3B<br><br>using namespace =
ost=3B<br>using namespace std=3B<br><br>class ccRTPImageSender: public Thre=
ad<br>{<br>private:<br>&nbsp=3B&nbsp=3B&nbsp=3B static const int RECEIVER_P=
ORT =3D 1235=3B<br>&nbsp=3B&nbsp=3B&nbsp=3B static const int TRANSMITTER_PO=
RT =3D 46016=3B<br>&nbsp=3B&nbsp=3B&nbsp=3B RTPSession *socket=3B<br>&nbsp=
=3B&nbsp=3B&nbsp=3B InetMcastAddress local_ip=3B<br>&nbsp=3B&nbsp=3B&nbsp=
=3B uint32 ssrc=3B<br>public:<br>&nbsp=3B&nbsp=3B&nbsp=3B ccRTPImageSender(=
){<br>&nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B local_ip =3D "224.0=
.0.1"=3B<br>&nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B socket =3D ne=
w RTPSession(local_ip=2C TRANSMITTER_PORT)=3B<br>&nbsp=3B&nbsp=3B&nbsp=3B &=
nbsp=3B&nbsp=3B&nbsp=3B ssrc =3D socket-&gt=3BgetLocalSSRC()=3B<br>&nbsp=3B=
&nbsp=3B&nbsp=3B }<br>&nbsp=3B&nbsp=3B&nbsp=3B ~ccRTPImageSender(){<br>&nbs=
p=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B terminate()=3B<br>&nbsp=3B&nb=
sp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B delete socket=3B<br>&nbsp=3B&nbsp=3B=
&nbsp=3B }<br>&nbsp=3B&nbsp=3B&nbsp=3B void run(void){&nbsp=3B&nbsp=3B&nbsp=
=3B <br>&nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B socket-&gt=3BsetS=
chedulingTimeout(20000)=3B<br>&nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbs=
p=3B socket-&gt=3BsetExpireTimeout(3000000)=3B<br>&nbsp=3B&nbsp=3B&nbsp=3B =
&nbsp=3B&nbsp=3B&nbsp=3B socket-&gt=3BaddDestination(local_ip=2C RECEIVER_P=
ORT)=3B<br>&nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B uint32 timesta=
mp =3D 0=3B<br>&nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B socket-&gt=
=3BsetPayloadFormat(StaticPayloadFormat(sptMP2T))=3B<br>&nbsp=3B&nbsp=3B&nb=
sp=3B &nbsp=3B&nbsp=3B&nbsp=3B socket-&gt=3BstartRunning()=3B<br>&nbsp=3B&n=
bsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B for( int i =3D 0 =3B true =3Bi++ ){=
<br>cout &lt=3B&lt=3B "sending" &lt=3B&lt=3Bendl=3B<br>&nbsp=3B&nbsp=3B&nbs=
p=3B &nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B unsigned char salute=
[50]=3B<br>&nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=
=3B&nbsp=3B snprintf((char *)salute=2C50=2C "Hello=2C brave gnu world (#%u)=
!"=2Ci)=3B<br>&nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nb=
sp=3B&nbsp=3B time_t sending_time =3D time(NULL)=3B<br>&nbsp=3B&nbsp=3B&nbs=
p=3B &nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B if ( 0 =3D=3D i ){<b=
r>&nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=
=3B &nbsp=3B&nbsp=3B&nbsp=3B timestamp =3D socket-&gt=3BgetCurrentTimestamp=
()=3B<br>&nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B=
&nbsp=3B } else {<br>&nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B &nbs=
p=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B timestamp +=3D socket-&gt=3Bg=
etCurrentRTPClockRate()=3B<br>&nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbs=
p=3B &nbsp=3B&nbsp=3B&nbsp=3B }&nbsp=3B&nbsp=3B&nbsp=3B <br><br>&nbsp=3B&nb=
sp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B socket-&gt=
=3BputData(timestamp=2Csalute=2C<br>&nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=
=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=
=3B&nbsp=3B strlen((char *)salute)+1)=3B<br>&nbsp=3B&nbsp=3B&nbsp=3B &nbsp=
=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B Thread::sleep(1000)=3B<br>&nbs=
p=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B }<br>&nbsp=3B&nbsp=3B&nbsp=3B=
 }<br>}=3B<br><br>int main(int argc=2C char *argv[])<br>{<br>&nbsp=3B&nbsp=
=3B&nbsp=3B ccRTPImageSender *transmitter =3D new ccRTPImageSender=3B<br>&n=
bsp=3B&nbsp=3B&nbsp=3B transmitter-&gt=3Bstart()=3B<br>&nbsp=3B&nbsp=3B&nbs=
p=3B cin.get()=3B<br>&nbsp=3B&nbsp=3B&nbsp=3B delete transmitter=3B<br>&nbs=
p=3B&nbsp=3B&nbsp=3B return 0=3B<br>}<br><br>-----------------------rtprece=
iver.cpp<br>#include &lt=3Bcstdio&gt=3B<br>#include &lt=3Bctime&gt=3B<br>#i=
nclude &lt=3Bstdlib.h&gt=3B<br>#include &lt=3Bccrtp/rtp.h&gt=3B<br><br>usin=
g namespace ost=3B<br>using namespace std=3B<br><br><br>class ccRTPImageRec=
eiver<br>{<br>private:<br>&nbsp=3B&nbsp=3B&nbsp=3B static const int RECEIVE=
R_PORT =3D 1235=3B<br>&nbsp=3B&nbsp=3B&nbsp=3B static const int TRANSMITTER=
_PORT =3D 46016=3B<br>&nbsp=3B&nbsp=3B&nbsp=3B RTPSession *socket=3B<br>&nb=
sp=3B&nbsp=3B&nbsp=3B InetMcastAddress local_ip=3B<br>&nbsp=3B&nbsp=3B&nbsp=
=3B uint32 ssrc=3B<br>public:<br>&nbsp=3B&nbsp=3B&nbsp=3B ccRTPImageReceive=
r(){<br>&nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B local_ip =3D "224=
.0.0.1"=3B<br>&nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B socket =3D =
new RTPSession(local_ip=2C RECEIVER_PORT)=3B<br>&nbsp=3B&nbsp=3B&nbsp=3B &n=
bsp=3B&nbsp=3B&nbsp=3B ssrc =3D socket-&gt=3BgetLocalSSRC()=3B<br>&nbsp=3B&=
nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B socket-&gt=3BsetSchedulingTimeout(=
20000)=3B<br>&nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B socket-&gt=
=3BsetExpireTimeout(3000000)=3B<br><br>InetHostAddress vaio =3D "10.10.10.1=
1"=3B<br>&nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B socket-&gt=3Badd=
Destination(vaio=2C TRANSMITTER_PORT)=3B<br>&nbsp=3B&nbsp=3B&nbsp=3B &nbsp=
=3B&nbsp=3B&nbsp=3B socket-&gt=3BsetPayloadFormat(StaticPayloadFormat(sptMP=
2T))=3B<br>&nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B socket-&gt=3Bs=
tartRunning()=3B<br>&nbsp=3B&nbsp=3B&nbsp=3B }<br>&nbsp=3B&nbsp=3B&nbsp=3B =
~ccRTPImageReceiver(){<br>&nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B=
 terminate()=3B<br>&nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B delete=
 socket=3B<br>&nbsp=3B&nbsp=3B&nbsp=3B }<br>&nbsp=3B&nbsp=3B&nbsp=3B void *=
 getData(){&nbsp=3B&nbsp=3B&nbsp=3B <br>&nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&n=
bsp=3B&nbsp=3B const AppDataUnit *adu =3D NULL=3B<br>&nbsp=3B&nbsp=3B&nbsp=
=3B &nbsp=3B&nbsp=3B&nbsp=3B while ( NULL =3D=3D adu ) {<br>&nbsp=3B&nbsp=
=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B Thread::sleep=
(10)=3B<br>&nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=
=3B&nbsp=3B adu =3D socket-&gt=3BgetData(socket-&gt=3BgetFirstTimestamp())=
=3B<br>&nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B }<br>&nbsp=3B&nbsp=
=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B char * buffer =3D (char *) malloc(3000=
)=3B<br>&nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B strcpy((char*)buf=
fer=2C (const char*)adu-&gt=3BgetData())=3B<br>&nbsp=3B&nbsp=3B&nbsp=3B &nb=
sp=3B&nbsp=3B&nbsp=3B delete adu=3B<br>&nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nb=
sp=3B&nbsp=3B return (void*) buffer=3B<br>&nbsp=3B&nbsp=3B&nbsp=3B }<br>&nb=
sp=3B&nbsp=3B&nbsp=3B void deleteData(void * data)<br>&nbsp=3B&nbsp=3B&nbsp=
=3B {<br>&nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B free(data)=3B<br=
>&nbsp=3B&nbsp=3B&nbsp=3B }<br>}=3B<br><br>int main(int argc=2C char *argv[=
])<br>{<br>&nbsp=3B&nbsp=3B&nbsp=3B ccRTPImageReceiver receiver=3B<br>&nbsp=
=3B&nbsp=3B&nbsp=3B for(=3B true=3B )<br>&nbsp=3B&nbsp=3B&nbsp=3B {<br>&nbs=
p=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B void * theData =3D receiver.g=
etData()=3B<br>&nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=3B&nbsp=3B printf("Re=
c: %s\n"=2C (char*) theData)=3B<br>&nbsp=3B&nbsp=3B&nbsp=3B &nbsp=3B&nbsp=
=3B&nbsp=3B receiver.deleteData(theData)=3B<br>&nbsp=3B&nbsp=3B&nbsp=3B }<b=
r>&nbsp=3B&nbsp=3B&nbsp=3B cin.get()=3B<br>&nbsp=3B&nbsp=3B&nbsp=3B return =
0=3B<br>}<br><br> 		 	   		  <br /><hr />Oltre 20 giochi per Messenger. <a =
href=3D'http://www.messenger.it/raccoltaGiochi.aspx' target=3D'_new'>Proval=
i subito!</a></body>
</html>=

--_91675451-b108-437e-9910-e63a30ebc062_--



--===============1173980596==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Ccrtp-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/ccrtp-devel

--===============1173980596==--