"These men know why they are on this New Jersey hilltop." Intrigued?

Netbounce Project

by: burt rosenberg
at: february 2026

Overview

This project is to have you write a program using UDP packets.

The code to work with sockets has a lot of details. They are found in Beej's Guide to Network programming and presented on my Netbounce page.

Much of the details can be hidden by a software layer, as long as the layer's API is well designed for the requirements. This project is about using a layer, called Foo Sockets, for UDP programming. Hopefully it communicates the essentials of programming with packet-style communication.

As a fun thing, we will learn more about the common technologies about the web. In the project we install a Netbounce Responder in an EC2 instance and direct its output to a webpage. We need to configure our webserver to use Server Side Includes (SSI), a form of server-side scripting. It will also be useful for our next program as we try to monitor the progress of UDP packets we try to bounce from machine to machine.

Netbounce Responder

To create the Netbounce Responder carry out the tasks found on the Netbounce Responder page.

The responder uses the code from the Netbounce page. However the server has a version that uses foo-sockets. As you attempt to write a version of the client that uses foo-sockets, refer to this code for inspiration and help.

Man Pages

NAME
    netbounce-server2, netbounce-client2
    
SYNOPSIS

    netbounce-client2 [-v] -p port -h host message

    netbounce-server2 [-vl] -p port

DESCRIPTION

    netbounce-server2 binds to the given UDP port, listens for a packet
    and echos it back to the source port and source IP.
    
    netbounce-client2 sends the given message in a UDP packet to the given
    port and host, then listens for a packet on the port that its
    socket was bound to. It prints out the contents of the returned
    packet to stdout.
    
    The verbose option (-v) prints to stdout. Multiple -v increase
    the verbose level.
    
    The loop option (-l) will have the server listen repeated on the port.
    Else it exits after one bounce.

BUGS


LAST UPDATE

    01 February 2026
    20 January 2012
    12 January 2016
NAME
    create_foo_socket, socket_sendto, socket_recvfrom, 
    socket_replyto, create_session_socket
    
 
SYNOPSIS

    #include "foo-socket.h"

    struct FooSocket * 
    create_foo_socket(int port) ;
    
    int 
    socket_sendto(struct FooSocket * foo_sock, char * host, int port, char * message, int msg_len) ;

    int 
    socket_recvfrom( struct FooSocket * foo_sock, char * buf, int buf_len) ;

    int
    socket_replyto(struct FooSocket * foo_sock, char * message, int buf_len) ;

    struct FooSocket * 
    create_session_socket(struct FooSocket * sock_listen) ;

DESCRIPTION
    The create_foo_socket returns a struct FooSocket * representing a newly
    opened socket. If a non-zero port is given, the socket is bound to that port.
    Else the socket is bound to an ephemeral port.
    
    The socket_sendto sends the message on the foo_socket to host:port.
    
    The socket_recvfrom receives into buf from the foo_socket up to buf_len bytes,
    returning the number of bytes received. The foo_socket binds to the packet 
    source for the purpose of socket_replyto.
    
    The socket_replyto sends the message in reply to the sender of the previous 
    socket_recv_from. 
    
    The create_session_socket returns a new foo_socket, a clone of the foo_sock
    bound to a sender after a socket_recvfrom.

BUGS


LAST UPDATE
    01 February 2026

Foo Sockets

There are general rules in the use of the foo socket calls.

  1. The first parameter is a pointer to a foo socket, as returned by the create.
  2. Message buffers are given by a character pointer and a length.
  3. Length of received message or character sent is the return value of the call.
  4. Character buffers are not strings — do not depend on the last character being a null.

The Foo Socket API

Assignment

Finish the code in netbounce-client2.c. Test against your Netbounce Responder running netbounce-server2.c. For full credit, follow the suggestions in netbounce-server2.c and use foo sockets similarly.
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

author: burton rosenberg
created: 8 feb 2024
update: 3 feb 2026