use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestmessage.MapRequest in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTest method mapRequestMapRegisterAndMapRequestTestTimeout.
// ------------------- TimeOut Tests -----------
public void mapRequestMapRegisterAndMapRequestTestTimeout() throws SocketTimeoutException {
cleanUP();
ConfigIni.getInstance().setSmrRetryCount(0);
Eid eid = LispAddressUtil.asIpv4PrefixBinaryEid("1.2.3.4/32");
mapService.addAuthenticationKey(eid, NULL_AUTH_KEY);
sleepForSeconds(1);
MapRequest mapRequest = MappingServiceIntegrationTestUtil.getDefaultMapRequestBuilder(eid).build();
sendMapRequest(mapRequest);
MapReply mapReply = receiveMapReply();
assertEquals(4, mapReply.getNonce().longValue());
assertEquals(0, mapReply.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().size());
MapRegister mapRegister = MappingServiceIntegrationTestUtil.getDefaultMapRegisterBuilder(eid).build();
sendMapRegister(mapRegister);
MapNotify mapNotify = receiveMapNotify();
assertEquals(8, mapNotify.getNonce().longValue());
sleepForSeconds(1);
sendMapRequest(mapRequest);
mapReply = receiveMapReply();
assertEquals(4, mapReply.getNonce().longValue());
assertEquals(MappingServiceIntegrationTestUtil.DEFAULT_IPV4_RLOC, mapReply.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(0).getRloc());
causeEntryToBeCleaned();
sendMapRequest(mapRequest);
mapReply = receiveMapReply();
assertEquals(0, mapReply.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().size());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestmessage.MapRequest in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTest method testMultipleMappings.
private void testMultipleMappings() throws UnknownHostException {
final InstanceIdType iid = new InstanceIdType(1L);
// prefix from the intersection of NB and SB gaps
final String prefix1 = "1.1.127.10/32";
// prefix with existing mapping in NB
final String prefix2 = "1.1.200.255/32";
final String prefix3 = "1.3.255.255/32";
final MapRequest mapRequest = new MapRequestBuilder().setSmrInvoked(false).setEidItem(Lists.newArrayList(new EidItemBuilder().setEid(LispAddressUtil.asIpv4PrefixBinaryEid(prefix1, iid)).build(), new EidItemBuilder().setEid(LispAddressUtil.asIpv4PrefixBinaryEid(prefix2, iid)).build(), new EidItemBuilder().setEid(LispAddressUtil.asIpv4PrefixBinaryEid(prefix3, iid)).build())).build();
final MapReply mapReply = lms.handleMapRequest(mapRequest);
// expected result
final String resultPrefix1 = "1.1.64.0";
final Address resultNegMapping1 = new Ipv4PrefixBinaryBuilder().setIpv4AddressBinary(new Ipv4AddressBinary(InetAddress.getByName(resultPrefix1).getAddress())).setIpv4MaskLength((short) 18).build();
final String resultPrefix2 = "1.1.128.0";
final Address resultMapping2 = new Ipv4PrefixBinaryBuilder().setIpv4AddressBinary(new Ipv4AddressBinary(InetAddress.getByName(resultPrefix2).getAddress())).setIpv4MaskLength((short) 17).build();
final String resultPrefix3 = "1.3.0.0";
final Address resultNegMapping3 = new Ipv4PrefixBinaryBuilder().setIpv4AddressBinary(new Ipv4AddressBinary(InetAddress.getByName(resultPrefix3).getAddress())).setIpv4MaskLength((short) 16).build();
assertEquals(resultNegMapping1, mapReply.getMappingRecordItem().get(0).getMappingRecord().getEid().getAddress());
assertEquals(resultMapping2, mapReply.getMappingRecordItem().get(1).getMappingRecord().getEid().getAddress());
assertEquals(resultNegMapping3, mapReply.getMappingRecordItem().get(2).getMappingRecord().getEid().getAddress());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestmessage.MapRequest in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTest method mapRequestMapRegisterAndMapRequestTestNativelyForwardTimeoutResponse.
public void mapRequestMapRegisterAndMapRequestTestNativelyForwardTimeoutResponse() throws Exception {
cleanUP();
Eid eid = LispAddressUtil.asIpv4PrefixBinaryEid("1.2.3.4/32");
MapRequest mapRequest = createMapRequest(eid);
testTTLBeforeRegister(mapRequest);
registerForTTL(eid);
testTTLAfterRegister(mapRequest);
causeEntryToBeCleaned();
testTTLAfterClean(mapRequest);
// northboundAddKey();
// testTTLAfterAutherize(mapRequest);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestmessage.MapRequest in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTest method createNonProxyMapRequest.
private MapRequest createNonProxyMapRequest(String eid, Rloc adLcaf) throws SocketTimeoutException {
MapRegister mr = createMapRegister(LispAddressUtil.asIpv4PrefixBinaryEid(eid));
LocatorRecord record = new LocatorRecordBuilder(mr.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().get(0)).setRloc(adLcaf).build();
mr.getMappingRecordItem().get(0).getMappingRecord().getLocatorRecord().set(0, record);
sendMapRegister(mr);
assertMapNotifyReceived();
MapRequest mapRequest = createMapRequest(LispAddressUtil.asIpv4PrefixBinaryEid(eid));
MapRequestBuilder builder = new MapRequestBuilder(mapRequest);
builder.setPitr(true);
mapRequest = builder.build();
return mapRequest;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestmessage.MapRequest in project lispflowmapping by opendaylight.
the class MappingServiceIntegrationTestUtil method checkSmr.
/**
* Read packets from the given socket until a Map-Request is found. Assert that the request is an SMR, and the
* Source EID field contains the given IPv4 EID. Note that the source EID does not have a mask length. If a
* reference to the LISP Mapping Service is passed, send an SMR-invoked Map-Request, to simulate what would happen
* in the real world. If a reference to the Mapping Service is passed, the internal state of the map caches and
* subscribers is logged.
*
* @param socket the receive socket
* @param lms reference to the LISP Mapping Service, if present, an SMR-invoked Map-Request is sent in reply to the
* SMR
* @param ms reference to the Mapping System, if present, the internal state of map-caches and subscribers is logged
* @param vni the VNI for the expected EID
* @param eids the expected EIDs, as an IPv4 string, without mask length
*/
static void checkSmr(DatagramSocket socket, IFlowMapping lms, IMappingService ms, long vni, String... eids) {
LOG.debug("checkSmr: expecting {} SMRs: {}", eids.length, eids);
List<MapRequest> mapRequests = receiveExpectedSmrs(socket, eids.length);
assertNoMoreSMRs(socket, ms);
HashMap<Eid, Integer> eidSet = prepareExpectedEids(vni, eids);
for (MapRequest mapRequest : mapRequests) {
LOG.trace("Solicit Map-Request: {}", mapRequest);
Eid originalSourceEid = mapRequest.getEidItem().get(0).getEid();
assertEquals(DEFAULT_IPV4_EID_PREFIX, originalSourceEid);
Eid smrEid = mapRequest.getSourceEid().getEid();
int counterDecremented = eidSet.get(smrEid) - 1;
if (counterDecremented < 0) {
fail("checkSmr: SMR contains EID " + LispAddressStringifier.getString(smrEid) + ", which is not in the list of expected EIDs: " + eidSet);
} else {
LOG.debug("checkSmr: successfully received expected SMR for {}", LispAddressStringifier.getString(smrEid));
}
if (lms != null) {
sendSMRInvokedMapRequestMessage(mapRequest, lms);
// TODO Capture the reply to the SMR-invoked Map-Request and assert on the expected result
}
}
if (ms != null) {
printMapCacheState(ms);
}
}
Aggregations