X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drl%2Fstandard.c;h=103a23c298b965b7d216184392b7ecd2abd348c8;hb=8675c0b77ad3e361f4255ce61881a79061c5238d;hp=5c6a6d8537fe05f1f7bee39599d67e8b6a14388f;hpb=1283484fb8f6a4531219984cf4d8d54e14a2ad05;p=distributedratelimiting.git diff --git a/drl/standard.c b/drl/standard.c index 5c6a6d8..103a23c 100644 --- a/drl/standard.c +++ b/drl/standard.c @@ -86,7 +86,7 @@ standard_flow *standard_table_lookup(standard_flow_table table, const key_flow * flow->source_port = key->source_port; flow->dest_port = key->dest_port; flow->last_packet = key->packet_time; - gettimeofday(&flow->last_update, NULL); + flow->last_update = table->common->last_update; /* Add the flow to the hash list. */ flow->nexth = table->flows[hash]; @@ -221,7 +221,7 @@ int standard_table_cleanup(standard_flow_table table) { time_t now = time(NULL); while (current != NULL) { - if (current->last_packet + FLOW_IDLE_TIME <= now) { + if (current->last_packet + STD_FLOW_IDLE_TIME <= now) { /* Flow hasn't received a packet in the time limit - kill it. */ remove = current; current = current->next; @@ -242,6 +242,7 @@ void standard_table_update_flows(standard_flow_table table, struct timeval now, standard_flow *current; struct in_addr src, dst; char sip[22], dip[22]; + key_flow largest_flow_info; /* Reset statistics. */ table->common->num_flows = 0; @@ -301,6 +302,11 @@ void standard_table_update_flows(standard_flow_table table, struct timeval now, if (current->rate > maxflowrate) { maxflowrate = current->rate; + largest_flow_info.source_ip = current->source_ip; + largest_flow_info.dest_ip = current->dest_ip; + largest_flow_info.source_port = current->source_port; + largest_flow_info.dest_port = current->dest_port; + largest_flow_info.protocol = current->protocol; } if (current->rate > 51200) { @@ -308,22 +314,18 @@ void standard_table_update_flows(standard_flow_table table, struct timeval now, table->common->num_flows_20k += 1; table->common->num_flows_10k += 1; table->common->num_flows_5k += 1; - table->common->num_flows += 1; } else if (current->rate > 20480) { table->common->num_flows_20k += 1; table->common->num_flows_10k += 1; table->common->num_flows_5k += 1; - table->common->num_flows += 1; } else if (current->rate > 10240) { table->common->num_flows_10k += 1; table->common->num_flows_5k += 1; - table->common->num_flows += 1; } else if (current->rate > 5120) { table->common->num_flows_5k += 1; - table->common->num_flows += 1; - } else { - table->common->num_flows += 1; - } + } + + table->common->num_flows += 1; src.s_addr = ntohl(current->source_ip); dst.s_addr = ntohl(current->dest_ip); @@ -342,4 +344,5 @@ void standard_table_update_flows(standard_flow_table table, struct timeval now, printlog(LOG_DEBUG, "FLOW:--\n--\n"); table->common->max_flow_rate = maxflowrate; + table->common->max_flow_rate_flow_hash = table->hash_function(&largest_flow_info); }