public NATFeatureRealization executeTest() {
NATFeatureRealization result = NATFeatureRealization.DONT_CARE;
try {
final Message responseI = this.executeTestI(this.primaryStunServerAddress.getAddress(),
this.primaryStunServerAddress.getPort());
final XorMappedAddress mappedAddressI = responseI.getAttribute(XorMappedAddress.class);
final String localAddress = InetAddress.getLocalHost().getHostAddress();
if (localAddress.equals(mappedAddressI.getEndpoint().getHostName())
&& this.sourcePort == mappedAddressI.getEndpoint().getPort()) {
result = NATFeatureRealization.NOT_REALIZED;
} else {
final InetSocketAddress alternateAddress = this.getAlternateSTUNServerAddressFromMessage(responseI);
final Message responseII = this.executeTestII(alternateAddress.getAddress(),
this.primaryStunServerAddress.getPort());
final XorMappedAddress mappedAddressII = responseII.getAttribute(XorMappedAddress.class);
if (mappedAddressII.equals(mappedAddressI)) {
result = NATFeatureRealization.ENDPOINT_INDEPENDENT;
} else {
final Message responseIII = this.executeTestIII(alternateAddress.getAddress(),
alternateAddress.getPort());
final XorMappedAddress mappedAddressIII = responseIII.getAttribute(XorMappedAddress.class);
if (mappedAddressIII.equals(mappedAddressII)) {
result = NATFeatureRealization.ADDRESS_DEPENDENT;
} else {
final Message responseIV = this.executeTestRun(this.primaryStunServerAddress.getAddress(),
this.primaryStunServerAddress.getPort());
final XorMappedAddress mappedAddressIV = responseIV.getAttribute(XorMappedAddress.class);
if (!mappedAddressIV.equals(mappedAddressI)) {
result = NATFeatureRealization.CONNECTION_DEPENDENT;
} else {
result = NATFeatureRealization.ADDRESS_AND_PORT_DEPENDENT;
}
}