The overall througput improvement is from 1.7544 to 2.2804 Mbps
RSSI measurement comparison:
Table1: RSSI (idle: out of 10 minutes test window)
w/o scheduling | w scheduling | |
1 | 206.74 | 207.4 |
2 | 203.6350 | 205.032 |
3 | 213.248 | 212.14 |
4 | 214.39 | 214.95 |
5 | 205.185 | 199.333 |
6 | 202.883 | 199.4467 |
Table2: RSSI (busy)
w/o scheduling | w scheduling | |
1 | 192.8689 | 191.0105 |
2 | 186.0568 | 189.0858 |
3 | 192.4553 | 194.459 |
4 | 193.6746 | 197.1952 |
5 | 182.7968 | 184.2826 |
6 | 182.3948 | 182.7943 |
/************************************************************ * UDP SEND ************************************************************/ int udp_send(cmd, data, rd) struct dbsd_param * volatile cmd; char *data; struct record *rd; { static struct timeval tp; struct timezone tzp; struct timeval esleep; int s, i, j; int total=0; /* Total Size of sended data */ int message; int sub_total; int rest, offset; struct dbsd_traffic *traffic = cmd->traffic; char *d; struct sockaddr *dest; int length; int volatile timeout_flg = OFF; //Zhibin WU, define more local variables struct timeval time_shift; float origin_rssi,cur_rssi,dead_rssi, total_rssi; //double FILE* fp1; //------------------End------------------- /* These are to avoid the optimization with the SPARC CPU's register window. */ struct dbsd_param * volatile * tmp = &cmd; /* to allocate cmd to memory */ int volatile * tmp4 = &timeout_flg; DEBUGMSG(2, "UDP_SEND: Start.\n"); if (sigsetjmp(env_alrm, 0) == 0) { /* * Initialization */ if (signal(SIGALRM, udp_send_timeout) == SIG_ERR) safe_exit(SIGNAL, "UDP_SEND.signal(SIGALRM)", strerror(errno)); INIT_RECORD(); timeval_cp(&esleep, &cmd->start_time); dest = (struct sockaddr *)&cmd->d_address; length = sizeof(cmd->d_address); WAIT_BEFORE(cmd->start_time); #ifdef DEBUGMODE WAIT_UNTIL(cmd->start_time); #else WAIT_AT(cmd->start_time); #endif alarm_at(&cmd->end_time); /* * Send Main Loop */ /* Zhibin Wu---------------------------------------------- Open the RSSI_Measurement file, read the first 30 measurments */ fp1 = fopen("rssi_mes.dat","r"); if ( fp1 == NULL) { DEBUGMSG(0, "RSSI file calc open error.\n"); } else { j = 0; total_rssi = 0.; while (!feof(fp1)) { fscanf( fp1, "%f4.0", &cur_rssi); total_rssi += cur_rssi; j++; } fclose(fp1); origin_rssi = total_rssi / j; fprintf ( stderr, "average RSSI is %f\n", origin_rssi); } //---------------------------End----------------------- message = 1; sub_total = 0; for (j=1; j<=cmd->send_times; j++) { for (i=0, traffic=cmd->traffic; i < cmd->traffic_n; i++, traffic++) { offset = 0; rest = traffic->size; while (1) { d = data + offset; *((unsigned int *)d) = htonl(total); /* XXX UDP Packet must larger than sizeof(int), 4byte*/ while ((s = sendto(cmd->fd, d, MIN(traffic->packet, rest), 0, dest, length)) < 0) /* NULL */; sub_total += traffic->packet; if (message % cmd->record_interval == 0) { RECORD(total, sub_total); sub_total = 0; } total += traffic->packet; rest -= traffic->packet; offset += traffic->packet; message++; if(rest <= 3) /* XXX */ break; } /*Zhibin Wu, ------------------------------------------------ adjust new transmission rate */ fp1 = fopen("rssi_mes.dat","r"); if ( fp1 == NULL) { DEBUGMSG(0, "RSSI file read open error.\n"); } else { fseek (fp1, -5L, SEEK_END); fscanf(fp1, "%f4.0", &cur_rssi ); // fprintf( stderr, "%d\n", (int)cur_rssi ) ; fclose (fp1); } /*The idea is that there are two ranges of the RSSI above -- 200 good, transmit as most as possible 180-200 are fair, so keep the original rate belwo 180--- reduce to 1 packet per 100ms. */ if (cur_rssi >= 200) timeval_put(&time_shift, 0.01); else if (cur_rssi<180) timeval_put(&time_shift, 0.1); else timeval_cp(&time_shift, &traffic->esleep); //-------------End Change by Zhibin USLEEP2(traffic->isleep, traffic->isleep_flag); WAIT_AT2(esleep, time_shift, traffic->esleep_flag); //Zhibin Modified } } } else { timeout_flg = ON; DEBUGMSG(1, "*Time Out!*\n"); } /* * Data Transfer End. */ alarm(0); wait_at(&cmd->end_time); sleep(END_TIME_OFFSET1); DEBUGMSG(2, "UDP_SEND: END.\n"); return timeout_flg; } |
static int queue_pos_for_pkt ( struct airo_queue*
q, int pkt_length ) { int new_tail, head; head = q->pos[q->head_pos] ; new_tail = q->pos[q->tail_pos] + q->pktlen[q->tail_pos]; if (BUF_SIZE - new_tail > pkt_length ) return new_tail; if ( head > pkt_length) return 0; // if no places for the packet return -1; } |