LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Network checking

Hello all,

 

I need small help. Please help me.

 

In one of my application, I’m downloading some data from server.

Before downloading, I need to check network connection (is it OK/Not).

 

I’m using below snippet for checking the network connection but it is taking 20sec (Average).

I want to reduce this time. Is there is any better idea?

 

Network Checking.png

Munna
Message 1 of 20
(6,209 Views)

Take a look at the help of the ping command. You can set the number of requests to 1, i.e. ping -n 1 google.com. This is much faster.

 

If you want to check the connection of your computer to the network, the 'String to IP' function in the TCP VI and Functions palette is faster. It resolves the net address, for example of google.com, very fast, if your PC is connected to the network.

Message 2 of 20
(6,192 Views)

Dear Chembo,

 

Thanks for your reply & Nice ideas.

I checked both the ways. Second option is much faster. Please confirm if there is any changes required.

 

Network Checking2.png

Munna
0 Kudos
Message 3 of 20
(6,175 Views)

Why don't you just try to connect to the server directly? If you get an error, the network (or the server!) is down. If you only check the network, it does not prove that the server is reachable, so what's the point?

0 Kudos
Message 4 of 20
(6,172 Views)
To expand on Christian's question, how are you getting the data? Downloading files? Querying a database? Something else?

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 5 of 20
(6,163 Views)

Yes, I need to download some files from server.

 

I used “Check if File or folder exists.vi” to validate my server path but it’s taking more time.

So that’s why I thought of using other way. Please let me know if there is any other way.

 

As Christian said, there is no use if server is down.

Before connecting to server, first I’m validating network connection.

Once it is done, trying to download files from server. If server/network is down then stopp downloading.

Munna
0 Kudos
Message 6 of 20
(6,150 Views)

@Munna232 wrote:

Yes, I need to download some files from server.

.......

In this case ping is probably a good choice,  if the Check if File or folder exists.vi takes much longer. You could even reduce the waiting time of the reply with the -w option.

ping -n 1 -w 20 server_name will send just a single request and wait 20 milliseconds before timeout.

 

The screenshot in your post shows that the ping timed out, but the connection check is TRUE. You need to parse the response instead of checking the string length. For example, use the Match Pattern function to find if 'Lost = 0' is present in the output.

 

Much easier and better is to check the return code of the System Exec. The return code is 0 if the ping was successful and 1 if there was an error.

I am not sure what is the return code when the ping times out, but it is 1 when the server was not found.

 

0 Kudos
Message 7 of 20
(6,112 Views)

Thanks for your reply.

 

Yes, it’s much faster.

Here, I’m getting return code of System Exec.vi is always “1”.

 

What about second idea? I think option-2 is much faster than option-1.

 

Network Checking3.png

Munna
0 Kudos
Message 8 of 20
(6,101 Views)

I think you're overcomplicating the last bit of logic and that's part of what's breaking your logic.

 

In your last screenshot, you are checking to see if you see "Lost = 1" at least 0 times.  If so, you're claiming you're connected.  Let's take a quick truth table.

 

You have two options.  Lost = 0 or Lost = 1.  In the first case, you'll see Lost = 1 0 times.  In the second case, you'll see Lost = 1 1 time.  In both cases (0 and 1), you're seeing a value greater or equal to 0.  In both cases, you'll report connectivity.  This isn't what you want.

 

If you want to search for lost, you want to either check for Lost = 0 is equal to 1 or Lost = 1 is less than 1.  You don't want lost to ever flag a valid connection.

0 Kudos
Message 9 of 20
(6,062 Views)

Thanks for your reply.

 

Actually I'm planning to use option-2. because it is much faster.

Do you have any comment on that?

Munna
0 Kudos
Message 10 of 20
(6,053 Views)