diff --git a/src/org/ice4j/pseudotcp/PseudoTCPBase.java b/src/org/ice4j/pseudotcp/PseudoTCPBase.java index 15da840..4dcae1d 100755 --- a/src/org/ice4j/pseudotcp/PseudoTCPBase.java +++ b/src/org/ice4j/pseudotcp/PseudoTCPBase.java @@ -793,7 +793,7 @@ public class PseudoTCPBase long now = Now(); - byte[] buffer = new byte[MAX_PACKET]; + byte[] buffer = new byte[HEADER_SIZE + (int)len]; long_to_bytes(m_conv, buffer, 0); long_to_bytes(seq, buffer, 4); long_to_bytes(m_rcv_nxt, buffer, 8); @@ -844,6 +844,39 @@ public class PseudoTCPBase return WriteResult.WR_SUCCESS; } + /** + * Method can be used in some debugging utilities + */ + public static String parseSeg(byte[] buffer, int size) + { + if (size < 12) + { + return null; + } + + Segment seg = new Segment(); + seg.conv = bytes_to_long(buffer, 0); + seg.seq = bytes_to_long(buffer, 4); + seg.ack = bytes_to_long(buffer, 8); + seg.flags = buffer[13]; + seg.wnd = bytes_to_short(buffer, 14); + + seg.tsval = bytes_to_long(buffer, 16); + seg.tsecr = bytes_to_long(buffer, 20); + + seg.data = copy_buffer(buffer, HEADER_SIZE, size - HEADER_SIZE); + seg.len = size - HEADER_SIZE; + String data="data: "; + for(byte b : seg.data) + { + data += b; + } + return "segment " + " "+data; + } + /** * Creates new segment from the data in buffer which is processed * by the protocol. @@ -952,9 +985,11 @@ public class PseudoTCPBase //if ((seg.flags & FLAG_RST) == 0) { // packet(tcb, seg.ack, 0, FLAG_RST, 0, 0); //} - closedown(new IOException( - debugName + " wrong conversation number, this: " + m_conv - + " remote: " + seg.conv)); + //closedown(new IOException( + // debugName + " wrong conversation number, this: " + m_conv + // + " remote: " + seg.conv)); + logger.info(debugName + " wrong conversation number, this: " + m_conv + + " remote: " + seg.conv); return false; } diff --git a/src/org/ice4j/pseudotcp/PseudoTcpSocketImpl.java b/src/org/ice4j/pseudotcp/PseudoTcpSocketImpl.java index 1f40a69..50b9fe2 100755 --- a/src/org/ice4j/pseudotcp/PseudoTcpSocketImpl.java +++ b/src/org/ice4j/pseudotcp/PseudoTcpSocketImpl.java @@ -20,7 +20,7 @@ public class PseudoTcpSocketImpl * The logger. */ private static final java.util.logging.Logger logger = - java.util.logging.Logger.getLogger(PseudoTCPBase.class.getName()); + java.util.logging.Logger.getLogger(PseudoTcpSocketImpl.class.getName()); /** * Pseudotcp logic instance */ @@ -84,6 +84,8 @@ public class PseudoTcpSocketImpl public PseudoTcpSocketImpl(long conv_id, DatagramSocket sock) { pseudoTcp = new PseudoTCPBase(this, conv_id); + //Default MTU + setMTU(1450); this.socket = sock; } @@ -411,7 +413,7 @@ public class PseudoTcpSocketImpl { logger.log( Level.FINER, - "TCP READABLE data available for reading: "); + "TCP READABLE data available for reading: "+tcp.GetAvailable()); read_notify.notifyAll(); } } @@ -768,19 +770,19 @@ public class PseudoTcpSocketImpl while (true) { logger.log(Level.FINER, "Read Recv"); - read = pseudoTcp.Recv(buffer, offset, length); - if (logger.isLoggable(Level.FINER)) - { - logger.log(Level.FINER, "Read Recv read count: " + read); - } - if (read > 0) - { - return read; - } try { synchronized (read_notify) { + read = pseudoTcp.Recv(buffer, offset, length); + if (logger.isLoggable(Level.FINER)) + { + logger.log(Level.FINER, "Read Recv read count: " + read); + } + if (read > 0) + { + return read; + } logger.log(Level.FINER, "Read wait for data available"); read_notify.wait(); if (logger.isLoggable(Level.FINER))