Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • RegExp::IPv6. There a couple of possibly useful subroutines in traceroute.pl (obtainable here):
    • Code Block
      
      sub valid_ip {
        #Given a string, it checks whether it is a valid IP name (returns "n"),
        #or valid IPv4 address (returns "4"), or valid IPv6 address returns "6").
        #If invalid it returnr IP name see: http://stackoverflow.com/questions/106179/regular-expression-to-match-hostname-or-ip-address
        #For IPv4 address see: http://answers.oreilly.com/topic/318-how-to-match-ipv4-addresses-with-regular-expressions/
        #For IPv6 address see: http://forums.dartware.com/viewtopic.php?t=452
        #Test cases for IPv6 address (we are using aeron) see http://download.dartware.com/thirdparty/test-ipv6-regex.pl
        #Examples:
        if(length($_[0])<256) {
          if($_[0]=~/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/){#IPv4 address
            return "4";
          }
          elsif($_[0]=~/^(((?=(?>.*?::)(?!.*::)))(::)?([0-9A-F]{1,4}::?){0,5}|([0-9A-F]{1,4}:){6})(\2([0-9A-F]{1,4}(::?|$)){0,2}|((25[0-5]|(2[0-4]|1[0-9]|[1-9])?[0-9])(\.|$)){4}|[0-9A-F]{1,4}:[0-9A-F]{1,4})(?<![^:]:)(?<!\.)\z/i) {#IPv6 Address
            return "6";
          }
          elsif($_[0]=~/^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])(\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9]))*$/) {#Name
          #if($_[0]=~/(([a-z0-9]+|([a-z0-9]+[-]+[a-z0-9]+))[.])+/) {#Name
            return "n";
          }
        }
        return "0";
      }
      
    • Code Block
      
      sub gethostbyname6 {
        #gethostbyname6 yields the IPv6 or IPv6 address for a host name
        # uses dig to get AAAA address for given name
        # returns IPv6 address if successful else returns ""
        my $name=$_[0];
        my $ipaddr="";
        if($ipv eq "4" && gethostbyname($name)) {
          $ipaddr=gethostbyname($name);
          my ($a1, $b1, $c1, $d1)=unpack('C4',$ipaddr);
          $ipaddr=$a1.".".$b1.".".$c1.".".$d1;
        }
        else {
          my $cmd="dig $name -t AAAA";
          if(!($cmd=~ /^([\w\.:\-\s]+)$/)) {#Untaint Check for valid characters
            print "<font color='red'><b>Invalid (tainted) command = $cmd, traceroute aborted!</b></font><br>\n";
            exit 1;
          }
          $cmd=$1; #Untaint $cmd.
          my @result=grep(/\s+AAAA\s+/,`$cmd`);
          foreach my $result(@result) {
            if($result =~ /^;/) {next;}
            my @tokens=split(/\s+/,$result);
            if(defined($tokens[4])) {$ipaddr=$tokens[4]; last;}
          }
        }
        return $ipaddr;
      }
      

...

Converting PingER analysis etc to IPv6 could be an interesting project for someone who wants to be in the vanguard. 

Most of the changes for IPv6 would be required in the analysis phases (see PingER data flow at SLAC for information on the data flow from measurement through gathering and analysis). Thus Anjum was thinking of rewriting the input IPv6 data  with the IPv4 address so leaving the analysis as is. Another thought was to remove the IP address altogether. 

Probably it would be best to port the gathering, archiving, analysis, prsentation code to another site for modification to support IPv6. For some information on portingthe code see PingER#PortingPingERArchivetoNUST.

Hints

An IPv6 host is ipv6.google.com(2001:4860:800f::68)

...

The Linux online manual has a very useful chapter on IPv6-ready test/debug programs