Netbounce Object Edition

by: burt rosenberg
at: january 2023

Netbounce 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. 

Netbounce-oe

The netbounce code has been encapsulated as a FooSocket object, and the code simplified.

Your assignment:

Please read the code and fill out the file project-response.txt, which requires you to run the code on two machines, capture packest using the tcpdump target in the project makefile, and then dissect one of the captured packets, demonstrating you understand IP and UPD headers.

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.

A socket library

For the following projects a socket library is provided. This is a first example of the library that has this functionality,

  1. It is called to create a socket object. The object is bound to a port number.
  2. The object is called to send a message to a particular destination.
  3. The object is called to listen for incoming packets. The source of the packet is remembered.
  4. The object is called to reply to the a packets received.
While we do not use this concept heavily, a socket is connected when it is dedicated to a peer in the communication. In a sense, our foo sockets which have listened at received a packet are connected to the source of that packet, as reply will send to that peer.

FooSocket man page
NAME
    create_foo_socket, socket_sendto, socket_recvfrom, socket_replyto, 

SYNOPSIS
    #include <foo-socket.h>
    
    struct FooSocket * create_foo_socket(int port)  ;
    int socket_sendto(struct FooSocket * sock, char * host, int port, char * message, int msg_len) ;
    int socket_recvfrom( struct FooSocket * sock, char * message, int buf_len) ;
    int socket_replyto(struct FooSocket * sock, char * message, int msg_len) ;

DESCRIPION
    Calling create_foo_socket returns a FooSocket object bound to port _port_. 
    If _port_==0, the port is chosen by the system (is ephemeral).
    
    socket_sendto sends the message to the _host_:_port_ given.
     
    socket_recvfrom listens on the bound port and returns the message in message. The
    return value is the number of bytes received. Objects internal recvfrom is set to 
    the source of the received message.
    
    socket_replyto sends the message to the destination bound as the reply-to of the 
    previous recvfrom.
    
RETURN VALUES
    As stated in the description.

BUGS
    It's all about the Foo.
    
HISTORY
    Updated library in 232.

    

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: 31 jan 2023