CITS3002 Computer Networks | |
|
Practical project 2024 - Getting Started(due 11:59pm Fri 17th May - end of week 11)See also: the Project and Clarifications (12/5) There are two significant, and different, networking aspects to be addressed in this project. Once those aspects are designed, implemented, and tested, attention can move to designing, implementing, and testing the business logic of the project.
Communication between web-browser and a station serverLet's see what a web-browser (acting as a client) sends to a server, sending its traffic using HTTP. Firstly, we'll need to know, or choose, a port-number for the communication. A port number is a small integer (on a server/computer) identifying a 'communication endpoint' able to receive some network communication from another computer. Both the sending and receiving processes may be on the same computer, and the operating system kernel (internally) uses the port-number to determine if there's a running process able/wanting to receive the communication and, if so, the kernel delivers the communication to that process.
OK, let's find an available port-number - meaning, one not currently in use
by another process.
shell> chmod +x portsinuse.sh
Choose a port-number not listed there (and above 1023), say 4444, and run the command: shell> nc -l 4444 You've just started a new server process, listening on port 4444, and expecting a connection and network traffic using TCP/IP (the default). Ahh, this project looks easy! Now let's use your web-browser, acting as a TCP/IP-based client, to connect to that nc server. Because (assuming) your web-browser and the nc process are running on the same computer, each will be able to communicate using the 'generic' hostname of localhost (or, depending on your computer's configuration, you may need to use the IP address 127.0.0.1). Open a new tab in your browser, and in the address bar enter the URL http://localhost:4444/ In the shell window of your nc process you should immediately see what the browser has sent to nc, commencing with:
GET / HTTP/1.1 The 8 or so lines you see is a basic HTTP header (version 1.1), followed by a blank line. Your web-browser is still waiting for a reply from nc, so we need to also reply using HTTP. Type (cut-and-paste) in your shell window:
HTTP/1.1 200 OK and then control-C or control-D to terminate the TCP/IP connection between nc and web-browser. You've replied with an HTTP header (version 1.1), indicating that the 'request' was valid and understood (reply code 200), indicated that the type of your reply will be HTML (case is insigificant), and eventually sent 5 lines of HTML. You should see the reply rendered in your browser's tab. Now, repeat the whole exercise, re-running nc and this time requesting the URL http://localhost:4444/?to=Perth_Stn into your browser. You should see this new request arrive with:
GET /?to=Perth_Stn HTTP/1.1 Hmmm now, if only nc was actually our own station server program, written in C or Python, we might know what to do with the request, and what to write back as our reply!
While this part of the project involves sending an HTTP request over a TCP/IP connection, and sending an HTTP reply carrying an HTML message back across the same TCP/IP connection, we've almost finished it without having written a line of code. Of course, we need to replicate some of the work that nc performed in establishing the server's connection on our chosen port-number (4444), and that's where our first bit of coding becomes programming-language specific. Communication between station serversStation servers communicate with each other using UDP/IP datagrams. Servers do not establish or maintain connections between each other, and send datagrams on-demand. Stations know the ports on which their neighbouring stations are expecting datagrams, but not the ports of other stations. Datagrams will be used to transmit both queries and replies between neighbouring stations. The contents of each UDP datagram (in its payload) will need to be formatted so that they can be unambiguously understood by its receiver. Their format does not need to match that of the HTTP or HTML protocols (that would be overkill for our requirements). However, you will be defining a protocol understood by your stations. Helpful language-specific tutorials on TCP and UDP
Defining and executing your own transport network
Consider the following excellent diagram of a simple 4-station network:
The above network requires 4 distinct operating system processes to execute, each written in your choice of two programming languages. We can invoke all of these processes from the command-line, or from a shellscript, as below. Each process receives a small number of command-line arguments, providing its station's name, its unique port for TCP/IP-based communication with a web-browser, its unique port for UDP/IP-based communication with other stations using datagrams, the UDP/IP-based port(s) of directly connected (neighbour) stations. Notice, also, that all processes have been 'started in the background', because none needs to remain connected to the invoking keyboard.
shell>
./station North_Terminus 2210 2608 localhost:2606 &
When invoked, each station process first initialises its TCP and UDP ports, and then reads a comma-separated textfile providing its own timetable information. While your servers will need to read in and parse the contents of the timetable files, you can assume that all their contents are correct (time-formats are correct, departure times precede arrival times, destination station names exist, etc). For example, the file tt-North_Terminus may contain lines of the form:
North_Terminus,-31.8448,115.7963 The first line contains the station's name (also forming the filename), and latitude and longitude (which you can ignore, though some students wanted to drap a map on their webpages! :-) The second and subsequent lines each define a single bus connection leaving the station. The second line can be read as: "At 7.15am, bus number 12 leaves Stop1, arriving at 7.54am at East_Station". Note that there is no networking information (protocols or ports) in the file, and that North_Terminus does not know anything about West_Station or South_Busport. The file tt-East_Station will have exactly the same format, but likely have more timetable entries because it has more direct connections.
East_Station,-31.9442,115.8771 Simplifying the building and execution of your transport networksThe following program and shellscripts may help you to automate the task of constructing (fake) timetables, and the shell commands to invoke your station servers. The use of these scripts is not required - they are just suggestions. In combination, these files generate a shellscript which, when invoked, will start all station-servers on the same host - localhost. You can use this approach to develop your project on your own host but, eventually, you'll need to modify things to name and invoke commands on remote hosts.
Using the Transperth GTFS datasetPerth's Public Transport Authority (PTA) provides public access to its scheduled times, stop locations, and route information from its webpage www.transperth.wa.gov.au/About/Spatial-Data-Access. You may download your own copy of the data (about 90MB) by clicking on the first link "By downloading the data you are agreeing to the terms of the License..."The data is released as a collection of inter-related textfiles following the Google Transit Feed Specification (GTFS), which is also used by many other public transport companies, worldwide. Finally. The shellscript buildtransperthtimetables.sh (it will probably download when you click on the link), reads the Transperth files and reduces the information to a set of more manageable timetable files, suitable for this project. Read the following points carefully:
|