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