Netbounce Object Edition

by: burt rosenberg
at: january 2022

man page
NAME
    netbounce-oe
    
SYNOPSIS

    netbounce-oe [-v] -p port -h host message
    netbounce-oe [-vl] -s -p port
    
DESCRIPTION

    Run with the -s option, netbounce-oe is the netbounce
    server. Else it is the netbounce client.

    The server listens for a packet on the given UDP port
    and echos the packet to source port and IP address.
    
    The client sends the message in a UDP packet to the given
    port and host, then listens for a packet on the bound port.
    It prints out the contents of the returned packet to stdout.

    The client will send and expects to receive null terminated
    strings.

OPTIONS
    -h  The host, if running as the client.
    -l  The server will loop. Else it exists after one packet.
    -p  The port number (required)
    -s  The server is invoked.
    -v  verbose
    
BUGS
    port is not an optional option.

HISTORY
    Introduced in csc424 term 222. 

man page
NAME
    server_listen, server_reply, client_send, client_receive
   
SYNOPSIS
    #include <netsocketlib.h>
    
    struct ClientSocket * create_client_socket(char * host, int port)  ;
    struct ServerSocket * create_server_socket(int port)  ;
    
    int server_listen(struct ServerSocket * sock, char * buf, int buf_size)  ;
    int server_reply( struct ServerSocket * sock, char * buf, int buf_len) ;
    int client_send(struct ClientSocket * sock, char * buf, int msg_len) ;
    int client_receive(struct ClientSocket * sock, char * buf, int buf_len) ;


DESCRIPION
    Calling create_client_socket with host and port returns a socket object that
    will send UDP packets to that host:port. And will receive replies on the port
    bound to that socket.
    
    Calling created_server_socket with a port will create a socket object that can
    receive UDP packets on that port, and can respond back to the source of packets
    received on that port.

RETURN VALUE

    The functions return that integer results of the socket calls recvfrom or sendto.

BUGS
    
HISTORY
    Introduced in csc424.222.

Overview

You are to start with the netbounce code, and adapt that code in netsocketlib.c to encapsulate the functionality into two objects, the ServerSocket and the ClientSocket.

The objects are struct's, whose datatype is provided. They store all the information about the socket as well as certain dynamic data, for instance, the address from which was received the last UDP packet. This is needed in the case of a server for it to respond.

The objects are adapted to client-server computing. The server socket is assigned to listen on a socket with the server_listen function, and to reply with the server_reply function.

THe client will make a request to the configured host and port with client_send, and will gather the server's response with client_receive.

Netbounce-oe

The netbounce program originally had all the code in its file. Now it calls the netsocketlib library. It is also now only a single binary, the uses the command line flags to determine its role as either client or server.

AWS Security Groups

In order to establish a communication flow between hosts in the Internet, the flow must be permitted. Various devices restrict such flows, in order to provide efficiency and security. The AWS solution of the Security Group is an example of a method of restricting traffic.

You need to identify which securit group is applied to your EC instance. By default, a security group will be created when the EC instance is created. The security group is associated with your EC instance until you change it. Security groups can be used by more than once EC instance. More than one security group can be applied to an EC instance.

A security group is a collection of Inbound Rules. Each rule allows traffic to arrive at the EC instance. For traffic to pass, it must match,

The rule created for an EC instance must allow SSH traffic to come in. Therefore the automatically created Security Group has in inbound rule to allow TCP port 22 from any internet host.

For the netbounce, if the server is an EC instance binding to port 3333, you will add the rule for inbound traffic to allow UDP port 3333 from any internet host.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

author: burton rosenberg
created: 27 jan 2022
update: 27 jan 2022