How ping command work - ping

in order to code a program, i need to know how the ping command is working.
I need to know, if a command ping -c1 "something" is executed, how many ipv4 packets and ethernet frames will be created ? considering that every cache is empty
thanks..

The ping command uses ICMP packets. In order to code a ping command you need to be able to send and receive ICMP packets.
In windows, this is done using winsock raw socket support. Here is an example of a ping using raw sockets.
In Linux, you just need sockets support. Here is a stack overflow question about how to do ICMP packets in Linux.
Or you can find a library that implements this for you.

Reply from 192.168.2.10: bytes=32 time<1ms TTL=128 - **Computer is on OS kernel still in memory**
Request timed out. - **OS is shutdown/Firewall blocking ICMP**
Reply from 192.168.2.10: Destination host unreachable. - **Computer powered off. Physical network active**
Here is the ping command explained for troubleshooting

Related

RSYSLOG listening on ephemeral (high) port

I've been poking around the internet trying to get an answer to this one but so far I've only seen it as "normal" behavior.
I have a fedora 29 host configured to send rsyslog messages over the default 514 port. That works as intented and has been for some time now. I had a client notice that the host would "listen" on an ephemeral port that appears to change with each reboot:
ss -tulnp | grep 46852
udp UNCONN 1536 0 0.0.0.0:468520.0.0.0:* users:(("rsyslogd",pid=676,fd=15))
also:
lsof -i :46852 -P
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
rsyslogd 676 root 15u IPv4 24836 0t0 UDP *:46852
Anyone know why rsyslog is doing this? It appears to be default behavior, and I'm not worried about it as the port can't be hit externally (firewall prohibits it) but just wanted to understand it. I also couldn't find anything in the rsyslog docs that talked about it.
Thanks!
This is just observed behavior I am curious about.
This isn't something that rsyslog is doing, but rather your OS.
Clients are assigned port numbers (random and sequential) by your operating system, as part of the sequence of system calls, that create a network connection. For example TCP and UDP typically use an "ephemeral" port for the client-end of a client–server communication.
These port numbers are - as you said - called "ephemeral" because they are valid only for the life of the connection and have no special significance.
As to why ephemeral ports are used.. I don't know. Maybe someone on ServerFault or Network Engineering can answer this question.
From my understanding ephemeral ports can be used either temporary or private. So if a service (temporarily) needs a port it can use an ephemeral port. After the service has done it's requests and has timed-out for some time, the port is released and can be used by some other service. This way a service doesn't block a port even though it doesn't even use it, or just frequently uses it.

IDAS not connecting to the ContextBroker

i'm having a problem sending the mesurements to the contextBroker.
I have the ContextBroker running on a CentOS virtual machine. On another CentOS virtual machine i'm setting the figway config.ini file with the host=/ContextBroker Virtual Machine Host IP/ and Port=1026. When i send mesurements to my ContextBroker:
python2.7 SendObservation.py Bus1 't|1'
it simply doesn't stick the values to the entity. It gives me a code:200 but the response is just blank.
What am i doing wrong?
UPDATE:
Even when i do from one VM to another (to the one where the contextBroker is running) the command:
GET *ip*:1026/version
, it returns nothing.
UPDATE:
Running
GET localhost:1026/version
works. Returns what's supose to return.
The problem could be similar to the one described in the answer to this question. The most probable causes of Orion connection problems are:
Something in the Orion host (e.g a firewall or security group) is blocking the incoming connection
Something in the client host (e.g a firewall) is blocking the outcoming connection
There is some other network issue is causing the connection problem.

Can you run a true ping in Java?

I have done a fair amount of research these last few weeks trying to create a connection diagnostic tool, I don't so much want to just check to see if the connection is available but to diagnose if there is jitter, packet loss, etc..
So far it seems that Java doesn't support a true ICMP request and that there are a few workarounds out there but none of which achieve what I'm trying to do.
Does anyone know if this sort of tool can be built or should I start looking into other options?
It seems that InetAdress is using ICMP when its possible:
https://docs.oracle.com/javase/7/docs/api/java/net/InetAddress.html
take a look at public boolean isReachable(int timeout)
Test whether that address is reachable. Best effort is made by the
implementation to try to reach the host, but firewalls and server
configuration may block requests resulting in a unreachable status
while some specific ports may be accessible. A typical implementation
will use ICMP ECHO REQUESTs if the privilege can be obtained,
otherwise it will try to establish a TCP connection on port 7 (Echo)
of the destination host.
You can find a simple use example here:
How to test if a remote system is reachable
or here How to ping an IP address
I believe ICMP4J does exactly what you need: Internet Control Message Protocol for Java
You can use 'Exec' to run ping at the command line (assuming your OS supports this), or JNI to interface to a native application to do the pinging.
Creating your own implementation of the ICMP protocol would not be trivial.
If you do use Exec be aware of it's limitations which are not always obvious in initial testing:
http://www.javaworld.com/article/2071275/core-java/when-runtime-exec---won-t.html

AS3 - Datagramsocket without port

I want to make multiplayer game, and I want it to use UDP sockets. Because of that, I want to use DatagramSocket. The problem is that DatagramSocket needs to be bound to a port on both sides. Is there a way to create a server - client program with UDP that does not need the client to portforward? (Like Serversocket and Socket).
Remember that UDP is connectionless. You send a packet of data to some IP address and hope it knows what to do with it once it gets to the targeted machine. But actually once it's on the machine it has no idea where to go from there, is there an application that's interested in these packets? And this is precisely why you need to specify a port number that is registered to forward packets to specific application on the machine.
Send a packet to myself to the application running on port 7000: 127.0.0.1 : 7000

Check latency if server denies ping requests

the server I need to check the latency of is denying PING requests, is there another way to check my latency to the server? Thanks in advance.
Use a ping based on TCP.
If you have access to a Windows box, use http://technet.microsoft.com/en-us/sysinternals/jj729731.aspx
Download the zip, unpack. From CMD prompt cd to unpacked folder, then run with -t flag like this:
psping.exe -t www.anywebsite.com:80
Please note: this assumes you have a web site running on remote host (port 80 in example above)
Some people recommend hping which can use other protocols like TCP (for when ICMP is denied).
Note that I haven't tried it so I would be curious to know your experience if you do.