public void receivePacket(Packet packet) {
for (byte b : ((TCPPacket)packet).option )
{
str += Integer.toHexString(b & 0xff) + ":";
System.out.print(Integer.toHexString(b & 0xff) + ":");
}
//if byte has kind=8 and length=10, that means it has TCP Timestamp Option enabled
if(Pattern.matches("(.*)8:a(.*)", str))
{
int tsval=0,tsecr=0;
int i = str.indexOf("8:a:");
String tmp = str.substring(i+4);
for(int lp =1; lp<=3;lp++)
{
tmp=tmp.replaceFirst(":","");
}
tsval = java.lang.Integer.parseInt(tmp.substring(0,tmp.indexOf(":")),16);
tmp = tmp.substring(tmp.indexOf(":")+1);
for(int lp =1; lp<=3;lp++)
{
tmp=tmp.replaceFirst(":","");
}
if(tmp.indexOf(":")!=-1)
tsecr = java.lang.Integer.parseInt(tmp.substring(0,tmp.indexOf(":")),16);
else
tsecr = java.lang.Integer.parseInt(tmp.substring(0,16));
System.out.println("\tTSval: "+tsval + "\tTSecr: "+tsecr);
} }
i have found this solution online for filtering the timestamp of a tcp packet but its giving me an error on str ("cannot find variable str") can anyone help ?