- for (PcapPacket pp : conv.getPackets()) {
- if (sb.length() != 0) {
- // only add a space if there's preceding content
- sb.append(" ");
+ // Add SYN and SYNACK at front of sequence to indicate if we saw the handshake or if recording started in
+ // the middle of the conversation.
+ for (PcapPacket syn : conv.getSynPackets()) {
+ TcpPacket.TcpHeader tcpHeader = syn.get(TcpPacket.class).getHeader();
+ if (tcpHeader.getSyn() && tcpHeader.getAck()) {
+ // Only append a space if there's preceding content.
+ appendSpaceIfNotEmpty(sb);
+ sb.append("SYNACK");
+ } else if (tcpHeader.getSyn()) {
+ if (sb.length() != 0) {
+ // If present in the trace, the client's SYN should be at the front of the list, so it should be
+ // appended as the first item.
+ throw new AssertionError("StringBuilder had content when appending SYN");
+ }
+ sb.append("SYN");