Search in sources :

Example 1 with PIMAddrUnicast

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

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

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