Objectives
Learn to create robust network protocols
Learn about reliable communication
How a premitive proxy might work. You can use this to get around sensorship or firewalls.
Overview
$ anonserver -p <PORT> -s <LOG FILE LOCATION> -p <web page to download>
1.PORT
- The port server listens on.
2.Log file location
- Where you will keep a record of actions.
3.p
- Which webpage to download and serve.
For example:
$ anonserver -p 30000 -l /tmp/logfile -p www.nytimes.com
Functional requirements
The server must open a UDP socket on the specified port number
The server should gracefully process incorrect port number and exit with a non-zero error code
The server should send a FIN after done sending the packet
The server should download the file specified by -p and save it from the memory
Client Specifications
$ anonclient -s <SERVER-IP> -p <PORT> -l LOGFILE
The client takes three arguments:
1.Server IP
- The IP address of the server.
2.PORT
- The port the server listens on.
2.Log file location
- Where you will keep a record of packets you received.
For example:
$ anonclient -s 192.168.2.1 -p 6543 -l LOGFILE
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Sequence Number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Acknowledgment Number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Not Used |A|S|F|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Where:
Sequence Number (32 bits): The sequence number of the first data octet in this packet (except when SYN is present). If SYN is present the sequence number is the initial sequence number (12345).
Acknowledgement Number (32 bits): If the ACK control bit is set this field contains the value of the next sequence number the sender of the segment is expecting to receive. Once a connection is established this is always sent.
The acknowledgement number is given in the unit of bytes.
Not Used (29 bits): Must be zero.
A (ACK, 1 bit): Indicates that there the value of Acknowledgment Number field is valid
S (SYN, 1 bit): Synchronize sequence numbers
F (FIN, 1 bit): Finish, No more data from sender
Here is what a sample interaction looks like:
Server Client
| |
| seq=12345, ack=0, SYN |
| <---------------------------------- |
| seq=100, ack=12346, SYN, ACK |
| ----------------------------------> |
| seq=12346, ack=101, ACK |
| <---------------------------------- |####handshake complete, start getting data
|seq=102,ack=12347,ACK,512Byte payload |
| ----------------------------------> |
| seq=12347, ack=614, ACK |
| <---------------------------------- |
|seq=614,ack=12348,ACK,512Byte payload |
| ----------------------------------> |
| seq=12348, ack=1126, ACK |
| <---------------------------------- |
|seq=1126, ack=12349,ACK,512Byte paylod|
| ----------------------------------> |
Client requirements:
Server Requirements
Additional requirements:
"RECV" <Sequence Number> <Acknowledgement Number> ["ACK"] ["SYN"] ["FIN"]
"SEND" <Sequence Number> <Acknowledgement Number> ["ACK"] ["SYN"] ["FIN"]
"RETRAN" <Sequence Number> <Acknowledgement Number> ["ACK"] ["SYN"] ["FIN"]