ccrtp-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Ccrtp-devel] lost packets


From: Chris Read
Subject: [Ccrtp-devel] lost packets
Date: Wed, 30 Jan 2002 13:30:18 -0800 (PST)

I have modified the demo programs rtpsend and
rtpreceive to begin working with the ccRTP library.
I have changed them to send a file (poor application
for UDP, I know, but it lets me work with the code and
vary the parameters--and check results).  I find,
however that packet loss is very consistent.
Typically the first 15-40 packets come through fine,
but then about 1 in 4 packets gets lost.  I have
changed various parameters such as the size of
packets, the frequency of packets, the time stamp of
packets, etc.  One test I ran led me to believe they
are getting lost in the transmission side.  Do you
have any suggestions as to where to begin looking?

(I have attached my filesend.cpp and filereceive.cpp)

Thanks,

Chris

__________________________________________________
Do You Yahoo!?
Great stuff seeking new owners in Yahoo! Auctions! 
http://auctions.yahoo.com
#include <iostream.h>
#include <fstream.h>

#include "rtp.h"
#include <cstdlib>

#ifdef  CCXX_NAMESPACES
using namespace ost;
#endif

const int BLOCKSIZE = 1024;

/**
 * @brief This class sends a file via RTP Packets - and it could fail!
 **/
class Sender: RTPSocket {
public:
        Sender( ifstream& inFile,
                const InetHostAddress& ia, tpport_t port) :
                RTPSocket(ia)
        {
                uint32 rawblock[BLOCKSIZE];
                unsigned char *block = (unsigned char *)&rawblock[0];
                uint32 *i = &rawblock[0];
                uint32 *n = &rawblock[1];
                char *pblock = (char *)&rawblock[2];
                

                setTimeout(0);
                setExpired(1000000);
                
                if ( Connect(ia,port) < 0 ) {
                        cerr << "Could not connect" << endl;
                        exit(0);
                }

                *i = 0;
                *n = 1;
                *pblock = 0;
                while(*n != 0) {
                        inFile.read((char *)&rawblock[2], BLOCKSIZE);
                        *n = inFile.gcount();
                        putPacket((*i * 90000), RTP_PAYLOAD_JPEG, (unsigned 
char *)&rawblock[0], *n+8);
                        //putPacket((*i * (BLOCKSIZE + 8) * 100), 
RTP_PAYLOAD_JPEG, (unsigned char *)&rawblock[0], *n+8);
                        cerr << "Packet " << *i << ": " << *n << " bytes" << 
endl;
                        ccxx_sleep(1000);
                        (*i)++;
                }
                // Allow the service thread to run
                while (isSending())
                        ccxx_sleep(100);
                ccxx_sleep(100); // One last sleep, for the receiver's sake
        }
};

int
main(int argc, char *argv[])
{
        if (argc != 4) { 
                cerr << "Syntax: " << "filename host port" << endl;
                exit(1);
        }


        ifstream fs(argv[1]);           // Open input file
        if (!fs) {
                cerr << "Unable to open " << argv[1] << " for input" << endl;
                exit(1);
        }

        Sender sender(fs, InetHostAddress(argv[2]), atoi(argv[3]));
}
#include <iostream.h>

#include "rtp.h"
#include <fstream.h>
#include <cstdlib>

#ifdef  CCXX_NAMESPACES
using namespace ost;
#endif

const int BLOCKSIZE = 1024;

class Listener: RTPSocket {
private:
        enum { SIZE = 8192 };
        unsigned char buffer[SIZE];
public:
        Listener(ofstream& outFile, InetHostAddress& ia, tpport_t port) : 
RTPSocket(ia,port)
        {
                uint32 *n = (uint32 *)&buffer[4];
                uint32 *i = (uint32 *)&buffer[0];
                uint32 tS;
                uint16 sN;
                uint16 nextSn = 0;
                uint16 next = 0;

                cerr << "Here 2" << endl;
                Connect(ia,port);
                
                *n = 1;
                while (*n) {
                        tS = getFirstTimestamp();
                        sN = getFirstSequence();
                        if (tS && sN != nextSn) cerr << "Stamp: " << tS << ", 
Sequence: " << sN << endl;
//                      if (tS || sN) cerr << "Stamp: " << tS << ", Sequence: " 
<< sN << endl;
                        if ( getPacket(tS, buffer, SIZE) ) {
                                nextSn = sN + 1;
//                              cerr << "Rx: *n=" << *n << ", *i=" << *i << 
endl;
                                while (next < *i) cerr << "Missed " << next++ 
<< endl;
                                cerr << "Got " << *i << endl;
                                next++;
                                outFile.seekp(*i * BLOCKSIZE);
                                outFile.write((char *)&buffer[8], *n);
//                              cerr << "Wrote to file" << endl;
                                
                        } else {
//                              cerr << "no packet at " << tS << endl;
                                *n = 0xffffffff;
                        }
                        ccxx_sleep(10);
                }
        }
        
};

int
main(int argc, char *argv[])
{
        if (argc != 4) { 
                cerr << "Syntax: filereceive <file> <ip> <port>" << endl;
                exit(1);
        }

        ofstream fs(argv[1]);           // Open output file
        if (!fs) {
                cerr << "Unable to open " << argv[1] << " for output" << endl;
                exit(1);
        }
        cerr << "Here 0" << endl;

        InetHostAddress ia(argv[2]);
        cerr << "Here 1 - " << ia << endl;

        Listener foo(fs, ia, atoi(argv[3]));
}

reply via email to

[Prev in Thread] Current Thread [Next in Thread]