I'm trying that with the following code
IpV4Packet p = new IpV4Packet.Builder()
.dstAddr((Inet4Address) Inet4Address.getByName("172.0.0.1"))
.srcAddr((Inet4Address) Inet4Address.getByName("172.0.0.2"))
.version(IpVersion.IPV4)
.protocol(IpNumber.TCP)
.ttl(new Integer(64).byteValue())
.options(Collections.singletonList(IpV4NoOperationOption.getInstance()))
.tos(new IpV4Rfc1349Tos.Builder().tos(IpV4TosTos.DEFAULT).precedence(IpV4TosPrecedence.ROUTINE).build())
.build();
TcpPacket t = new TcpPacket.Builder()
.dstPort(new TcpPort((short)9042, "CQL"))
.srcPort(new TcpPort((short)47014, "Host"))
.correctLengthAtBuild(true)
.sequenceNumber(6)
.ack(true)
.psh(true)
.urgentPointer((short) 0)
.window((short) 229)
.build();
byte[] arr = ArrayUtils.addAll(ArrayUtils.addAll(p.getHeader().getRawData(), t.getHeader().getRawData()),Arrays.copyOfRange(buffer, 0, bytesRead ));
'arr' is what I'm writing the file, but for some reason wireshark loads the packets as "Bogus Length, must be at least 20". If I add correctLengthAtBuild(true) it shows length 20 but malformed tcp packets.
Is this what you meant?
↧