Thread: ICMP ping network without specifying destination hosts

  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    2

    ICMP ping network without specifying destination hosts

    What is the protocol to send echo ICMP Raw packets to hosts on network without
    specifying destination host. The purpose of this is to write a diagnostic to test
    the network on the src host, such as pinging a network without actually providing
    destination host. The following is a sample of what I tried....
    sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)

    ip->protocol = IPPROTO_ICMP;
    ip->saddr = inet_addr(dest_addr);

    icmp->type = ICMP_ECHO;
    connection.sin_family = AF_INET;
    connection.sin_addr.s_addr = inet_addr(dest_addr);
    sendto(,,,&connection,,,);
    recvfrom(,,,&connection,,,,);

    Thank you. Yehuda

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    You can't send anything on a network without a destination IP address...

  3. #3
    Registered User
    Join Date
    Apr 2011
    Posts
    2
    Thank you. I was under impression that we could broadcast a packet to a live network and get echo back without specifying the destination IP address to perform net-test diagnostics on the src network port. Thank you

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Yehuda View Post
    Thank you. I was under impression that we could broadcast a packet to a live network and get echo back without specifying the destination IP address to perform net-test diagnostics on the src network port. Thank you
    Yes you can broadcast on networks where the router supports it... but even then you need the broadcast IP for that router... and you won't get a ping response on that address. The whole idea behind most ICMP functions is that of checking the status of a specific host server... not the machine you are sending from.

    If you want to do a self-test... have the machine ping itself... i.e. destination IP = source IP

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Scanning for hosts.
    By wierdbeard65 in forum Networking/Device Communication
    Replies: 8
    Last Post: 06-26-2008, 06:20 AM
  2. Obtaining source & destination IP,details of ICMP Header & each of field of it ???
    By cromologic in forum Networking/Device Communication
    Replies: 1
    Last Post: 04-29-2006, 02:49 PM
  3. Web Hosts
    By RoD in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 10-02-2002, 04:41 PM
  4. Free mud hosts
    By knight543 in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 01-25-2002, 08:56 PM