Examples of Tcp


Examples of net.floodlightcontroller.packet.TCP

                if (vipIpToId.containsKey(destIpAddress)){
                    IPClient client = new IPClient();
                    client.ipAddress = ip_pkt.getSourceAddress();
                    client.nw_proto = ip_pkt.getProtocol();
                    if (ip_pkt.getPayload() instanceof TCP) {
                        TCP tcp_pkt = (TCP) ip_pkt.getPayload();
                        client.srcPort = tcp_pkt.getSourcePort();
                        client.targetPort = tcp_pkt.getDestinationPort();
                    }
                    if (ip_pkt.getPayload() instanceof UDP) {
                        UDP udp_pkt = (UDP) ip_pkt.getPayload();
                        client.srcPort = udp_pkt.getSourcePort();
                        client.targetPort = udp_pkt.getDestinationPort();
View Full Code Here

Examples of net.floodlightcontroller.packet.TCP

        // dl_type type
        IPv4 pkt_ip = null;

        // nw_proto types
        TCP pkt_tcp = null;
        UDP pkt_udp = null;

        // tp_src and tp_dst (tp port numbers)
        short pkt_tp_src = 0;
        short pkt_tp_dst = 0;

        // switchID matches?
        if (wildcard_dpid == false && dpid != switchDpid)
            return false;

        // in_port matches?
        if (wildcard_in_port == false && in_port != inPort)
            return false;
        if (action == FirewallRule.FirewallAction.DENY) {
            wildcards.drop &= ~OFMatch.OFPFW_IN_PORT;
        } else {
            wildcards.allow &= ~OFMatch.OFPFW_IN_PORT;
        }

        // mac address (src and dst) match?
        if (wildcard_dl_src == false
                && dl_src != packet.getSourceMAC().toLong())
            return false;
        if (action == FirewallRule.FirewallAction.DENY) {
            wildcards.drop &= ~OFMatch.OFPFW_DL_SRC;
        } else {
            wildcards.allow &= ~OFMatch.OFPFW_DL_SRC;
        }

        if (wildcard_dl_dst == false
                && dl_dst != packet.getDestinationMAC().toLong())
            return false;
        if (action == FirewallRule.FirewallAction.DENY) {
            wildcards.drop &= ~OFMatch.OFPFW_DL_DST;
        } else {
            wildcards.allow &= ~OFMatch.OFPFW_DL_DST;
        }

        // dl_type check: ARP, IP

        // if this is not an ARP rule but the pkt is ARP,
        // return false match - no need to continue protocol specific check
        if (wildcard_dl_type == false) {
            if (dl_type == Ethernet.TYPE_ARP) {
                if (packet.getEtherType() != Ethernet.TYPE_ARP)
                    return false;
                else {
                    if (action == FirewallRule.FirewallAction.DENY) {
                        wildcards.drop &= ~OFMatch.OFPFW_DL_TYPE;
                    } else {
                        wildcards.allow &= ~OFMatch.OFPFW_DL_TYPE;
                    }
                }
            } else if (dl_type == Ethernet.TYPE_IPv4) {
                if (packet.getEtherType() != Ethernet.TYPE_IPv4)
                    return false;
                else {
                    if (action == FirewallRule.FirewallAction.DENY) {
                        wildcards.drop &= ~OFMatch.OFPFW_NW_PROTO;
                    } else {
                        wildcards.allow &= ~OFMatch.OFPFW_NW_PROTO;
                    }
                    // IP packets, proceed with ip address check
                    pkt_ip = (IPv4) pkt;

                    // IP addresses (src and dst) match?
                    if (wildcard_nw_src == false
                            && this.matchIPAddress(nw_src_prefix,
                                    nw_src_maskbits, pkt_ip.getSourceAddress()) == false)
                        return false;
                    if (action == FirewallRule.FirewallAction.DENY) {
                        wildcards.drop &= ~OFMatch.OFPFW_NW_SRC_ALL;
                        wildcards.drop |= (nw_src_maskbits << OFMatch.OFPFW_NW_SRC_SHIFT);
                    } else {
                        wildcards.allow &= ~OFMatch.OFPFW_NW_SRC_ALL;
                        wildcards.allow |= (nw_src_maskbits << OFMatch.OFPFW_NW_SRC_SHIFT);
                    }

                    if (wildcard_nw_dst == false
                            && this.matchIPAddress(nw_dst_prefix,
                                    nw_dst_maskbits,
                                    pkt_ip.getDestinationAddress()) == false)
                        return false;
                    if (action == FirewallRule.FirewallAction.DENY) {
                        wildcards.drop &= ~OFMatch.OFPFW_NW_DST_ALL;
                        wildcards.drop |= (nw_dst_maskbits << OFMatch.OFPFW_NW_DST_SHIFT);
                    } else {
                        wildcards.allow &= ~OFMatch.OFPFW_NW_DST_ALL;
                        wildcards.allow |= (nw_dst_maskbits << OFMatch.OFPFW_NW_DST_SHIFT);
                    }

                    // nw_proto check
                    if (wildcard_nw_proto == false) {
                        if (nw_proto == IPv4.PROTOCOL_TCP) {
                            if (pkt_ip.getProtocol() != IPv4.PROTOCOL_TCP)
                                return false;
                            else {
                                pkt_tcp = (TCP) pkt_ip.getPayload();
                                pkt_tp_src = pkt_tcp.getSourcePort();
                                pkt_tp_dst = pkt_tcp.getDestinationPort();
                            }
                        } else if (nw_proto == IPv4.PROTOCOL_UDP) {
                            if (pkt_ip.getProtocol() != IPv4.PROTOCOL_UDP)
                                return false;
                            else {
View Full Code Here

Examples of net.floodlightcontroller.packet.TCP

        .setPayload(
                new IPv4()
                .setTtl((byte) 128)
                .setSourceAddress("192.168.1.1")
                .setDestinationAddress("192.168.1.2")
                .setPayload(new TCP()
                .setSourcePort((short) 81)
                .setDestinationPort((short) 80)
                .setPayload(new Data(new byte[] {0x01}))));

        // Build a broadcast ARP packet
        this.broadcastARPPacket = new Ethernet()
        .setDestinationMACAddress("FF:FF:FF:FF:FF:FF")
        .setSourceMACAddress("00:44:33:22:11:00")
        .setVlanID((short) 42)
        .setEtherType(Ethernet.TYPE_ARP)
        .setPayload(
                new ARP()
                .setHardwareType(ARP.HW_TYPE_ETHERNET)
                .setProtocolType(ARP.PROTO_TYPE_IP)
                .setOpCode(ARP.OP_REQUEST)
                .setHardwareAddressLength((byte)6)
                .setProtocolAddressLength((byte)4)
                .setSenderHardwareAddress(Ethernet.toMACAddress("00:44:33:22:11:00"))
                .setSenderProtocolAddress(IPv4.toIPv4Address("192.168.1.1"))
                .setTargetHardwareAddress(Ethernet.toMACAddress("00:00:00:00:00:00"))
                .setTargetProtocolAddress(IPv4.toIPv4Address("192.168.1.2"))
                .setPayload(new Data(new byte[] {0x01})));

        // Build a ARP packet
        this.ARPReplyPacket = new Ethernet()
        .setDestinationMACAddress("00:44:33:22:11:00")
        .setSourceMACAddress("00:11:22:33:44:55")
        .setVlanID((short) 42)
        .setEtherType(Ethernet.TYPE_ARP)
        .setPayload(
                new ARP()
                .setHardwareType(ARP.HW_TYPE_ETHERNET)
                .setProtocolType(ARP.PROTO_TYPE_IP)
                .setOpCode(ARP.OP_REQUEST)
                .setHardwareAddressLength((byte)6)
                .setProtocolAddressLength((byte)4)
                .setSenderHardwareAddress(Ethernet.toMACAddress("00:11:22:33:44:55"))
                .setSenderProtocolAddress(IPv4.toIPv4Address("192.168.1.2"))
                .setTargetHardwareAddress(Ethernet.toMACAddress("00:44:33:22:11:00"))
                .setTargetProtocolAddress(IPv4.toIPv4Address("192.168.1.1"))
                .setPayload(new Data(new byte[] {0x01})));

        // Build a broadcast IP packet
        this.broadcastIPPacket = new Ethernet()
        .setDestinationMACAddress("FF:FF:FF:FF:FF:FF")
        .setSourceMACAddress("00:44:33:22:11:00")
        .setVlanID((short) 42)
        .setEtherType(Ethernet.TYPE_IPv4)
        .setPayload(
                new IPv4()
                .setTtl((byte) 128)
                .setSourceAddress("192.168.1.1")
                .setDestinationAddress("192.168.1.255")
                .setPayload(new UDP()
                .setSourcePort((short) 5000)
                .setDestinationPort((short) 5001)
                .setPayload(new Data(new byte[] {0x01}))));

        // Build a malformed broadcast packet
        this.broadcastMalformedPacket = new Ethernet()
        .setDestinationMACAddress("FF:FF:FF:FF:FF:FF")
        .setSourceMACAddress("00:44:33:22:11:00")
        .setVlanID((short) 42)
        .setEtherType(Ethernet.TYPE_IPv4)
        .setPayload(
                new IPv4()
                .setTtl((byte) 128)
                .setSourceAddress("192.168.1.1")
                .setDestinationAddress("192.168.1.2")
                .setPayload(new UDP()
                .setSourcePort((short) 5000)
                .setDestinationPort((short) 5001)
                .setPayload(new Data(new byte[] {0x01}))));

        this.tcpPacketReply = new Ethernet()
        .setDestinationMACAddress("00:44:33:22:11:00")
        .setSourceMACAddress("00:11:22:33:44:55")
        .setVlanID((short) 42)
        .setEtherType(Ethernet.TYPE_IPv4)
        .setPayload(
                new IPv4()
                .setTtl((byte) 128)
                .setSourceAddress("192.168.1.2")
                .setDestinationAddress("192.168.1.1")
                .setPayload(new TCP()
                .setSourcePort((short) 80)
                .setDestinationPort((short) 81)
                .setPayload(new Data(new byte[] {0x02}))));
    }
View Full Code Here

Examples of org.hyperic.sigar.Tcp

        return address + ":" + port;
    }

    private void outputTcpStats() throws SigarException {
        Tcp stat = this.sigar.getTcp();
        final String dnt = "    ";
        println(dnt + stat.getActiveOpens() + " active connections openings");
        println(dnt + stat.getPassiveOpens() + " passive connection openings");
        println(dnt + stat.getAttemptFails() + " failed connection attempts");
        println(dnt + stat.getEstabResets() + " connection resets received");
        println(dnt + stat.getCurrEstab() + " connections established");
        println(dnt + stat.getInSegs() + " segments received");
        println(dnt + stat.getOutSegs() + " segments send out");
        println(dnt + stat.getRetransSegs() + " segments retransmited");
        println(dnt + stat.getInErrs() + " bad segments received.");
        println(dnt + stat.getOutRsts() + " resets sent");
    }
View Full Code Here

Examples of org.hyperic.sigar.Tcp

    }

    private TCPStatObject getTCPStat() {
        TCPStatObject tcpObj = new TCPStatObject();
        try {
            Tcp stat = sigar.getTcp();
            tcpObj.setActiveOpens(stat.getActiveOpens());
            tcpObj.setPassiveOpens(stat.getPassiveOpens());
            tcpObj.setAttemptFails(stat.getAttemptFails());
            tcpObj.setEstabResets(stat.getEstabResets());
            tcpObj.setCurrentEstab(stat.getCurrEstab());
            tcpObj.setInSegs(stat.getInSegs());
            tcpObj.setOutSegs(stat.getOutSegs());
            tcpObj.setRetransSegs(stat.getRetransSegs());
            tcpObj.setInErrs(stat.getInErrs());
            tcpObj.setOutRsts(stat.getOutRsts());
        } catch (SigarException ex) {
            Logger.getLogger(NetStat.class.getName()).log(Level.SEVERE, null, ex);
        }

        return tcpObj;
View Full Code Here

Examples of org.hyperic.sigar.Tcp

        super(name);
    }

    public void testCreate() throws Exception {
        Sigar sigar = getSigar();
        Tcp tcp;
       
        try {
            tcp = sigar.getTcp();
        } catch (SigarNotImplementedException e) {
            return;
        } catch (SigarPermissionDeniedException e) {
            return;
        }

        traceln("");
        assertValidFieldTrace("ActiveOpens", tcp.getActiveOpens());
        assertValidFieldTrace("PassiveOpens", tcp.getPassiveOpens());
        assertValidFieldTrace("AttemptFails", tcp.getAttemptFails());
        assertValidFieldTrace("EstabResets", tcp.getEstabResets());
        assertValidFieldTrace("CurrEstab", tcp.getCurrEstab());
        assertValidFieldTrace("InSegs", tcp.getInSegs());
        assertValidFieldTrace("OutSegs", tcp.getOutSegs());
        assertValidFieldTrace("RetransSegs", tcp.getRetransSegs());
        assertValidFieldTrace("OutRsts", tcp.getOutRsts());
    }
View Full Code Here

Examples of org.hyperic.sigar.Tcp

        super(name);
    }

    public void testCreate() throws Exception {
        Sigar sigar = getSigar();
        Tcp tcp;
       
        try {
            tcp = sigar.getTcp();
        } catch (SigarNotImplementedException e) {
            return;
        } catch (SigarPermissionDeniedException e) {
            return;
        }

        traceln("");
        assertValidFieldTrace("ActiveOpens", tcp.getActiveOpens());
        assertValidFieldTrace("PassiveOpens", tcp.getPassiveOpens());
        assertValidFieldTrace("AttemptFails", tcp.getAttemptFails());
        assertValidFieldTrace("EstabResets", tcp.getEstabResets());
        assertValidFieldTrace("CurrEstab", tcp.getCurrEstab());
        assertValidFieldTrace("InSegs", tcp.getInSegs());
        assertValidFieldTrace("OutSegs", tcp.getOutSegs());
        assertValidFieldTrace("RetransSegs", tcp.getRetransSegs());
        assertValidFieldTrace("OutRsts", tcp.getOutRsts());
    }
View Full Code Here

Examples of org.hyperic.sigar.Tcp

        return address + ":" + port;
    }

    private void outputTcpStats() throws SigarException {
        Tcp stat = this.sigar.getTcp();
        final String dnt = "    ";
        println(dnt + stat.getActiveOpens() + " active connections openings");
        println(dnt + stat.getPassiveOpens() + " passive connection openings");
        println(dnt + stat.getAttemptFails() + " failed connection attempts");
        println(dnt + stat.getEstabResets() + " connection resets received");
        println(dnt + stat.getCurrEstab() + " connections established");
        println(dnt + stat.getInSegs() + " segments received");
        println(dnt + stat.getOutSegs() + " segments send out");
        println(dnt + stat.getRetransSegs() + " segments retransmited");
        println(dnt + stat.getInErrs() + " bad segments received.");
        println(dnt + stat.getOutRsts() + " resets sent");
    }
View Full Code Here

Examples of org.hyperic.sigar.Tcp

        super(name);
    }

    public void testCreate() throws Exception {
        Sigar sigar = getSigar();
        Tcp tcp;
       
        try {
            tcp = sigar.getTcp();
        } catch (SigarNotImplementedException e) {
            return;
        }

        traceln("");
        assertGtEqZeroTrace("ActiveOpens", tcp.getActiveOpens());
        assertGtEqZeroTrace("PassiveOpens", tcp.getPassiveOpens());
        assertGtEqZeroTrace("AttemptFails", tcp.getAttemptFails());
        assertGtEqZeroTrace("EstabResets", tcp.getEstabResets());
        assertGtEqZeroTrace("CurrEstab", tcp.getCurrEstab());
        assertGtEqZeroTrace("InSegs", tcp.getInSegs());
        assertGtEqZeroTrace("OutSegs", tcp.getOutSegs());
        assertGtEqZeroTrace("RetransSegs", tcp.getRetransSegs());
        assertGtEqZeroTrace("OutRsts", tcp.getOutRsts());
    }
View Full Code Here

Examples of org.jgroups.protocols.TCP

    public void setUp() throws Exception {
        for (int i = 0; i < NUM; i++) {
            Protocol ping = createPing();

            channels[i] = new JChannel(
                new TCP(),
                ping,
                new NAKACK2(),
                new UNICAST3(),
                new STABLE(),
                new GMS()
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.