I have pcap trace file and I want to extract the time and source IP address from the packets. I'm using tcpdump and awk. Here is a sample of the file
02:00:00.001814 IP 61.31.228.1.80 > 0.106.173.16.19999: Flags [S.], seq 4049606604, ack 4044405336, win 512, length 0
02:00:00.005787 IP 61.31.228.1.80 > 0.4.173.19.13923: Flags [S.], seq 3812128115, ack 3811406374, win 512, length 0
02:00:00.005799 IP 74.54.182.242.80 > 0.176.229.61.43527: Flags [S.], seq 61247722, ack 352633207, win 65535, options [mss 1460,nop,nop,sackOK], length 0
Then I applied the awk to extract the time and source IP address in csv file:
02:00:00.001814,0.106.173.16.19999:
02:00:00.005787,0.4.173.19.13923:
02:00:00.005799,0.176.229.61.43527:
I'm only interested in the last bit of the time and I want to get rid of the ":" at the end of the source ip. I have used
awk '{print $1 "," $5}'
Any suggestions?
Try this :
awk -F'[:. ]' '$5=="IP"{print $4","$12"."$13"."$14"."$15}'
001814,0.106.173.16
005787,0.4.173.19
005799,0.176.229.61