/*----------------------------------------------------------------* |sender.cpp | |@version: 2.1 | |Last Modification: Sep 12, 2003 , by Fei | | A simple SRTP sender client for testing | | The sender client send out specified number of message of | | specified length | *----------------------------------------------------------------*/ /*----------------------------------------------------------------* | Copyright 2001-2003 Networking and Simulation Laboratory | | George Mason University, Fairfax, Virginia | | | | Permission to use, copy, modify, and distribute this | | software and its documentation for academic purposes is hereby | | granted without fee, provided that the above copyright notice | | and this permission appear in all copies and in supporting | | documentation, and that the name of George Mason University | | not be used in advertising or publicity pertaining to | | distribution of the software without specific, written prior | | permission. GMU makes no representations about the suitability | | of this software for any purposes. It is provided "AS IS" | | without express or implied warranties. All risk associated | | with use of this software is expressly assumed by the user. | *----------------------------------------------------------------*/ #include #include "srtp_api.h" /* the multicast group address */ //#define mca "226.78.2.10" #define mca "224.0.0.100" /* full command should be: * sender [len] [req_udp_port] * if mode==0, "dataid" is meanningless, and can be set to a random value. * "req_udp_port" is the UDP port that local SRTP daemon listening on for * client request, default value 8001 */ int main(int argc, char* argv[]) { int len; int i; int udp_port; int dataid; int mode; int number; unsigned long int mcg; unsigned char longbuf[MAX_M1_BUFFER_SIZE]; unsigned int message_byte; len=800; /* the default message len, in case not specified */ /** parse the command line parameters */ if(argc<4) { printf( "usage: sender [len] [req_udp_port]\n"); return -1; } dataid=atoi(argv[1]); mode=atoi(argv[2]); number=atoi(argv[3]); if(argc>=5) len=atoi(argv[4]); udp_port=0; if(argc>=6) udp_port=atoi(argv[5]); if ((mcg = inet_addr(mca)) == NULL) return(-1); /* * compose a message, wich will be send out * NOTE: when used to test throughput, the message should be filled with * random generated characters. Otherwise, the physical layer * compressing mechanism will compact the actual bits send out */ memset(longbuf, 0, MAX_M1_BUFFER_SIZE); for (i=0; i<5; i++) longbuf[i]=i; for(i=30; i<40; i++) longbuf[i]=i; longbuf[0]=89; longbuf[len-1]=60; /** print out the message that being send out */ for(i=0; i */ if(mode >0 && srmp_reg_dataid(mcg,dataid,mode)<0) { fprintf(stderr,"Failed to Register\n"); return -1; } if(mode >0) printf("Register successfuly: mca=%s, dataid=%d, mode=%d\n", mca, dataid, mode); printf("Starting to send message\n"); /** send out the message */ for(i=0; i */ if(mode >0 && srmp_unreg_dataid(mcg,dataid)<0) { fprintf(stderr,"Failed to UN-Register\n"); return -1; } if (mode>0) printf("dataid=%d un-registered\n", dataid); return(0); }