ping from different node

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • selvialagar
    New Member
    • Apr 2008
    • 57

    ping from different node

    i'm doing icmp implementation in vc++.net 2003.when i receive icmp packets, it comes from the different system..what is the reason?is it correct?
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    The icmp packet should be coming from someone else yes.
    Did you look at the docs on icmp?

    Comment

    • selvialagar
      New Member
      • Apr 2008
      • 57

      #3
      Reply comes from the node different from what i am expected.

      When i gave ping 172.20.20.23, reply comes from other system...is it correct

      or not?

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        Well they get changed.
        If a series of devices are connected, where lowercase is a computer and uppercase are routers:

        a - B - C - d

        If you ping d from a, your icmp response will come from B, since each packet gets stopped on the way I believe.
        I *think* this is what you are seeing. Another explanation could be a byte order mistake, like you think you're pinging one address but really it's different one due to a byte order mistake?

        Comment

        • selvialagar
          New Member
          • Apr 2008
          • 57

          #5
          Thanks for your reply..

          Code:
          iphe =Dns::Resolve(s); 
          		Console::WriteLine(S"Host Entry :{0}",iphe->HostName->ToString()); 
          		IPAddress* ipad = __try_cast<IPAddress*>(iphe->AddressList[0]);
          
          		Console::WriteLine(S"IP Address : {0}",ipad->ToString()); 
          		IPEndPoint* ipe = new IPEndPoint(ipad,80);
          EndPoint* senderRemote = __try_cast<EndPoint*>(ipe);
          		Console::WriteLine(S"Sender Remote :{0}",senderRemote->ToString());  
          
          DateTime dt=DateTime::Now;	
          		int iRet;
          		st->SetSocketOption(SocketOptionLevel::Socket,SocketOptionName::IpTimeToLive,32);
          		st->SetSocketOption(SocketOptionLevel::Socket,SocketOptionName::SendTimeout,500000);
          Byte RecvByte[]=new Byte[256]; 
          			  iRet=st->ReceiveFrom(RecvByte,RecvByte->Length,SocketFlags::None,&senderRemote);
               	      TimeSpan ts=DateTime::Now -dt;
          			if(iRet==-1)
          			{
          					Console::WriteLine(S"Error Getting Data"); 
          			}
          			Console::WriteLine(S"Reply From :IP={0,-20} TTL={1,-10}  Time={2,3}ms",senderRemote->ToString(),RecvByte[8].ToString(),ts.Milliseconds.ToString());
          this is my code..here before i got reply from the destination,the IP address is printed correctly.But after i getting reply the destination address has changed..

          My assumption is.. the packet from the destination comes through different node..the actual reply is from the actual destination..


          Another problem is i am getting very late response...even i ping my node response is very late.what is the reason for that?can i minimize the response time?

          i'm awaiting for your reply..

          Comment

          • Plater
            Recognized Expert Expert
            • Apr 2007
            • 7872

            #6
            What happens when you ping with a regular ping command in windows?
            Or use the actual ping implementation in .NET?

            If you do a traceroute to that same address, does the "next hop" have the ip address you are seeing on the return of YOUR ping?

            Comment

            • selvialagar
              New Member
              • Apr 2008
              • 57

              #7
              In Regular ping commad, the response comes immediatly.I used the actual ping implementaion.

              When i checked the IP datagram header,the TTL always 128.If the packet comes from the different node, TTL field might be decremented by 1 or 2.but in my case the TTL always 128.

              Here is my output of my program.I displayed first 60 bytes of the returning IP packet.when i send ping 172.20.20.24,th e reply comes from 172.20.20.6 which is the server.Sometime s the reply comes from other IP address

              IP Address : 172.20.20.24

              Data Sending to 172.20.20.24:80

              Reply From :IP=172.20.20.6 :0 TTL=128 Time=213ms

              69 0 0 60 148 184 0 0 128 1 37 190 172 20 20 6 172 20 20 28 0 0 65 94 2 0 20 0 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 65 66 67 68 69 70 71 72 73
              Data Sending to 172.20.20.24:80

              Reply From :IP=172.20.20.6 :0 TTL=128 Time=213ms
              69 0 0 60 148 186 0 0 128 1 37 188 172 20 20 6 172 20 20 28 0 0 64 94 2 0 21 0 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 65 66 67 68 69 70 71 72 73
              Data Sending to 172.20.20.24:80

              Reply From :IP=172.20.20.6 :0 TTL=128 Time=758ms
              69 0 0 60 244 161 0 0 128 1 197 212 172 20 20 6 172 20 20 28 0 0 63 94 2 0 22 0 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 65 66 67 68 69 70 71 72 73
              Data Sending to 172.20.20.24:80

              Reply From :IP=172.20.20.6 :0 TTL=128 Time= 71ms
              69 0 0 60 244 163 0 0 128 1 197 210 172 20 20 6 172 20 20 28 0 0 62 94 2 0 23 0 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 65 66 67 68 69 70 71 72 73

              Comment

              Working...