This page describes the protocol used by the Map/Mod Downloader.

services

  • torrent tracker: http://tracker.caspring.org:8201/announce
  • p2p coordinator: tracker.caspring.org:8202 (tcp stream)
  • site: http://tracker.caspring.org/ (will change to root of tracker in the future)
  • backups: tracker2.caspring.org, backup-tracker.licho.eu

site

The site provides torrent browsing in /torrents subfolder, each torrent named by unitsync hash. Site also provides torrent uploading (using upload_torrent.php <- put file to fname file variable).

The torrent file must contains special data in its comment: "name|type" type being MOD or MAP now and name name of mod or map from unitsync.

Site also contains and maintains several legacy files, like torrent.txt, requests.txt and battles.txt

P2P coordinator

This service runs at tracker.caspring.org:8202 - its purpose is to notify clients about new torrents and to distribute information that seeding is needed for some torrent. It can also provide "tracking" - it can take lobby user name and direct client to start downloading maps needed for his game or notify client that his spring started.

Protocol used by coordinator is similar to TasServer?, each command is one line and arguments are divided by "|" symbol.

server commands

command meaning
T+|hash|name|type informs client that new torrent was added to server (type is either MOD or MAP)
T-|hash informs client that torrent was removed from server
S+|hash|seeders|leechers tells client that seed is needed for this torrent
S-|hash tells client that seed is no longer neede for this torrent
L+|hash tells client that it should leech this torrent
L-|hash tells client that he no longer needs this torrent
INGAME|mode tells client that his ingame status changed - mode is 1 or 0
PING every minute - client must respond with its own "PING"
M+|hash|url It tells the client if url is given that http mirror exists for given hash, else there are no mirrors.

client commands

TRACK_MAP|mode|username this tells server that client requests tracking. Mode is either "NONE", "ALL", "PLAYER"
NONE - server only informs about ingame status changes
PLAYER - server only sends leech commands for maps needed by this player (if he joins some lobby game or lobby map changes server sends leech commands)
ALL - leech commands will be sent for all currently hosted maps
PING in response to server PING
N+|hash requests mirror list and seeding from server
N-|hash stop requesting seeding from server

basic client operations

  • Upon start or when map folder changes, torrent files are created for all maps and mods and stored in special folder. Torrents have announce address set to tracker and comment set by special rules notified earlier.
  • Client connects to p2p coordinator and coordinator and coordinator sends its list of known torrents.
  • When seed command is recieved, client starts seeding requested file (if it has it).
  • When client wants to download new file it gets torrent for it from http://tracker.caspring.org/torrents/<map hash>.torrent and starts leeching it. All other clients are notified instantly that seeding is needed using p2p coordinator.
  • New files are added to system using torrent upload to http://tracker.caspring.org/upload_torrent.php (again all clients are notified instantly through p2p coordinator that file has been added).

General remarks

  • Client should not download more than 5 torrents at once, server enforces this internally by not sending further seed requests if more than 5 files are requested.
  • Client should reannounce every 15s during first minute of leeching/seeding to ensure optimal performance and after that every minute.