Skip to content

wizrd00/rufshare

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

139 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RUFShare

RUF CRC Language Platform

RUFShare (Reliable UDP File Sharing) is a lightweight file transfer library built on top of UDP, designed to provide reliable file delivery while maintaining the performance advantages of connectionless communication.

The library implements a custom protocol that handles:

  • Peer discovery
  • File transfer negotiation
  • Chunked data transmission
  • Integrity verification using CRC16/CRC32
  • Acknowledgement and retransmission mechanisms

RUFShare is written in pure C99 and targets Unix-like systems.


Features

  • Reliable file transfer over UDP
  • Custom packet-based protocol
  • Peer discovery through broadcasting
  • Chunked file transmission
  • CRC-based data integrity validation
  • Shared library interface
  • Minimal external dependencies
  • Suitable for embedded, networking, and systems programming projects

Protocol Overview

RUFShare uses four packet types:

Packet Purpose
CAST Peer discovery and broadcasting
SEND File transfer metadata
FLOW File data chunks
RECV ACK/NACK responses

Transfer Flow

Sender                     Receiver
  |                             |
  |-------- CAST -------------> |
  | <------ CAST -------------- |
  |                             |
  |-------- SEND -------------> |
  | <------ ACK --------------- |
  |                             |
  |-------- FLOW -------------> |
  | <------ ACK/NACK ---------- |
  |                             |
  |-------- FLOW -------------> |
  | <------ ACK/NACK ---------- |

Project Structure

include/
├── broadcast.h
├── cntl.h
├── data.h
├── file_stream.h
├── net_stream.h
├── puller.h
├── pusher.h
├── scanpair.h
├── tryexec.h
└── protocol/

source/
├── broadcast.c
├── cntl.c
├── data.c
├── file_stream.c
├── net_stream.c
├── puller.c
├── pusher.c
└── ...

library/
├── librufshare.so
└── libcrc.a

Building

PCC (default)

make

GCC

make CC=gcc

Generated library:

library/librufshare.so

Public API

Initialize the library:

status_t initiate(const char *logpath, size_t logcount);

Shutdown:

status_t deinitiate(void);

Send a file:

status_t push_file(
    InitConfig *config,
    const char *path
);

Receive a file:

status_t pull_file(
    InitConfig *config,
    char *remote_name
);

Broadcast presence:

status_t broadcast(
    InitConfig *config
);

Discover peers:

status_t scanpair(
    InitConfig *config,
    PairInfo **info,
    size_t *len
);

Example

#include "rufshare.h"

int main(void)
{
    if (initiate("./logs", 1024) != SUCCESS)
        return 1;

    InitConfig cfg = {
        /* configuration */
    };

    push_file(&cfg, "example.bin");

    deinitiate();

    return 0;
}

Reliability

RUFShare achieves reliability through:

  • Sequence numbers
  • ACK/NACK packets
  • CRC16 validation for control packets
  • CRC32 validation for data packets
  • Chunk-based transmission

Unlike TCP, the protocol is application-defined and optimized specifically for file transfer workloads.


Use Cases

  • Local network file sharing
  • Embedded device communication
  • Custom networking applications
  • Educational networking projects
  • UDP protocol experimentation

Requirements

  • POSIX-compatible operating system
  • C99 compiler
  • pthread
  • mmap support

Tested with:

  • PCC
  • GCC

License

This project is licensed under the terms provided in the LICENSE file.

About

Powerful programming interface for Reliable UDP File Sharing protocol(RUFShare)

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages