[Jnetstream-users] Error in TCP decode
Brought to you by:
voytechs
|
From: Frédéric D. <fre...@dr...> - 2008-08-05 04:09:32
|
Hi,
I have some trouble decoding IP and TCP headers. the header length and
the offset are wrongly decoded in most of the packets.
Did I do something wrong?
Regards,
Frederic Dreier
Console output -------------------------------
PACKET DUMP::
00 12 3F 19 FC 3F 00 07
84 BC A0 C0 08 00 45 00
00 28 9D 7A 40 00 2B 06
25 94 D0 50 98 03 81 AD
A2 C0 00 50 D7 59 29 F4
BC EF 33 C8 F3 C5 50 11
Vers : 4
Hlen : 4 <----- should be 5
TOS : 0
Lgt : 40
ident: 40314
flags: 2
offs : 1 <---- should be 0
TTL : 43
Prot : 6
Src : 208.80.152.3
Dst : 129.173.162.192
Console output -------------------------------
Code snipet ------------------------------
Ip4 ipHd = packet.getHeader(Ip4.class);
Tcp tcpHd = packet.getHeader(Tcp.class);
System.out.println("PACKET DUMP::");
for (int i = 0; i < 6; i++) {
for (int k = i * 8; k < ((i + 1) * 8);
k++) {
System.out.printf("%02X ",
packet.getBuffer().getBackingBuffer().get(k) & 0xFF);
}
System.out.println();
}
System.out.printf("Vers : %d\n", ipHd.ver());
System.out.printf("Hlen : %d\n", ipHd.hlen());
System.out.printf("TOS : %d\n", ipHd.tos());
System.out.printf("Lgt : %d\n", ipHd.length());
System.out.printf("ident: %d\n",
ipHd.id()&0xFFFF);
System.out.printf("flags: %d\n", ipHd.flags());
System.out.printf("offs : %d\n", ipHd.offset());
System.out.printf("TTL : %d\n", ipHd.ttl());
System.out.printf("Prot : %d\n",
ipHd.protocol());
System.out.printf("Src : %s\n", ipHd.source());
System.out.printf("Dst : %s\n",
ipHd.destination());
--------------------------------------------
|