Package org.jnetpcap.packet

Examples of org.jnetpcap.packet.JMemoryPacket$JMemoryHeader


            + "31 04 69 61  67 72 03 6e  65 74 00 00  01 00 01 c0"
            + "17 00 06 00  01 00 00 2a  30 00 2f 05  70 64 6e 73"
            + "31 08 75 6c  74 72 61 64  6e 73 c0 1c  07 6b 67 72"
            + "61 75 65 72  c0 17 77 bf  dd f5 00 00  2a 30 00 00"
            + "0e 10 00 27  8d 00 00 01  51 80" + "";
    final JPacket packet = new JMemoryPacket(JProtocol.ETHERNET_ID, data);

    // final String TEMP_CAP = "tests/temp.pcap";
    // final File TEMP_CAP_FILE = new File(TEMP_CAP);
    // if (TEMP_CAP_FILE.exists()) {
    // TEMP_CAP_FILE.delete();
    // }
    // FormatUtils.createPcapFile(TEMP_CAP, data);

    // System.out.println(packet);
    System.out.println(packet.getHeader(new Ethernet()));
    System.out.println(packet.getHeader(new Ip4()));
    System.out.println(packet.getHeader(new Udp()));
    System.out.println(packet.getState().toDebugString());

  }
View Full Code Here


  /**
   * Test peer to j buffer.
   */
  public void testPeerToJBuffer() {
    assertNotNull(VariousInMemoryPackets.PACKET_1);
    JPacket packet = new JMemoryPacket(VariousInMemoryPackets.PACKET_1);
    packet.scan(Ethernet.ID);
   
    System.out.println(packet);
  }
View Full Code Here

  public final void testDispatchIntIntJPacketHandlerOfTTLoop() {
    for (int i = 0; i < COUNT; i++) {
      loop(TEST_AFS, new JPacketHandler<Counter>() {
        public void nextPacket(JPacket packet, Counter counter) {
          counter.inc();
          new JMemoryPacket(packet.size()).transferStateAndDataFrom(packet);
        }
      });
    }
  }
View Full Code Here

  public final void testDispatchIntIntJPacketHandlerOfTTDispatch() {
    for (int i = 0; i < COUNT; i++) {
      dispatch(TEST_AFS, new JPacketHandler<Counter>() {
        public void nextPacket(JPacket packet, Counter counter) {
          counter.inc();
          new JMemoryPacket(packet.size()).transferStateAndDataFrom(packet);
        }
      });
    }
  }
View Full Code Here

   * @throws UnknownHostException
   *           the unknown host exception
   */
  public void testSendPacketUsingJBuffer() throws UnknownHostException {
    JPacket packet =
        new JMemoryPacket(JProtocol.ETHERNET_ID,
            "0016b6c13cb10021 5db0456c08004500 "
                + "00340e8e40008006 9c54c0a80165d822 "
                + "b5b1c1cf005020ce 4303000000008002 "
                + "2000d94300000204 05b4010303020101 " + "0402");

    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

TOP

Related Classes of org.jnetpcap.packet.JMemoryPacket$JMemoryHeader

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.