Search in sources :

Example 36 with DefaultOutboundPacket

use of org.onosproject.net.packet.DefaultOutboundPacket in project onos by opennetworkinglab.

the class OpenstackNetworkingUtil method processGarpPacketForFloatingIp.

/**
 * Sends GARP packet with supplied floating ip information.
 *
 * @param floatingIP floating ip
 * @param instancePort instance port
 * @param vlanId vlain id
 * @param gatewayNode gateway node
 * @param packetService packet service
 */
public static void processGarpPacketForFloatingIp(NetFloatingIP floatingIP, InstancePort instancePort, VlanId vlanId, OpenstackNode gatewayNode, PacketService packetService) {
    Ethernet ethernet = buildGratuitousArpPacket(floatingIP, instancePort, vlanId);
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(gatewayNode.uplinkPortNum()).build();
    packetService.emit(new DefaultOutboundPacket(gatewayNode.intgBridge(), treatment, ByteBuffer.wrap(ethernet.serialize())));
}
Also used : Ethernet(org.onlab.packet.Ethernet) DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Example 37 with DefaultOutboundPacket

use of org.onosproject.net.packet.DefaultOutboundPacket in project onos by opennetworkinglab.

the class OpenstackTroubleshootManager method buildIcmpOutputPacket.

/**
 * Builds ICMP Outbound packet.
 *
 * @param srcPort   source instance port
 * @param dstPort   destination instance port
 * @param icmpId    ICMP identifier
 * @param icmpSeq   ICMP sequence number
 */
private OutboundPacket buildIcmpOutputPacket(InstancePort srcPort, InstancePort dstPort, OpenstackNode gateway, short icmpId, short icmpSeq, Direction direction) {
    Ethernet ethFrame;
    IpAddress srcIp;
    IpAddress dstIp;
    DeviceId deviceId;
    if (direction == Direction.EAST_WEST) {
        ethFrame = constructEastWestIcmpPacket(srcPort, dstPort, icmpId, icmpSeq);
        srcIp = srcPort.ipAddress();
        dstIp = dstPort.ipAddress();
        deviceId = srcPort.deviceId();
    } else if (direction == Direction.NORTH_SOUTH) {
        ethFrame = constructNorthSouthIcmpPacket(dstPort, icmpId, icmpSeq);
        srcIp = clusterService.getLocalNode().ip();
        dstIp = instancePortService.floatingIp(dstPort.portId());
        deviceId = gateway.intgBridge();
    } else {
        log.warn("Invalid traffic direction {}", direction);
        return null;
    }
    TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
    // we send out the packet to ingress table (index is 0) of source OVS
    // to enforce the Outbound packet to go through the ingress and egress
    // pipeline
    tBuilder.setOutput(TABLE);
    Reachability reachability = DefaultReachability.builder().srcIp(srcIp).dstIp(dstIp).isReachable(false).build();
    icmpReachabilityMap.put(String.valueOf(icmpId), reachability);
    icmpIds.add(String.valueOf(icmpId));
    return new DefaultOutboundPacket(deviceId, tBuilder.build(), ByteBuffer.wrap(ethFrame.serialize()));
}
Also used : DeviceId(org.onosproject.net.DeviceId) Ethernet(org.onlab.packet.Ethernet) IpAddress(org.onlab.packet.IpAddress) DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Reachability(org.onosproject.openstacktroubleshoot.api.Reachability)

Example 38 with DefaultOutboundPacket

use of org.onosproject.net.packet.DefaultOutboundPacket in project onos by opennetworkinglab.

the class PimInterface method sendHello.

/**
 * Multicast a hello message out our interface.  This hello message is sent
 * periodically during the normal PIM Neighbor refresh time, as well as a
 * result of a newly created interface.
 */
public void sendHello() {
    if (lastHello + TimeUnit.SECONDS.toMillis(helloInterval) > System.currentTimeMillis()) {
        return;
    }
    lastHello = System.currentTimeMillis();
    // Create the base PIM Packet and mark it a hello packet
    PimPacket pimPacket = new PimPacket(PIM.TYPE_HELLO);
    // We need to set the source MAC and IPv4 addresses
    pimPacket.setSrcMacAddr(onosInterface.mac());
    pimPacket.setSrcIpAddress(Ip4Address.valueOf(getIpAddress().toOctets()));
    // Create the hello message with options
    PIMHello hello = new PIMHello();
    hello.createDefaultOptions();
    hello.addOption(PIMHelloOption.createHoldTime(holdtime));
    hello.addOption(PIMHelloOption.createPriority(priority));
    hello.addOption(PIMHelloOption.createGenID(generationId));
    // Now set the hello option payload
    pimPacket.setPimPayload(hello);
    packetService.emit(new DefaultOutboundPacket(onosInterface.connectPoint().deviceId(), outputTreatment, ByteBuffer.wrap(pimPacket.getEthernet().serialize())));
}
Also used : DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket) PIMHello(org.onlab.packet.pim.PIMHello)

Example 39 with DefaultOutboundPacket

use of org.onosproject.net.packet.DefaultOutboundPacket in project onos by opennetworkinglab.

the class PimInterface method sendJoinPrune.

private void sendJoinPrune(McastRoute route, RouteData data, boolean join) {
    PIMJoinPrune jp = new PIMJoinPrune();
    jp.addJoinPrune(route.source().toIpPrefix(), route.group().toIpPrefix(), join);
    jp.setHoldTime(join ? (short) Math.floor(JOIN_PERIOD * HOLD_TIME_MULTIPLIER) : 0);
    jp.setUpstreamAddr(new PIMAddrUnicast(data.ipAddress.toString()));
    PIM pim = new PIM();
    pim.setPIMType(PIM.TYPE_JOIN_PRUNE_REQUEST);
    pim.setPayload(jp);
    IPv4 ipv4 = new IPv4();
    ipv4.setDestinationAddress(PIM.PIM_ADDRESS.getIp4Address().toInt());
    ipv4.setSourceAddress(getIpAddress().getIp4Address().toInt());
    ipv4.setProtocol(IPv4.PROTOCOL_PIM);
    ipv4.setTtl((byte) 1);
    ipv4.setDiffServ((byte) 0xc0);
    ipv4.setPayload(pim);
    Ethernet eth = new Ethernet();
    eth.setSourceMACAddress(onosInterface.mac());
    eth.setDestinationMACAddress(MacAddress.valueOf("01:00:5E:00:00:0d"));
    eth.setEtherType(Ethernet.TYPE_IPV4);
    eth.setPayload(ipv4);
    TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(onosInterface.connectPoint().port()).build();
    packetService.emit(new DefaultOutboundPacket(onosInterface.connectPoint().deviceId(), treatment, ByteBuffer.wrap(eth.serialize())));
    data.timestamp = System.currentTimeMillis();
}
Also used : PIMJoinPrune(org.onlab.packet.pim.PIMJoinPrune) PIMAddrUnicast(org.onlab.packet.pim.PIMAddrUnicast) PIM(org.onlab.packet.PIM) IPv4(org.onlab.packet.IPv4) Ethernet(org.onlab.packet.Ethernet) DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Example 40 with DefaultOutboundPacket

use of org.onosproject.net.packet.DefaultOutboundPacket in project onos by opennetworkinglab.

the class SimpleFabricManager method requestMac.

@Override
public boolean requestMac(IpAddress ip) {
    FabricSubnet fabricSubnet = fabricSubnet(ip);
    if (fabricSubnet == null) {
        log.warn("simple fabric request mac failed for unknown fabricSubnet: {}", ip);
        return false;
    }
    FabricNetwork fabricNetwork = fabricNetwork(fabricSubnet.networkName());
    if (fabricNetwork == null) {
        log.warn("simple fabric request mac failed for unknown fabricNetwork name {}: {}", fabricSubnet.networkName(), ip);
        return false;
    }
    log.debug("simple fabric send request mac fabricNetwork {}: {}", fabricNetwork.name(), ip);
    for (Interface iface : fabricNetwork.interfaces()) {
        Ethernet neighbourReq;
        if (ip.isIp4()) {
            neighbourReq = ARP.buildArpRequest(fabricSubnet.gatewayMac().toBytes(), fabricSubnet.gatewayIp().toOctets(), ip.toOctets(), iface.vlan().toShort());
        } else {
            byte[] soliciteIp = IPv6.getSolicitNodeAddress(ip.toOctets());
            neighbourReq = NeighborSolicitation.buildNdpSolicit(ip.getIp6Address(), fabricSubnet.gatewayIp().getIp6Address(), Ip6Address.valueOf(soliciteIp), MacAddress.valueOf(fabricSubnet.gatewayMac().toBytes()), MacAddress.valueOf(IPv6.getMCastMacAddress(soliciteIp)), iface.vlan());
        }
        TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(iface.connectPoint().port()).build();
        OutboundPacket packet = new DefaultOutboundPacket(iface.connectPoint().deviceId(), treatment, ByteBuffer.wrap(neighbourReq.serialize()));
        packetService.emit(packet);
    }
    return true;
}
Also used : FabricSubnet(org.onosproject.simplefabric.api.FabricSubnet) Ethernet(org.onlab.packet.Ethernet) DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) FabricNetwork(org.onosproject.simplefabric.api.FabricNetwork) Interface(org.onosproject.net.intf.Interface) OutboundPacket(org.onosproject.net.packet.OutboundPacket) DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket)

Aggregations

DefaultOutboundPacket (org.onosproject.net.packet.DefaultOutboundPacket)53 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)42 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)41 OutboundPacket (org.onosproject.net.packet.OutboundPacket)32 Ethernet (org.onlab.packet.Ethernet)23 ByteBuffer (java.nio.ByteBuffer)12 ConnectPoint (org.onosproject.net.ConnectPoint)12 PortNumber (org.onosproject.net.PortNumber)11 IpAddress (org.onlab.packet.IpAddress)9 Test (org.junit.Test)8 DeviceId (org.onosproject.net.DeviceId)8 InboundPacket (org.onosproject.net.packet.InboundPacket)7 PacketContext (org.onosproject.net.packet.PacketContext)7 Set (java.util.Set)6 MacAddress (org.onlab.packet.MacAddress)6 ApplicationId (org.onosproject.core.ApplicationId)6 PacketProcessor (org.onosproject.net.packet.PacketProcessor)6 DefaultInboundPacket (org.onosproject.net.packet.DefaultInboundPacket)5 PacketService (org.onosproject.net.packet.PacketService)5 PiPacketOperation (org.onosproject.net.pi.runtime.PiPacketOperation)5