Can ICMP ping return different codes if a ping was successful? - ping

I'm trying to build a ping sweep using ping and am wondering if ping can return a return value if the ping successfully returns or not. Currently I see it just prints to standard out and I have to manually evaluate if a packet returned or not.

Related

Checking understanding of the ping -t TTL flag

I'm checking for comprehension on a homework question for my class. I looked over the man pages for ping and the -t flag didn't have a lot of info on it so I had to infer quite a bit. If someone could verify that my understanding is correct, and perhaps point me to a resource that explains -t flag better than the man pages, I'd appreciate it.
The question:
Write a bash command line that will verify that no more than two network devices are used to pass messages from the syccuxas01.pcc.edu server to the www.pcc.edu server. Use ping with the -t option and see the TTL Details section of man ping.
ping -t 2 www.pcc.edu
My understanding of what that command means and thoughts: The question is poorly worded as "network devices" would be more accurately described as hops. Hops are the steps that a packet of information takes to get to the server you want to send it to, much like if you're going on a car trip, you'll drive through other towns along the way to your destination.
So if we ping the TTL (time to live, which is very dramatic sounding!) [ aka -t ] twice, we're able to get results, which means that there are 2 "hops" to get to www.pcc.edu from the server we access through Putty. TTL from what I understand means how many hops the ping will try to use to send a packet. So ping -t 1 www.pcc.edu will fail. ping -t 3 www.pcc.edu will succeed, but it's using 3 hops, which is not what we want to solve the problem.

nmap retry option to scan list of IPs

I'm trying to scan list of IP addresses using below command
nmap -v -n -sP -iL <IP-list-file.txt>
here I'm looking retry option with nmap command for the failed probe retransmission. Above command will do a single ICMP probe for each IP/hosts. Even I tried with --max-retries no result. So I'm looking a similiar option like { ping -c<2> IP > along with this nmap.
Even tried "-A -T5" no result
Note:- My purpose is to check only whether the host/IP is alive or dead that's it. Preferably nmap utility.
Nmap uses a lot of different methods for host discovery. The options that you used will do one of two things depending on whether you have root privileges:
If you do run Nmap as root, it will send four probes: ICMP Echo Request, TCP SYN to port 443, TCP ACK to port 80, and ICMP Timestamp Request. Only if all four fail to get a response will it mark the target as down.
If you do not run Nmap as root, it will attempt to make a TCP connection to port 80 and port 443. If both of these time out, it will mark the target as down.
So this method is already more robust than simply using /bin/ping. Nmap also retries probes a certain number of times depending on how reliable the network seems. For host discovery, this starts out at 2 retransmits per probe. There doesn't really seem to be a way to increase this without Nmap detecting network problems, so the best way to increase confidence in a "down" determination is to add more host discovery probes using the various -P* options.
The -A and -T5 options will not help at all. -A turns on extra features, none of which will run if the target is considered down, and -T5 simply tells Nmap to assume a very fast and reliable network. It will never retransmit more than 2 times, and will time out probes very quickly. This is almost certainly the opposite of what you want.

How to interpret this particular SMTP response by AOL?

Connect to AOL's mail server:
telnet mailin-01.mx.aol.com 25
You receive:
554- (RTR:DU) https://postmaster.aol.com/error-codes#554rtrdu
554 Connecting IP: 82.xxx.xxx.xxx
Connection to host lost.
Interestingly, the line breaks after the first two lines are <CR><CR><LF>. This is not visible in the telnet output. I determined this using a C# program that prints the bytes.
This appears to be invalid SMTP behavior. Is it? How to deal with that when writing an SMTP client?
(I understand the reason for the error code. The question is not about that but about the apparent protocol violation.)

How to ping website using PHP?

So anyways, I'm working on a small PHP website/script, and as one of the features I'd like to be able to run a Ping Test on the current domain the PHP script is running on. I don't know much about Ping test (well, I know what they do, I just don't know how to run them in PHP) Please let me know how to do it and get same result as : http://www.ipfingerprints.com/ping.php
There is no built-in method to running a ping test in PHP, you must use exec to run the command.
exec('ping -n 4 $ip', $output, $retval);
If you want to send ICMP packets in php you can take a look at this Native-PHP ICMP ping implementation, but I didn't test it.

Luasocket server and actionscript

I used an example given on the Luasocket website just to try it out, my goal was to make a flash game that'll communicate with the socket.
I run the server and connected to it using telnet at first and it worked, every message I sent appeared on the console so I took it to the next step and connected to it through AS 3 and it did connect but the server won't receive any message even though I constantly write() to it.
Is there anything I'm missing that won't let an actionscript application communicate with the lua socket server?
Code
-- load namespace
local socket = require("socket")
-- create a TCP socket and bind it to the local host, at any port
local server = assert(socket.bind("*", 0))
-- find out which port the OS chose for us
local ip, port = server:getsockname()
-- print a message informing what's up
print("Please telnet to localhost on port " .. port)
print("After connecting, you have 10s to enter a line to be echoed")
-- loop forever waiting for clients
while 1 do
-- wait for a connection from any client
local client = server:accept()
-- make sure we don't block waiting for this client's line
client:settimeout(10)
-- receive the line
local line, err = client:receive()
-- if there was no error, send it back to the client
if not err then client:send(line .. "\n") end
-- done with client, close the object
client:close()
end
Actionscript:
var sock:Socket = new Socket();
sock.connect("127.0.0.1",3335);
stage.addEventListener(Event.ENTER_FRAME,test);
public function test(e:Event):void{
sock.writeUTF("Hello world");
}
The standard mode of operation of the client:receive() method is "*l", which waits for a new line character in the input stream to return. http://w3.impa.br/~diego/software/luasocket/tcp.html#receive
To correct this, either send "Hello world\n" (assuming it's the correct escape character in actionscript) or use another parameter in receive().