ELEC-E7321
In this assignment you will implement TCP server the gets incoming connection requests and should send a number of bytes as requested by the client.
The course git repository contains Rust templates for this task that you may use if you want.
Follow these steps in your program:
Open a listening TCP socket that binds to a port of your choice. You should choose a port number between 1024 and 49151
Send a control message to the adnet-agent server that follows this form:
TASK-002 keyword IP:port
. As in previous task, keyword is a random word
you receive in MyCourses assignment (if you are Aalto student). IP is the IP
address your program runs at listening to incoming connections, and port is
the port that you chose to bind for listening. If you
are running your program in node “lh1” of our simple_topo
Mininet
configuration, the IP address is 10.0.0.1.
adnet-agent starts opening connections to your server. It first sends 5 bytes of data. First four bytes is a 32-bit unsigned integer in network (big-endian) byte order. This tells how many bytes the agent excepts to receive from this socket. You should send this many bytes, all containing the value that is indicated by the fifth byte in request from adnet-agent. Note that your implementation should be prepared to handle multiple connections in parallel.
When you have finished sending the requested number of bytes, you should
output the following to terminal: “Wrote N bytes of byte B
”. A new
request may arrive from adnet-agent, with similar 5-byte format, to which
you should respond in the same way as described above. If adnet-agent does
not need more data from this socket, it closes the TCP connection. Your
program should therefore be able to handle closing TCP connection without
problems. Not that while one connection closes, there may be other
connections still open, performing transmission.
When adnet-agent has closed all connections it opened in the beginning, this assignment is complete and successful.
Execute your program and the adnet-agent in Mininet simple_topo
topology. As
in previous assignment, adnet-agent should run in host “rh1”, and your
implementation should run in host “lh1”. It is sufficient that you only try
with the “slow transmitter” scenario from previous assignment: sudo
aalto/simple_topo.py --delay=50ms --bw=0.1
, but you can also try other
scenarios if you are interested.
You should submit to MyCourses the output of your program, consisting multiple
lines of the above mentioned “Wrote N bytes of byte B
” messages.
Calculate also the total number of bytes you sent through all sockets, and
report that in MyCourses.