Networking I

Getting it running

You need to get the PWM and accelerometer working.

NAT

The workstations are not behind a NAT router. How can you Pi do its work with a private IP addresss.

The view from home

en0: flags=8863 mtu 1500
        ether 8c:85:90:93:61:f1 
        inet6 fe80::108a:e457:25c5:9fda%en0 prefixlen 64 secured scopeid 0xc 
        inet 192.168.86.169 netmask 0xffffff00 broadcast 192.168.86.255

The view from UNCA

brock@arden:~$ nslookup 68.189.175.xx
Server:127.0.1.1
Address:127.0.1.1#53

Non-authoritative answer:
76.175.189.xx.in-addr.arpaname = xx-189-175-76.dhcp.gnvl.sc.charter.com.

Authoritative answers can be found from:
189.68.in-addr.arpanameserver = ns4.charter.com.
189.68.in-addr.arpanameserver = ns3.charter.com.
................
brock@arden:~$ ssh brock@68.189.175.xx
^C
brock@arden:~$ ping 68.189.175.xx
PING 68.189.175.xx (68.189.175.xx) 56(84) bytes of data.

See How to Set up an SSH Server on a Home Computer for a good description of how you could do this for your home network, but don’t expect ITS to set it just for you.

What is my net, mask, and gateway

netstat -nr

A realistic solution

Your Pi must be the client and relay information through some unNATed server. Start by playing with netcat to send messages to your neighbor. Or try this command to read copy this page.

printf "GET /brock/classes/Spring2018/csci373/notes/Class25.html HTTP/1.0\r\n\r\n" \ 
            | nc www.cs.unca.edu 80

A traditional client solution

Take a look at the Socket Programming HOWTO. Try do read this web page (using the URL) using the Python interface. You will use the same send and recv calls that the C programmers ever since Berkeley sockets interface was created.

You can also try out the Java interface. Look for the getInputStream() and getOutputStream() methods.

An object-based server solution

Writing servers using the Berkeley API is hard. Try using Python’s SocketServer or Java’s ServerSocket to avoid the pain of handling multiple simultaneous connections.