# ping vs. ping6

## wswartzendruber

Is there some reason why the two are separate?  Why are they not merged together with -4 and -6 paramters?

----------

## gerdesj

 *wswartzendruber wrote:*   

> Is there some reason why the two are separate?  Why are they not merged together with -4 and -6 paramters?

 

That's a fair question but not one for these forums.  

ping6 is not a symlink to ping so I think they are separate binaries.

"man ping" and "man"ping6" seem to be identical.

It might to help to think of the word dialect:

Why does ps not need "-" for its switches or tar?

Why do "key" and "quay" sound similar in en_GB (at least)?

You should probably contact the writers of ping itself.  

Cheers

Jon

----------

## wswartzendruber

I'm having trouble finding an email address.

----------

## Hu

The package homepage leads me through a few redirects, but dropped me on a page that linked to iputils.  Near the bottom of the useful content of that page, I see: *Quote:*   

> 
> 
> Maintainer: YOSHIFUJI Hideaki <yoshfuji at linux-ipv6 dot org>
> 
>     * Previous maintainer was Alexey Kuznetsov <kuznet at ms2.inr.ac.ru>

 

----------

## truc

I'd also be interested in his answer, so if you get one, please share it with us. I suppose it'll also apply to traceroute6/traceroute

----------

## wswartzendruber

Here's what I said:

 *Quote:*   

> Dear Mr. Hideaki:
> 
> I have noticed that ping functionality for IPv4 and IPv6 reside in two separate commands, and I am wondering why this is.  Actually, a few of us on the Gentoo Forums are wondering why (relevant thread).
> 
> OpenSSH has functionality for both protocols, and you can manually specify which one by passing either "-4" or "-6" to ssh.  This is also how ping on Windows works.
> ...

 

Now I'm waiting for a reply.

----------

## salahx

I would suspect the reason why is that the difference between ping and ping6 isn't simple just a change to socket(). ping has to use a raw socket, and thus has to build the all the headers by hand. ipv4 and ipv6 have totally different structures, protocol number, etc - so the only thing they'd share would be the argument parsing code.

----------

## wswartzendruber

 *salahx wrote:*   

> I would suspect the reason why is that the difference between ping and ping6 isn't simple just a change to socket(). ping has to use a raw socket, and thus has to build the all the headers by hand. ipv4 and ipv6 have totally different structures, protocol number, etc - so the only thing they'd share would be the argument parsing code.

 

I understand that, it's just a nightmare usage-wise.  Okay, so I can't get to a website.  Uh, do I use ping or ping6 to test it?  I know, I'll first do nslookup to see what kind of records it returns.

See, if a website is down on Windows, you just use "ping" and it automatically selects depending on what's returned from the DNS query.

EDIT:  Or you can force one via a command line argument.

----------

## wswartzendruber

I found the reasoning in the ping6 man page that's online:

 *Quote:*   

> The ping6 utility is intentionally separate from ping(8).
> 
>      There have been many discussions on why we separate ping6 and ping(8).
> 
>      Some people argued that it would be more convenient to uniform the ping
> ...

 

EDIT:  This still doesn't make it any easier to use.

----------

## wswartzendruber

Just got this back from the author:

 *Quote:*   

> As you know, this was because "raw" API and packet format are
> 
> different.  We put ping/ping6 common parts in "ping_common.c".
> 
> Note: In SSH case, there is little difference in the wire format.
> ...

 

----------

## truc

I think I agree with how it works in windows/

ping -> IP proto not specified so so do as any other software do, check IPv6 first then fallback on IPv4, then ping -4 ping -6,

This retro-compatibility requirement sucks IMO

----------

## wswartzendruber

I just sent him this:

 *Quote:*   

> What about:
> 
> 1. Have a single "ping" binary.
> 
> 2. Have a symlink from "ping6" to "ping" that forces IPv6 (check argv[0]).
> ...

 

----------

