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())));
}
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()));
}
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())));
}
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();
}
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;
}
Aggregations