void update_summary_cs(struct timespec dmaci,int len,int num,int t){ // t is the type of wifi bands struct timespec tmp1={0}; copy_timespec(&tmp1,&summary[t].overall_busywait); summary[t].overall_busywait = timespec_add(tmp1,dmaci); summary[t].mine_packets = summary[t].mine_packets + num; summary[t].mine_bytes = summary[t].mine_bytes + len; }
static void copy_root_item(struct btrfs_util_subvolume_info *subvol, const struct btrfs_root_item *root) { subvol->flags = le64_to_cpu(root->flags); memcpy(subvol->uuid, root->uuid, sizeof(subvol->uuid)); memcpy(subvol->parent_uuid, root->parent_uuid, sizeof(subvol->parent_uuid)); memcpy(subvol->received_uuid, root->received_uuid, sizeof(subvol->received_uuid)); subvol->generation = le64_to_cpu(root->generation); subvol->ctransid = le64_to_cpu(root->ctransid); subvol->otransid = le64_to_cpu(root->otransid); subvol->stransid = le64_to_cpu(root->stransid); subvol->rtransid = le64_to_cpu(root->rtransid); copy_timespec(&subvol->ctime, &root->ctime); copy_timespec(&subvol->otime, &root->otime); copy_timespec(&subvol->stime, &root->stime); copy_timespec(&subvol->rtime, &root->rtime); }
void check_print(struct packet_info *p,int t){ copy_timespec(&inf_end_timestamp,&p->te); //printf("start time is %f, end time is %f\n",inf_start_timestamp,inf_end_timestamp); if (timespec_sub(inf_end_timestamp,inf_start_timestamp).tv_sec > FREQUENT_UPDATE_PERIOD_SECONDS) { //print out print_inf(W2G); print_inf(W5G); //print_summary(); memset(cs,0,sizeof(cs)); memset(lccs_client,0,sizeof(lccs_client)); ht[0].tv_sec = 0; ht[0].tv_nsec = 0; ht[1].tv_sec = 0; ht[1].tv_nsec = 0; reset_summary(W2G); reset_summary(W5G); copy_timespec(&inf_start_timestamp,&inf_end_timestamp); } }
int cal_inf(struct packet_info * p){ int t; // type of bands t = wap_type(p->dev_name); if(t == -1){ printk(KERN_DEBUG "[warning]wAP dosen't have this kind of interface!\n"); return; } if(p->phy_rate == 0 && p->ampdu != 2){ printk(KERN_DEBUG "[warning]There is one packet whose phyrate == 0!\n"); memcpy(&last_p[t],p,sizeof(last_p[t]));// update last p previous_is_ampdu[t] = p->ampdu; return; } struct timespec th={0},transmit={0},dmaci={0},tmp1={0},tmp2={0},difs={0},tr={0}; if (previous_is_ampdu[t] != 0){ if (p->ampdu != 2){ dmaci = cal_dmaci_ampdu(t); if (ampdu[t].retry > 0){ // all packets are retried packets update_summary_ht(dmaci,ampdu[t].len*ampdu[t].num,ampdu[t].num,t); }else{ divide_inf(backup_store[t],ampdu[t].th,ampdu[t].te,dmaci,0,1,t); update_summary_cs(dmaci,ampdu[t].len*ampdu[t].num,1,t);//overall busywait, ampdu regards as one } clear_timespec(&tmp1); tmp1 = timespec_sub(ampdu[t].te,ampdu[t].th); summary[t].overall_extra_time = timespec_add(summary[t].overall_extra_time,tmp1);//overall transmit summary[t].wing = summary[t].wing + timespec_div(dmaci,tmp1); printk(KERN_DEBUG "[ampdu,%ld.%ld]%ld.%ld,%d,%ld.%ld,%ld.%ld,ifindex=%d,%s,num=%d,size=%d,retry=%d\n",ampdu[t].tw.tv_sec,ampdu[t].tw.tv_nsec,ampdu[t].te.tv_sec,ampdu[t].te.tv_nsec,ampdu[t].rate,dmaci.tv_sec,dmaci.tv_nsec,tmp1.tv_sec,tmp1.tv_nsec,ampdu[t].ifindex,ampdu[t].dev_name,ampdu[t].num,ampdu[t].len,ampdu[t].retry); //clear the ampdu structure memset(&du[t],0,sizeof(ampdu[t])); } } if(p->ampdu == 1){ //first packet of aggregation backup_sniffer_packet(p->tw,p->te,1,t); ampdu[t].rate = p->phy_rate; ampdu[t].ifindex = p->ifindex; memcpy(ampdu[t].dev_name,p->dev_name,IFNAMSIZ); copy_timespec(&du[t].te,&p->te); copy_timespec(&du[t].last_te,&last_p[t].te); copy_timespec(&du[t].tw,&p->tw); ampdu[t].num = 1; ampdu[t].len = p->len; memcpy(&last_p[t],p,sizeof(last_p[t]));// update last p check_print(p,t); if (p->wlan_retry > 0){ ampdu[t].retry = p->wlan_retry; } previous_is_ampdu[t] = p->ampdu; }else if(p->ampdu==2){ //rest of packets of aggregation p->phy_rate = ampdu[t].rate; copy_timespec(&du[t].tw,&p->tw); ampdu[t].num = ampdu[t].num + 1; if ( p->wlan_retry >= 1){ update_ht_transmit(p->len,p->phy_rate,t); } }else{ // non-aggregation packet th.tv_sec = p->tw.tv_sec; th.tv_nsec = p->tw.tv_nsec; if (timespec_compare(&th,&last_p[t].te)<0){ th=last_p[t].te; } memcpy(&last_p[t],p,sizeof(last_p[t])); //update previous packet if (p->tw.tv_nsec == 0){ previous_is_ampdu[t] = p->ampdu; return; } transmit = cal_transmit_time(p->len,p->phy_rate); difs.tv_sec =0; difs.tv_nsec = CONST_TIME[t]*1000; tmp1 = timespec_sub(p->te,th); tmp2 = timespec_sub(tmp1,transmit); dmaci = timespec_sub(tmp2,difs); if (dmaci.tv_sec < 0 || dmaci.tv_nsec < 0){ dmaci.tv_sec = 0; dmaci.tv_nsec = 0; } if(p->wlan_retry == 0){ update_summary_cs(dmaci,p->len,1,t); divide_inf(store[t],th,p->te,dmaci,p->wlan_retry,0,t); }else{ update_summary_ht(dmaci,p->len,1,t); } summary[t].overall_extra_time = timespec_add(summary[t].overall_extra_time,tmp1); summary[t].wing = summary[t].wing + timespec_div(dmaci,tmp1); printk(KERN_DEBUG "[unampdu,%ld.%ld]%ld.%ld,%d,%ld.%ld,%ld.%ld,ifindex=%d,%s,num=%d,size=%d,retry=%d\n",p->tw.tv_sec,p->tw.tv_nsec,p->te.tv_sec,p->te.tv_nsec,p->phy_rate,dmaci.tv_sec,dmaci.tv_nsec,tmp1.tv_sec,tmp1.tv_nsec,p->ifindex,p->dev_name,1,p->len,p->wlan_retry); check_print(p,t); previous_is_ampdu[t] = p->ampdu; } }