Package org.jnetpcap.protocol.lan

Examples of org.jnetpcap.protocol.lan.Ethernet


    packet.setUByte(14 + 0, 0x45);
    System.out.println(packet.toHexdump());
    packet.setUByte(14 + 9, 0x11); //UDP
    System.out.println(packet.toHexdump());
    packet.scan(JProtocol.ETHERNET_ID);
    Ethernet eth = packet.getHeader(new Ethernet());
    Ip4 ip = packet.getHeader(new Ip4());
    Udp udp = packet.getHeader(new Udp());
//    udp.transferFrom(getFakeData(1460)); //Generate Random bytes
    eth.destination(new byte[] {(byte) 0xaa, 0x0c, 0x08, 11, 22, 33});
    eth.source(new byte[] {(byte) 0xaa, 0x0c, 0x08, 11, 22, 34});
    ip.flags(0);
    ip.tos(0);
    ip.source(new byte[] {(byte) 192, (byte) 168, 18, (byte) 218});
    ip.setByteArray(16, new byte[] {(byte) 192,(byte) 168, 18, (byte) 219});
   
View Full Code Here


  /**
   * Test ip4 fragment flag directly.
   */
  public void testIp4FragmentFlagDirectly() {
    JPacket packet = TestUtils.getPcapPacket(TestUtils.REASEMBLY, 1 - 1);
    Ethernet eth = new Ethernet();

    if (packet.hasHeader(eth)) {
      // System.out.println(eth);
      // System.out.printf("flags=%x\n", eth.getState().getFlags());
      assertNotSame(JHeader.State.FLAG_HEADER_FRAGMENTED, (eth.getState()
          .getFlags() & JHeader.State.FLAG_HEADER_FRAGMENTED));
    }

    Ip4 ip = new Ip4();
    if (packet.hasHeader(ip)) {
View Full Code Here

  /**
   * Test j header is fragmented.
   */
  public void testJHeaderIsFragmented() {
    JPacket packet = TestUtils.getPcapPacket(TestUtils.REASEMBLY, 1 - 1);
    Ethernet eth = new Ethernet();

    if (packet.hasHeader(eth)) {
      assertFalse(eth.isFragmented());
    }

    Ip4 ip = new Ip4();
    if (packet.hasHeader(ip)) {
      assertTrue(ip.isFragmented());
View Full Code Here

    // 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

  public void testScanIpv6File() throws IOException {
    TextFormatter out = new TextFormatter(OUT);
    out.setResolveAddresses(false);

    int i = 0;
    Ethernet eth = new Ethernet();
    for (PcapPacket packet : TestUtils.getIterable("tests/test-ipv6.pcap")) {

      System.out.println(packet.toDebugString());
      if (packet.hasHeader(eth)) {
        out.format(eth);
View Full Code Here

    out.setResolveAddresses(false);

    PcapPacket packet = TestUtils.getPcapPacket("tests/test-http-jpeg.pcap", 5);

    Ip4 ip = new Ip4();
    Ethernet eth = new Ethernet();
    if (packet.hasHeader(eth)) {
      out.format(eth);
    }
    if (packet.hasHeader(ip)) {
      out.format(ip);
View Full Code Here

    out.setResolveAddresses(true);

    PcapPacket packet = TestUtils.getPcapPacket("tests/test-http-jpeg.pcap", 5);

    Ip4 ip = new Ip4();
    Ethernet eth = new Ethernet();
    if (packet.hasHeader(eth)) {
      out.format(eth);
    }
    if (packet.hasHeader(ip)) {
      // out.format(ip);
View Full Code Here

TOP

Related Classes of org.jnetpcap.protocol.lan.Ethernet

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.