replace detection algorithm for wan/lan ports