Search in sources :

Example 1 with PIMJoinPrune

use of org.onlab.packet.pim.PIMJoinPrune in project onos by opennetworkinglab.

the class PIMTest method setUp.

/**
 * Create PIM Hello and Join/Prune packets to be used in testing.
 *
 * @throws Exception if packet creation fails
 */
@Before
public void setUp() throws Exception {
    // Create a PIM Hello
    pimHello = new PIM();
    pimHello.setVersion((byte) 2);
    pimHello.setPIMType((byte) PIM.TYPE_HELLO);
    pimHello.setChecksum((short) 0);
    hello = new PIMHello();
    hello.createDefaultOptions();
    pimHello.setPayload(hello);
    hello.setParent(pimHello);
    // Create PIM Join Prune
    pimJoinPrune = new PIM();
    pimJoinPrune.setVersion((byte) 2);
    pimJoinPrune.setPIMType((byte) PIM.TYPE_JOIN_PRUNE_REQUEST);
    pimJoinPrune.setChecksum((short) 0);
    joinPrune = new PIMJoinPrune();
    joinPrune.setUpstreamAddr(new PIMAddrUnicast(SADDR));
    joinPrune.addJoin(GADDR1, SADDR1);
    joinPrune.addJoin(GADDR2, SADDR2);
    joinPrune.addPrune(GADDR1, SADDR2);
    joinPrune.addPrune(GADDR2, SADDR1);
    pimJoinPrune.setPayload(joinPrune);
    joinPrune.setParent(pimJoinPrune);
    deserializer = PIM.deserializer();
}
Also used : PIMJoinPrune(org.onlab.packet.pim.PIMJoinPrune) PIMAddrUnicast(org.onlab.packet.pim.PIMAddrUnicast) PIMHello(org.onlab.packet.pim.PIMHello) Before(org.junit.Before)

Example 2 with PIMJoinPrune

use of org.onlab.packet.pim.PIMJoinPrune in project onos by opennetworkinglab.

the class PimInterface method processJoinPrune.

/**
 * Process an incoming PIM JoinPrune message.
 *
 * @param ethPkt the Ethernet packet header.
 */
public void processJoinPrune(Ethernet ethPkt) {
    IPv4 ip = (IPv4) ethPkt.getPayload();
    checkNotNull(ip);
    PIM pim = (PIM) ip.getPayload();
    checkNotNull(pim);
    PIMJoinPrune jpHdr = (PIMJoinPrune) pim.getPayload();
    checkNotNull(jpHdr);
    /*
         * The Join/Prune messages are grouped by Group address. We'll walk each group address
         * where we will possibly have to walk a list of source address for the joins and prunes.
         */
    Collection<PIMJoinPruneGroup> jpgs = jpHdr.getJoinPrunes();
    for (PIMJoinPruneGroup jpg : jpgs) {
        IpPrefix gpfx = jpg.getGroup();
        // Walk the joins first.
        for (IpPrefix spfx : jpg.getJoins().values()) {
        // We may need
        }
        for (IpPrefix spfx : jpg.getPrunes().values()) {
        // TODO: this is where we many need to remove multi-cast state and possibly intents.
        }
    }
}
Also used : PIMJoinPrune(org.onlab.packet.pim.PIMJoinPrune) IpPrefix(org.onlab.packet.IpPrefix) PIM(org.onlab.packet.PIM) PIMJoinPruneGroup(org.onlab.packet.pim.PIMJoinPruneGroup) IPv4(org.onlab.packet.IPv4)

Example 3 with PIMJoinPrune

use of org.onlab.packet.pim.PIMJoinPrune 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)

Aggregations

PIMJoinPrune (org.onlab.packet.pim.PIMJoinPrune)3 IPv4 (org.onlab.packet.IPv4)2 PIM (org.onlab.packet.PIM)2 PIMAddrUnicast (org.onlab.packet.pim.PIMAddrUnicast)2 Before (org.junit.Before)1 Ethernet (org.onlab.packet.Ethernet)1 IpPrefix (org.onlab.packet.IpPrefix)1 PIMHello (org.onlab.packet.pim.PIMHello)1 PIMJoinPruneGroup (org.onlab.packet.pim.PIMJoinPruneGroup)1 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)1 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)1 DefaultOutboundPacket (org.onosproject.net.packet.DefaultOutboundPacket)1