fping on windows

I started working on a ping plotter a while ago and back then I still was on linux and was currently getting into C. Now that I’m not on linux anymore I kinda dropped the project for a while. After that pause I’ve finally gone back I decided to ditch C and write it in Python since I’m developing it on windows but want it to work on linux aswell. The ping plotter is supposed to ping an ip over a timespan and then make a graph out of the latency values. For that I’ll use the ping command since that’s the easiest way to get latency values without adiministrative rights. The issue is that the windows ping.exe and the linux ping command return different outputs so formatting them means I have to differenciate between windows and linux.

After some searching I came across fping which is a custom ping program for linux. It’s designed to be used in scripts which digest it’s output. So now the only issue is to compile that for windows. I used cygwin for it since nobody seems to have done it before me. Sadly the build script returns errors when compiling. So here’s how I fixed that:

First get the sourcode from the releases. Now we’ll need to convince cygwin that we have the right headers. Download this header file (made by John Paul Morrison) as icmp.h. Copy it into these folders and replace it with the icmp.h that is in those folders (That one is empty, you can open it if you want):

\usr\include\icmp.h
\usr\include\cygwin\icmp.h

The path to cygwin will usually be C:\cygwin64\ or C:\cygwin\. Now you can run

$ ./configure
$ make

Now you’ll have a fping.exe in the ./src/ folder. Run a command prompt as admin and then run something like

C:\fping\src>fping.exe -s google.com

That should give someting like this

google.com is alive

       1 targets
       1 alive
       0 unreachable
       0 unknown addresses

       0 timeouts (waiting for response)
       1 ICMP Echos sent
       1 ICMP Echo Replies received
       0 other ICMP received

 36.6 ms (min round trip time)
 36.6 ms (avg round trip time)
 36.6 ms (max round trip time)
        0.038 sec (elapsed real time)

Pretty cool, huh? But if you read carefully it needs adminstrative rights on windows and root rights on linux so all of that was kinda wasted… I’ll just use the output of the native ping commands instead but if anyone needs fping on windows here you go. For those whore are to lazy to compile it themselves you can download my compiled binary for windows here (By the way there seems to be an infected version of fping on the web so if you need some confidence, that this one isn’t a virus heres a virustotal scan or scan it yourself). It’s completely unmodified and all credits go to the original authors.

I’ll now go back to getting back into python and formatting ping command outputs. Wohoo.

Advertisements

Clearscreen

I mentioned a while ago that I got a second monitor, which a long needed upgrade for me. I’ve been using only one screen for quite a while and for a lot of things it can get very frustrating to only have one screen. For example when playing a game in fullscreen your entire screen space is used up by one program, or when I needed to run two instances of a program for debugging, or when working on any project which requires to switch between programs like the webbrowser and something like Powerpoint.

Now that I have that second screen it’s obviously a lot more comfortable doing these things, but from time to time I still turn the other screen off because I notice that I don’t need it. The problem that comes up with that is that Windows remembers where you closed a program, so when opening for example the taskmanager and the last time I used it it was on the second monitor, I won’t see it since it’s turned off. So for now I’ve always either turned it back on again or just blindly guessed where the program is and dragged my mouse around in the dark.

Since that’s not an efficient solution I put together a small program that’ll move all windows (Almost all windows) that are open on one screen to another.

The program gets all it’s settings over arguments and is generally really small and probably unfinished but it does the trick for me. You pass it the dimensions of your main screen (Left, Right, Top, Bottom coordinates), which you can find out by running the progam with the –setup flag and finally pass it the coordinates of a point to which it should move all programs on the main screen.

It works pretty ok, it just doesn’t seem to want to move the file explorer since it’s probably the same process as the taskbar. At some point it also moved my taskbar, which made up for some interesting results like two taskbars stacked onto eachother. So I ended up blacklisting the explorer process.

And as always here‘s the sourcecode and the binary. I suggest launching the program from a shortcut with arguments.

Wifi issues

This is something that I already dealt with about a year back but it has come again to hunt me. A year back I tried to make use of an old laptop (An IBM T23 to be exact) and install linux on it. The laptop doesn’t have any internal wifi card so I went with an old wifi usb drive. But that thing was already hard to use on windows so getting it to work on linux was a whole different story. First I needed ndiswrapper to get the windows driver to work. But that didn’t do the trick so I went ahead and asked on the Arch linux forums. In the end I dug up a solution which worked for me back then.

A year later I dig up another laptop (An IBM T41 this time) and tried the same procedure. Sadly the thing that did the trick last time wasn’t the whole solution. After some more careful reading of my old thread I put together what is needed to get a wifi pci card or a wifi usb drive to work on an old ibm with linux:

First you need ndiswrapper. For Arch it’ll look like this:

$ sudo pacman -S ndiswrapper

If you have issues running ndiswrapper later you might need the linux headers:

$ sudo pacman -S linux-header

Next up we need to install the driver:

$ sudo nidswrapper -i <driver>.inf

The *.inf file is usually distributed with the driver, sometimes it’s inside the *.exe which means you’ll need to extract it using cabextract.

Now you want to plug in the device of which you just installed the driver and run

$ ndiswrapper -l 

This will list all installed drivers and wether or not the device is present. If it says so the driver is correct and the device is recognized. Now with most devices the last thing you want to do is load ndiswrapper on startup using

$ sudo ndiswrapper -ma

And since this is your first time using it you’ll have to load it manually once:

$ sudo modprobe nidswrapper

Now the device should be ready to use and you can connect to your network using a network mananger or wpa_supplicant. But for me this wasn’t all that was needed. What I need to do is disable ipv6 by editing /etc/sysctl.d/40-ipv6.conf

net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.<wifi device>.disable_ipv6=1

You can find the device name by typing ip link and for me it was the last listed device. The next thing to do is add these two lines to /etc/dhcpcd.conf

noipv6rs
noipv6
# Also comment out the line that says something like 'ipv4all'

Now this command has to be executed on every startup:

$ sudo dhcpcd <wifi device> --nohook mtu
# Once again get the wifi device with ip link

Now finally we’ll generate a wpa_supplicant config using

# wpa_passphrase <Networkname> <network password> /home/<username>/wifi.conf

You can get your exact Network name by scanning for networks over:

$ sudo pacman -S wifi-menu
$ sudo wifi-menu

Don’t use wifi-menu to connect (It’ll probably not work, but you can try).

Finally we can use the config to connect via wpa_supplicant:

sudo wpa_supplicant -D wext -B -i <wifi device> -c /home/<username>/wifi.conf

To automate the connection you can follow the Arch wiki or create a service.

And that’s it, wasn’t all that hard, right? 😛