Package org.jnetpcap.protocol.tcpip

Examples of org.jnetpcap.protocol.tcpip.Tcp$NoOp


    InetAddress dst = InetAddress.getByName("201.1.1.1");
    InetAddress src = InetAddress.getByName("192.168.1.1");

    Ip4 ip = packet.getHeader(new Ip4());
    Tcp tcp = packet.getHeader(new Tcp());

    ip.destination(dst.getAddress());
    ip.source(src.getAddress());

    ip.checksum(ip.calculateChecksum());
    tcp.checksum(tcp.calculateChecksum());
    packet.scan(Ethernet.ID);

    System.out.println(packet);
    List<PcapIf> alldevs = new ArrayList<PcapIf>(); // Will be filled with NICs
    StringBuilder errbuf = new StringBuilder(); // For any error msgs
View Full Code Here


    assertNotNull(errbuf.toString(), pcap);

    pcap.loop(Pcap.LOOP_INFINATE, new PcapPacketHandler<String>() {
      Ip4 ip = new Ip4();

      Tcp tcp = new Tcp();

      // public void nextPacket(PcapHeader header, JBuffer buffer, String user)
      // {
      public void nextPacket(PcapPacket packet, String user) {

        if (packet.hasHeader(tcp) == false) {
          return;
        }

        // PcapPacket packet = new PcapPacket(header, buffer);

        long f = packet.getFrameNumber();
        assertTrue("#" + f, packet.hasHeader(ip));

        final int crc =
            Checksum.pseudoTcp(packet, ip.getOffset(), tcp.getOffset());

        if (crc != 0 && tcp.checksum() != crc) {
          System.out.println(tcp);
          System.out.printf("#%d: tcp.crc=%x computed=%x\n", f, tcp.checksum(),
              crc);
          // System.out.println(ip.toHexdump());
          // System.out.println(tcp.toHexdump());
          System.exit(0);
        }
View Full Code Here

    assertNotNull(errbuf.toString(), pcap);

    pcap.loop(Pcap.LOOP_INFINATE, new PcapPacketHandler<String>() {
      Ip6 ip = new Ip6();

      Tcp tcp = new Tcp();

      public void nextPacket(PcapPacket packet, String user) {

        if (packet.hasHeader(tcp) == false) {
          return;
        }

        // PcapPacket packet = new PcapPacket(header, buffer);

        long f = packet.getFrameNumber();
        assertTrue("#" + f, packet.hasHeader(ip));

        assertTrue("Frame #" + f, tcp.isChecksumValid());
      }

    }, null);
  }
View Full Code Here

   */
  public void testTcpOptions() {
    JPacket packet = TestUtils.getPcapPacket(SMALL_IMAP, 1 - 1);
    System.out.println(packet.toString());
   
    Tcp tcp = packet.getHeader(new Tcp());
    Tcp.Timestamp ts = new Tcp.Timestamp();
   
    if (tcp.hasSubHeader(ts)) {
      System.out.printf("tsval=%d tsecr=%d%n", ts.tsval(), ts.tsecr());
    }
  }
View Full Code Here

    long pid = sig.getPid();
    ProcMem pm = new ProcMem();
    long base = 0;
    final PcapPacket packet = new PcapPacket(JMemory.POINTER);
    int loop = 0;
    final Tcp tcp = new Tcp();

    final JBufferHandler<Object> handler = new JBufferHandler<Object>() {

      public void nextPacket(PcapHeader header, JBuffer buffer, Object user) {
View Full Code Here

    ProcMem pm = new ProcMem();
    long base = 0;

    final PcapPacket packet = new PcapPacket(JMemory.POINTER);
    final PcapPacket.State state = packet.getState();
    final Tcp tcp = new Tcp();
    // final TcpScanner tcpScanner = new TcpScanner();

    final ByteBuffer byteBuffer = ByteBuffer.allocate(8 * 1024);

    final ReferenceQueue<PcapPacket> refQueue =
View Full Code Here

TOP

Related Classes of org.jnetpcap.protocol.tcpip.Tcp$NoOp

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.