Tiny UDP GPS data gathering server

Gpsdgs is distributed under a license GPL3+

The purpose of this software is the ability to create your personal server to track own devices, and saving location data without using a third-party servers for storing private information on the whereabouts.

This software is used in conjunction with the client, or any other, which may transmits the information over UDP as following:

  1. UID of user
  2. Time since the UNIX epoch (seconds)
  3. Latitude (degrees and fractions of a degree)
  4. Longitude (degrees and fractions of a degree)
  5. Speed (meters per second)
  6. Direction (degrees)
  7. Accuracy (meters)
  8. Height (meters)
  9. Flags (two numbers), the first number: 0 - GPS point 1 - GSM point; the second number: 0 - the point from the cache, 1 - through point, not from the cache
  10. Battery charge (%), also may consist some events: tracker enabled - 127, connecting to the internet - 109, charger connected - 107, connected to USB - 108, disconnected from the internet - 105, runned GPSMTA service - 110 , switched to battery - 106.
  11. Battery temperature (Celsius)
  12. Battery status: 1 - charged, 0 - no charge
  13. The second line is not used and is always 0

Example of valid UDP packet from the client: 123456789 1401610649 45.32175 32.14598 25 139 25 115 00 75 25 0 0

Server is send response, containing the same time stamp that was in the incoming UDP packet, if client data successful parsed and saved.

Example of valid UDP packet from the server: 1401610649

Usage: gpsdgs [OPTION]
        --version – print the version number of gpsdgs and exit
        --debug – enable loging in stdout
        --help – display this help and exit

/etc/gpsdgs.conf — config file. If file is not exist, it will be created with the default values (need root privileges).
Default values:
        debug=1 – enable logging in stdout (priority lower than command line option)
        udpport=5300 – UDP port
        dbname=gpsdata – name of used database
        dbhost=localhost – address or name postgresql server
        dbport=5432 – postgresql server port
        dbuser=gpsuser – username for database connect
        dbpass=gpsu – password for database connect


  1. Response packet is sent if the client UDP packet contain unique pair of UID and time stamp that are already saved in the row of table. But this is not checked properly.

Contact to Michael Tatarko to correct errors or typos.




Addition testing user with uid=0 into users table:

INSERT INTO users VALUES (0,' ',' ',' ',' ',1,0);

Use gpsdgs-bench util for testing:

gpsdgs-bench <domain or ip> <udp port> [packet number (1-1000, default=50)]

The client so fast sends the packet again, until it receives a response from the server. Do not be surprised that sent much more than received.

~ # gpsdgs-bench lumi.pw 5300 1000
Connect to:
current:783	total:25898	receive:1000	left:0
Client send 25898 request at 3.393917s. (~7630.711 rps)
Server send 1000 answer at 3.393877s. (~294.648 aps)

And then delete garbage from tables users and data:

DELETE FROM users WHERE uid='0';
DELETE FROM data WHERE uid='0';

Coverity Scan Build Status