-
Notifications
You must be signed in to change notification settings - Fork 1
/
throughput_input_queue.cc
35 lines (34 loc) · 1.23 KB
/
throughput_input_queue.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
int count(struct sk_buff* skb)
{
struct iphdr *iph; //IP header
struct tcphdr *tcph; //TCP header
struct udphdr *udph; //UDP header
struct timeval tv; //time struct(second & micro second)
static int totalpacket=0;
do_gettimeofday(&tv); //get now time
_kernel_seconds_t intime=(tv.tv_sec*1000000)+tv.tv_usec; // intime = micro second
iph = ip_hdr(skb); //get IP header
if(iph->protocal==6){ //TCP packet
tcph=(struct tcphdr *)((char *)iph+(iph->ihl*4));
if(ntohs(tcph->source) == 8888) // TCP header, port number = 8888(change to your port number)
{
totalpacket++;
printk("Socket_i\t%ld\t%d\t%d\n",intime,ntohs(iph-> tot_len),totalpacket); // time, total length, total packet
}
}
if(iph->protocal==17) //UDP packet
{
udph=(struct udphdr*)((char *)iph+(iph->ihl*4)); //get UDP header
if(ntohs(udph->source) == 6970) // RTP header, port number = 6970(change to your port number)
{
totalpacket++;
printk("Darwin \t%ld\t%d\t%d\n",intime,ntohs(iph-> tot_len),totalpacket); // time, total length, total packet
}
else if(ntohs(udph->source)==7078) //linphne audio
{
totalpacket++;
printk("Socket_i\t%ld\t%d\t%d\n",intime,ntohs(iph-> tot_len),totalpacket); // time, total length, total packet
}
}
return 0;
}