예제 #1
0
  public void testT011ReceivedTcpHeaderChecksum() {
    TCP tcp = null;
    try {
      tcp = new TCP(1);
    } catch (IOException e) {
      Assert.fail("Exception during creation of TCP: " + e.getMessage());
    }

    // hexString copied from wireshark (empty ACK package) from specific source/destination IP
    String hexString = "dd810050334b9c1f38e0f8b65010ff37c4d20000";

    IpAddress sourceIp = IpAddress.getAddress("192.168.1.12");
    IpAddress destinationIp = IpAddress.getAddress("65.55.10.11");
    byte[] tcpData = hexStringToByteArray(hexString);

    TcpPacket tcpPacket =
        tcp
        .new TcpPacket(sourceIp.getAddress(), destinationIp.getAddress(), tcpData, tcpData.length);

    assertTrue(tcpPacket.isACK_Flag());
    assertFalse(tcpPacket.isFIN_Flag());
    assertFalse(tcpPacket.isPSH_Flag());
    assertFalse(tcpPacket.isSYN_Flag());
    assertTrue(tcpPacket.verifyChecksum());
  }