关于C语言提取数据包问题
现有一堆数据包存放在一个文本文档里。我想从中提取第一给数据包该怎么做。c语言。每个数据包的大小都不相同。
其中一部分数据包如下:
2009-06-18 17:18:19.153487 10:23:45:67:89:ab (oui Unknown) > 00:0d:61:a6:5c:ea (oui Unknown), ethertype ARP (0x0806), length 42: arp reply 192.168.2.6 is-at 10:23:45:67:89:ab (oui Unknown)
0x0000: 0001 0800 0604 0002 1023 4567 89ab c0a8 .........#Eg....
0x0010: 0206 000d 61a6 5cea c0a8 0216 ....a.\.....
2009-06-18 17:18:19.153755 00:0d:61:a6:5c:ea (oui Unknown) > 10:23:45:67:89:ab (oui Unknown), ethertype IPv4 (0x0800), length 78: (tos 0x0, ttl 64, id 35993, offset 0, flags [DF], proto: TCP (6), length: 64) 192.168.2.22.1212 > 192.168.2.6.80: S 3553733642:3553733642(0) win 65535 <mss 1460,nop,wscale 2,nop,nop,timestamp[|tcp]>
0x0000: 4500 0040 8c99 4000 4006 28b2 c0a8 0216 E..@..@.@.(.....
0x0010: c0a8 0206 04bc 0050 d3d1 ac0a 0000 0000 .......P........
0x0020: b002 ffff 2baa 0000 0204 05b4 0103 0302 ....+...........
0x0030: 0101 080a 0000 ......
2009-06-18 17:18:19.154349 10:23:45:67:89:ab (oui Unknown) > 00:0d:61:a6:5c:ea (oui Unknown), ethertype IPv4 (0x0800), length 74: (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto: TCP (6), length: 60) 192.168.2.6.80 > 192.168.2.22.1212: S 2306474322:2306474322(0) ack 3553733643 win 5792 <mss 1460,sackOK,timestamp 4294936398[|tcp]>
0x0000: 4500 003c 0000 4000 4006 b54f c0a8 0206 E..<..@.@..O....
0x0010: c0a8 0216 0050 04bc 897a 0152 d3d1 ac0b .....P...z.R....
0x0020: a012 16a0 14e5 0000 0204 05b4 0402 080a ................
0x0030: ffff 874e 0000 ...N..
2009-06-18 17:18:19.154647 00:0d:61:a6:5c:ea (oui Unknown) > 10:23:45:67:89:ab (oui Unknown), ethertype IPv4 (0x0800), length 66: (tos 0x0, ttl 64, id 35995, offset 0, flags [DF], proto: TCP (6), length: 52) 192.168.2.22.1212 > 192.168.2.6.80: ., cksum 0x7de9 (correct), ack 1 win 64240 <nop,nop,timestamp 6873352 4294936398>
0x0000: 4500 0034 8c9b 4000 4006 28bc c0a8 0216 E..4..@.@.(.....
0x0010: c0a8 0206 04bc 0050 d3d1 ac0b 897a 0153 .......P.....z.S
0x0020: 8010 faf0 7de9 0000 0101 080a 0068 e108 ....}........h..
0x0030: ffff 874e ...N