bwping patch (catching signals)

Written by Christophe Lucas - - no comments
diff -urpN bwping/bwping.c bwping-patched/bwping.c
--- bwping/bwping.c     2012-10-11 19:23:17.000000000 +0200
+++ bwping-patched/bwping.c     2017-04-20 09:06:23.449540033 +0200
@@ -26,6 +26,7 @@
 #ifdef __CYGWIN__
 #include "cygwin.h"
@@ -224,21 +225,39 @@ static int recv_ping (int sock, int iden
         return 0;
+unsigned int   transmitted_number, received_number;
+unsigned long  int received_volume;
+struct timeval begin, end;
+void sig_handler(int signo)
+       if (signo == SIGUSR1) {
+                printf("Total: pkts sent/rcvd: %u/%u, volume rcvd: %lu bytes, time: %d sec, speed: %lu kbps, rtt min/max/average: %llu/%llu/%llu ms\n",
+                               transmitted_number, received_number, received_volume, (int)(end.tv_sec - begin.tv_sec),
+                               end.tv_sec - begin.tv_sec?((received_volume / (end.tv_sec - begin.tv_sec)) * 8) / 1000:(received_volume * 8) / 1000,
+                               min_rtt==DEF_MIN_RTT?0:min_rtt, max_rtt, average_rtt);
+               exit(255);
+       }
 int main (int argc, char **argv)
     int                    sock, exitval, ch, ident, finish, pktburst, i, n;
-    unsigned int           bufsize, tos, transmitted_number, received_number;
-    unsigned long int      kbps, pktsize, volume, rperiod, received_volume;
+    unsigned int           bufsize, tos;
+    unsigned long int      kbps, pktsize, volume, rperiod;
     unsigned long long int min_interval, interval, current_interval, integral_error;
     char                   *ep, *bind_addr, *target;
     fd_set                 fds;
     struct sockaddr_in     bind_to, to;
     struct hostent         *hp;
-    struct timeval         begin, end, report, start, now, seltimeout;
+    struct timeval         report, start, now, seltimeout;
     sock = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
+       if (signal(SIGUSR1, sig_handler) == SIG_ERR)
+               printf("\ncan't catch SIGUSR1\n");
     if (sock==-1) {
         perror("bwping: socket(AF_INET, SOCK_RAW, IPPROTO_ICMP) failed");

Download : patch-bwping-sig.diff

Linux : Remote desktop && Hamachi

Written by Christophe Lucas - - 1 comment
For those of you which need to access by means of "Remote Desktop" you can use :

  • Nomachine NX

  • Teamviewer

  • VNC

And you can use both LogmeIn Hamachi and VNC. Hamachi is a software which can make network betweeen devices. Against logmein product which lot of you know, here it is at ~~Level2~~ (OSI).


How you create your VPN ?

For Linux users, you must install vnc4server and hamachi (supplied by LogmeIn) package (dpkg is your friend). Then you launch your vnc server :
root@plop# vncserver 
New 'plop:1 (clucas)' desktop is plop:1

Starting applications specified in /home/clucas/.vnc/xstartup
Log file is /home/clucas/.vnc/plop:1.log

Now the VNC server is reacheable by means of 5901 (5900 + 1) port.

Then you can create your VPN network by using hamachi :
root@neptune:~# hamachi -h
LogMeIn Hamachi, a zero-config virtual private networking utility, ver

usage: hamachi [command]

command specifies an action. Can be one of the following -

# set-nick
# list
# create []
set-pass []
set-access [lock|unlock] [manual|auto]
# approve
# join []
do-join []
# go-online
# attach
# gw-config
[dhcp|static [net ]
[domain ]
[dns []]]
[del ...]
[add ...]
# set-ip-mode ipv4 | ipv6 | both
# check-update
vpn-alias |0
If no command is specified, hamachi displays its status including version,
pid, client id, online status, nickname and the LogMeIn account
root@neptune~# hamachi attach
root@neptune~# hamachi join network password
root@neptune~# hamachi go-online network

You have now access to your Linux server/desktop from anywhere by means of hamachi's device :

















For mac users (such as me : not a really experimented user), you have a built-in VNC client in MAC from 10.5 MAC OS X.
Go in your finder window > Go > Connect to server >
Now you can access to your device by means of :
vnc://x.y.z.w:5901 (where 5900 + X display : here :1)
Classified in : Linux - Tags : none

Float and divide into bash

Written by Christophe Lucas - - no comments

It is a funny and simply tip under bash.

How to deals with float and division under bash. 'bc' is your friend such as :

clucas@jupiter:~$ i=$( echo "scale=3; 1/3" | bc)
clucas@jupiter:~$ echo $i

It must found on the net (where I found), but searchable for me on this stuff for future.

NdR :

clucas@pluton:~$ i=$((1/3))
clucas@pluton:~$ echo $i

Classified in : Linux - Tags : none
Rss feed of the category