Exemplo n.º 1
0
inline void wd11c00_17_device::write_data(uint8_t data)
{
	if (m_status & STATUS_BUSY)
	{
		m_out_ramwr_cb(m_ra & 0x7ff, data);

		increment_address();
	}
}
Exemplo n.º 2
0
int sender(int nAddr, int nStream, float bandwidth, int packet_size, int test_time, int test_inc, char *addr, int start_port, int verbose){
    int i, j, pid, k;
	char bw[20];
	sprintf(bw, "%fm",bandwidth);
	char ttime[8];
	m_itoa(test_time, ttime);
	char pktsize[8];
	m_itoa(packet_size, pktsize);
	for (k = 0; k < 8; k++){
		if (pktsize[k] == '\0'){
			pktsize[k] = 'B';
			pktsize[k + 1] = '\0';
			break;
		}
	}
	k = 1;
	if (test_inc == 0) k = nAddr;
	int n = 1;
	signal(SIGCHLD, SIG_IGN);
	while(k <= nAddr ){	
		char *plural_s = "";
		if (nStream > 1) plural_s = "s";
		char *plural_a = "";
		if (nAddr > 1) plural_a = "es";
		if (verbose == 1) printf("Test %d: Sending to %d/%d Address%s (starting at %s:%d) over %d stream%s, at %.2f mbps for %d seconds.\n", n, k, nAddr, plural_a, addr, start_port,nStream,plural_s, bandwidth, test_time);
		for(i = 0; i < k; i++) {
			for (j = 0; j < nStream; j++){
				pid = fork();
			    if(pid < 0) {
			        printf("Error");
			        return 0;
			    } else if (pid == 0) {
					int port = start_port + i *nStream + j;
					char p[6];
					m_itoa(port, p);
					
					char fn[20];
					sprintf(fn, "%d.%d.%d.txt",i,j,k);					
					execl("/usr/bin/iperf", "/usr/bin/iperf", "-c", increment_address(addr, i), "-u", "-T", "32", "-l", pktsize, "-p", p, "-x", "CDMSV", "-t", ttime, "-b", bw,"-o",fn, NULL);
			        exit(0);
			    } else  {
					continue;
			    }
			}
		}
		n++;
		sleep(test_time + 4);		
		if (k == nAddr) break;
		if (k == 1 && test_inc != 1) k = 0;
		k += test_inc;
		if (k > nAddr) k = nAddr;
	}
	return 0;
}
Exemplo n.º 3
0
inline uint8_t wd11c00_17_device::read_data()
{
	uint8_t data = 0;

	if (m_status & STATUS_BUSY)
	{
		data = m_in_ramcs_cb(m_ra & 0x7ff);

		increment_address();
	}

	return data;
}
Exemplo n.º 4
0
inline UINT8 wd11c00_17_device::read_data()
{
	UINT8 data = 0;

	if (m_status & STATUS_BUSY)
	{
		data = m_in_ramcs_func(m_ra & 0x7ff);

		increment_address();
	}

	return data;
}
Exemplo n.º 5
0
int open_sockets(int n_addr, int n_stream, int start_port, char *start_addr){
	int i,k;
	for (i = 0; i < n_addr; i++){
		char addr[25];
		for (k = 0; k < n_stream; k++){
			int ind = i * n_stream + k;
			char port[8];			
			sprintf(port, "%d", start_port + ind);
			sprintf(addr, "%s", increment_address(start_addr, i));
			sockets[ind] = mcast_recv_socket(addr, port, MULTICAST_SO_RCVBUF);
			if (sockets[ind] < 0) {
				return -1;
			}
		} 
	}
	return 0;
}
Exemplo n.º 6
0
McastResult* run_tests(int n_addr, int n_stream, char *start_addr, int startPort, int bufLen, int *jitterSize, int timeout, int verbose){
	int i,j,rc;
	int n_thread = n_addr * n_stream;
	pthread_t thr[n_thread];
	mthread_data_t thr_data[n_thread];
    pthread_attr_t thread_attr;
	pthread_attr_init(&thread_attr);
	pthread_attr_setstacksize(&thread_attr , PTHREAD_STACK_MIN );
	
	char *plural_s = "";
	if (n_stream > 1) plural_s = "s";
	char *plural_a = "";
	if (n_addr > 1) plural_a = "es";
	if (verbose == 1){
		printf("Receiving from %d Multicast Address%s (starting at %s:%d) over %d stream%s.\n", n_addr, plural_a, start_addr, startPort, n_stream, plural_s);
	}
	for (i = 0; i < n_addr; i++){
		for (j = 0; j < n_stream; j++){
			int ind = i * n_stream + j;
			sprintf(thr_data[ind].port, "%d", startPort + ind);
			sprintf(thr_data[ind].addr, "%s", increment_address(start_addr, i));
			thr_data[ind].bufLen = bufLen;
			thr_data[ind].sock = sockets[ind];
			thr_data[ind].jitterSize = *jitterSize;
			thr_data[ind].timeout = timeout;
			thr_data[ind].stat = createMcastStat(*jitterSize);
		} 
	}
	
	// loop again to ensure things start at same time.
	for (i = 0; i < n_thread; i++){
		if ((rc = pthread_create(&thr[i], &thread_attr, run_subtest, &thr_data[i])) < 0) {
			printf("pthread_create rc: %d\n", rc);
			fprintf(stderr, "error: pthread_create, rc: %d\n", rc);
			return NULL;
		}
	} 
	
	int ntime = 0;
	for (i = 0; i < n_thread; i++){
		pthread_join(thr[i], NULL);
	}
	int nerr = 0;
	McastStat *res = createMcastStat(*jitterSize);
	for (i = 0; i < n_thread; i++){	
		McastStat *stat = thr_data[i].stat;
		if (thr_data[i].timeout == -1){
			nerr++;
		}
		else {
			ntime = stat->ttime;
			res->lost += stat->lost;
			res->rcvd += stat->rcvd;
			res->ttime += stat->ttime;
			res->bytes += stat->bytes;
			float rj = res->rollingJitter;
			for (j = 0; j < stat->used; j++){
				insertJitter(res, stat->jitters[j]);
			}
			res->rollingJitter = rj + stat->rollingJitter;		
			if (stat->used > *jitterSize){
				*jitterSize = stat->used;
			}
		}
		freeMcastStat(stat);
	}
	res->ttime += ntime * nerr;
	if (nerr >= (n_thread + 1) / 2 || computeBitrate(res) < 0.01){
		return (McastResult *)NULL;
	}	
	
	res->rollingJitter /= (n_thread - nerr);
	McastResult* r = computeMcastResult(res, n_addr, n_stream);
	freeMcastStat(res);
	return r;
}