int doTest() { ExtZrtpSession rx(pattern.getSsrc()+1, pattern.getReceiverAddress(), pattern.getReceiverPort()); rx.initialize("test_r.zid"); rx.setSchedulingTimeout(10000); rx.setExpireTimeout(1000000); rx.startRunning(); rx.setPayloadFormat(StaticPayloadFormat(sptPCMU)); // arbitrary number of loops to provide time to start transmitter if (!rx.addDestination(pattern.getSenderAddress(), pattern.getSenderPort()) ) { return 1; } rx.startZrtp(); for ( int i = 0; i < 5000 ; i++ ) { const AppDataUnit* adu; while ( (adu = rx.getData(rx.getFirstTimestamp())) ) { cerr << "got some data: " << adu->getData() << endl; if (*adu->getData() == 'e') { delete adu; return 0; } delete adu; } Thread::sleep(70); } return 0; }
int doTest() { // should be valid? //RTPSession tx(); RTPSession tx(InetHostAddress("localhost")); tx.setSchedulingTimeout(10000); tx.setExpireTimeout(1000000); tx.startRunning(); tx.setPayloadFormat(StaticPayloadFormat(sptPCMU)); if ( !tx.addDestination(pattern.getDestinationAddress(), pattern.getDestinationPort()) ) { return 1; } // 50 packets per second (packet duration of 20ms) uint32 period = 20; uint16 inc = tx.getCurrentRTPClockRate()/50; TimerPort::setTimer(period); for ( uint32 i = 0; i < pattern.getPacketsNumber(); i++ ) { tx.putData(i*inc, pattern.getPacketData(i), pattern.getPacketSize(i)); Thread::sleep(TimerPort::getTimer()); TimerPort::incTimer(period); } return 0; }
int doTest() { // should be valid? //RTPSession tx(); // Initialize with local address and Local port is detination port +2 - keep RTP/RTCP port pairs ExtZrtpSession tx(pattern.getSsrc(), pattern.getSenderAddress(), pattern.getSenderPort()); tx.initialize("test_t.zid"); tx.setSchedulingTimeout(10000); tx.setExpireTimeout(1000000); tx.startRunning(); tx.setPayloadFormat(StaticPayloadFormat(sptPCMU)); if (!tx.addDestination(pattern.getReceiverAddress(), pattern.getReceiverPort()) ) { return 1; } tx.startZrtp(); // 2 packets per second (packet duration of 500ms) uint32 period = 500; uint16 inc = tx.getCurrentRTPClockRate()/2; TimerPort::setTimer(period); uint32 i; for (i = 0; i < pattern.getPacketsNumber(); i++ ) { tx.putData(i*inc, pattern.getPacketData(i), pattern.getPacketSize(i)); cout << "Sent some data: " << i << endl; Thread::sleep(TimerPort::getTimer()); TimerPort::incTimer(period); } tx.putData(i*inc, (unsigned char*)"exit", 5); Thread::sleep(200); return 0; }
int doTest() { // should be valid? //RTPSession tx(); ExtZrtpSession tx(pattern.getSsrc(), pattern.getSenderAddress(), pattern.getSenderPort()); // SymmetricZRTPSession tx(pattern.getSsrc(), InetHostAddress("localhost")); tx.setSchedulingTimeout(10000); tx.setExpireTimeout(1000000); tx.startRunning(); tx.setPayloadFormat(StaticPayloadFormat(sptPCMU)); // We are sender: if (!tx.addDestination(pattern.getReceiverAddress(), pattern.getReceiverPort()) ) { return 1; } // 2 packets per second (packet duration of 500ms) uint32 period = 500; uint16 inc = tx.getCurrentRTPClockRate()/2; TimerPort::setTimer(period); uint32 i; for (i = 0; i < pattern.getPacketsNumber(); i++ ) { tx.putData(i*inc, pattern.getPacketData(i), pattern.getPacketSize(i)); cout << "Sent some data: " << i << endl; Thread::sleep(TimerPort::getTimer()); TimerPort::incTimer(period); } tx.putData(i*inc, (unsigned char*)"exit", 5); Thread::sleep(TimerPort::getTimer()); return 0; }
int doTest() { // should be valid? //RTPSession tx(); ExtZrtpSession tx(/*pattern.getSsrc(),*/ pattern.getSenderAddress(), pattern.getSenderPort()); // config.clear(); // config.setStandardConfig(); config.addAlgo(PubKeyAlgorithm, zrtpPubKeys.getByName("DH2k")); config.addAlgo(PubKeyAlgorithm, zrtpPubKeys.getByName("EC38")); config.addAlgo(PubKeyAlgorithm, zrtpPubKeys.getByName("EC25")); config.addAlgo(HashAlgorithm, zrtpHashes.getByName("S384")); // config.addAlgo(CipherAlgorithm, zrtpSymCiphers.getByName("2FS3")); // config.addAlgo(CipherAlgorithm, zrtpSymCiphers.getByName("AES3")); config.addAlgo(SasType, zrtpSasTypes.getByName("B256")); tx.initialize("test_t.zid", true, &config); // At this point the Hello hash is available. See ZRTP specification // chapter 9.1 for further information when an how to use the Hello // hash. int numSupportedVersion = tx.getNumberSupportedVersions(); cout << "TX Hello hash 0: " << tx.getHelloHash(0) << endl; cout << "TX Hello hash 0 length: " << tx.getHelloHash(0).length() << endl; if (numSupportedVersion > 1) { cout << "TX Hello hash 1: " << tx.getHelloHash(1) << endl; cout << "TX Hello hash 1 length: " << tx.getHelloHash(1).length() << endl; } tx.setUserCallback(new MyUserCallback(&tx)); tx.setSchedulingTimeout(10000); tx.setExpireTimeout(1000000); tx.startRunning(); tx.setPayloadFormat(StaticPayloadFormat(sptPCMU)); if (!tx.addDestination(pattern.getReceiverAddress(), pattern.getReceiverPort()) ) { return 1; } tx.startZrtp(); // 2 packets per second (packet duration of 500ms) uint32 period = 500; uint16 inc = tx.getCurrentRTPClockRate()/2; TimerPort::setTimer(period); uint32 i; for (i = 0; i < pattern.getPacketsNumber(); i++ ) { tx.putData(i*inc, pattern.getPacketData(i), pattern.getPacketSize(i)); cout << "Sent some data: " << i << endl; Thread::sleep(TimerPort::getTimer()); TimerPort::incTimer(period); } tx.putData(i*inc, (unsigned char*)"exit", 5); Thread::sleep(TimerPort::getTimer()); return 0; }
int doTest() { ExtZrtpSession rx( /*pattern.getSsrc()+1,*/ pattern.getReceiverAddress(), pattern.getReceiverPort()); rx.initialize("test_r.zid"); // At this point the Hello hash is available. See ZRTP specification // chapter 9.1 for further information when an how to use the Hello // hash. int numSupportedVersion = rx.getNumberSupportedVersions(); cout << "RX Hello hash 0: " << rx.getHelloHash(0) << endl; cout << "RX Hello hash 0 length: " << rx.getHelloHash(0).length() << endl; if (numSupportedVersion > 1) { cout << "RX Hello hash 1: " << rx.getHelloHash(1) << endl; cout << "RX Hello hash 1 length: " << rx.getHelloHash(1).length() << endl; } rx.setUserCallback(new MyUserCallback(&rx)); rx.setSchedulingTimeout(10000); rx.setExpireTimeout(1000000); rx.startRunning(); rx.setPayloadFormat(StaticPayloadFormat(sptPCMU)); // arbitrary number of loops to provide time to start transmitter if (!rx.addDestination(pattern.getSenderAddress(), pattern.getSenderPort()) ) { return 1; } rx.startZrtp(); for ( int i = 0; i < 5000 ; i++ ) { const AppDataUnit* adu; while ( (adu = rx.getData(rx.getFirstTimestamp())) ) { cerr << "got some data: " << adu->getData() << endl; if (*adu->getData() == 'e') { delete adu; return 0; } delete adu; } Thread::sleep(500); } return 0; }
int doTest() { RTPSession rx(pattern.getDestinationAddress(), pattern.getDestinationPort()); rx.setSchedulingTimeout(10000); rx.setExpireTimeout(1000000); rx.startRunning(); rx.setPayloadFormat(StaticPayloadFormat(sptPCMU)); // arbitrary number of loops for ( int i = 0; i < 500 ; i++ ) { const AppDataUnit* adu; while ( (adu = rx.getData(rx.getFirstTimestamp())) ) { delete adu; } Thread::sleep(7); } return 0; }
int doTest() { const uint32 NSESSIONS = 10; RTPSession rx(pattern.getDestinationAddress(),pattern.getDestinationPort()); RTPSession **tx = new RTPSession* [NSESSIONS]; for ( uint32 i = 0; i < NSESSIONS; i++ ) { tx[i] = new RTPSession(InetHostAddress("localhost")); } for ( uint32 i = 0; i < NSESSIONS; i++) { tx[i]->setSchedulingTimeout(10000); tx[i]->setExpireTimeout(1000000); tx[i]->setPayloadFormat(StaticPayloadFormat(sptPCMU)); if ( !tx[i]->addDestination(pattern.getDestinationAddress(), pattern.getDestinationPort()) ) { return 1; } } rx.setPayloadFormat(StaticPayloadFormat(sptPCMU)); rx.setSchedulingTimeout(5000); rx.setExpireTimeout(10000000); // 10 seconds! rx.startRunning(); for ( uint32 i = 0; i < NSESSIONS; i++) { tx[i]->startRunning(); } uint32 period = 20; TimerPort::setTimer(period); for ( uint32 i = 0; i < pattern.getPacketsNumber(); i++ ) { if ( i == 70 ) { RTPApplication &app = defaultApplication(); app.setSDESItem(SDESItemTypeCNAME,"foo@bar"); } for ( uint32 s = 0; s < NSESSIONS; s++) { // 50 packets per second (packet duration of 20ms) uint16 inc = tx[s]->getCurrentRTPClockRate()/50; tx[s]->putData(i*inc, pattern.getPacketData(i), pattern.getPacketSize(i)); } Thread::sleep(TimerPort::getTimer()); TimerPort::incTimer(period); } Thread::sleep(5000); for ( uint32 i = 0; i < NSESSIONS; i++ ) { delete tx[i]; } RTPSession::SyncSourcesIterator it; cout << "Sources of synchronization:" << endl; for (it = rx.begin() ; it != rx.end(); it++) { const SyncSource &s = *it; cout << s.getID(); if ( s.isSender() ) cout << " (sender) "; cout << s.getNetworkAddress() << ":" << s.getControlTransportPort() << "/" << s.getDataTransportPort(); Participant *p = s.getParticipant(); cout << " (" << p->getSDESItem(SDESItemTypeCNAME) << ") " << endl; } RTPApplication &app = defaultApplication(); RTPApplication::ParticipantsIterator ai; cout << "Participants:" << endl; for ( ai = app.begin(); ai != app.end(); ai++ ) { const Participant &p = *ai; cout << p.getSDESItem(SDESItemTypeCNAME) << endl; //cout << p.getPRIVPrefix(); } delete[] tx; return 0; }
int main(int argc, char *argv[]) { int result = 0; bool send = false; bool recv = false; char c; /* check args */ while (1) { c = getopt(argc, argv, "rsR:S:"); if (c == -1) { break; } switch (c) { case 'r': recv = true; break; case 's': send = true; break; case 'R': pattern.setReceiverAddress(new InetHostAddress(optarg)); break; case 'S': pattern.setSenderAddress(new InetHostAddress(optarg)); break; default: cerr << "Wrong Arguments, only -s and -r are accepted" << endl; } } if (send || recv) { if (send) { cout << "Running as sender" << endl; } else { cout << "Running as receiver" << endl; } } else { cerr << "No send or receive argument specificied" << endl; exit(1); } // accept as parameter if must run as --send or --recv #if 0 RecvPacketTransmissionTest *rx; SendPacketTransmissionTest *tx; // run several tests in parallel threads if ( send ) { tx = new SendPacketTransmissionTest(); tx->start(); tx->join(); } else if ( recv ) { rx = new RecvPacketTransmissionTest(); rx->start(); rx->join(); } //#endif //#if 0 ZrtpRecvPacketTransmissionTest *zrx; ZrtpSendPacketTransmissionTest *ztx; if ( send ) { ztx = new ZrtpSendPacketTransmissionTest(); ztx->start(); ztx->join(); } else if ( recv ) { zrx = new ZrtpRecvPacketTransmissionTest(); zrx->start(); zrx->join(); } #endif ZrtpRecvPacketTransmissionTestCB *zrxcb; ZrtpSendPacketTransmissionTestCB *ztxcb; if ( send ) { ztxcb = new ZrtpSendPacketTransmissionTestCB(); ztxcb->start(); ztxcb->join(); } else if ( recv ) { zrxcb = new ZrtpRecvPacketTransmissionTestCB(); zrxcb->start(); zrxcb->join(); } exit(result); }