TELE 3118 - Mini-projectTELE 3118: Network Technologies: Project [10 points]
Logistics notes: - This project can be done in pairs (i.e. groups of twopeople); but if so, you are required to register the pairing using no later than the end of week 8.
This project introduces you to network programming using the socketAPI. The socket API allows applications to communicate across networks, so is useful for general development of network applications, and you will also use it in UNSW courses TELE3119 Trusted Networks, TELE4642 Network Performance and TELE4123 Design Proficiency.The application you will develop is a simple version of a chatprogram that allows two users to chat to each other. Moresophisticated chat programs like Yahoo messenger and MSN chat allowmany more users, multi-party communication, etc, which can be seen asrefinements to this project.
Your application will consist of three parts:
Part 1 [4 points]:Chat registrationclient: This part requires you to write a program that sends a UDPregistration message to the registrationserver.
The isprovided to you, and you can run it on your local machine (on port31180) to test if your client is able to communicate with it. During weeks6-8, the registration server will be running on the machine 149.171.36.211 on UDP port 31180. If you believe the chat registration server is not working on that machine, then please tell the lab demonstrators.
Your registration message to the server must have the following format:
- The password (stored in an array of 12 bytes), currently setto the string "3118project". (All character strings for this project must use ASCII - avoid unicode - and be null terminated.)
- Your user-name (stored in an array of 14 bytes), which is astring of characters of your choice.
- The UDP port number on which your chat program (of part 2 below)sends and receives chat messages. This is sent as a 2-byte number(unsigned short) in network format.
Your registration message should be sent periodically (onceper minute) to the registration server, otherwise the server willconsider you (the user) as having logged off or crashed. In responseto your registration message with the correct password, the server will send you back a messagewith a list of all logged-in users, in the format below:
- The first 4-bytes (unsigned long integer, in network order) will indicatehow many users are logged-in.
- The rest of the mesage will be an array (of at most 50 items) of astructure that includes the following information for each logged-inuser: 14-byte user-name, followed by 2-bytes of UDP port-number (innetwork format) on which that user is listening, followed by the4-byte IP address of that user.
Warning: If the user registered from behind a NAT (e.g. from Uniwide) then the IP address will be the public address of the NAT and not the private IP address seen by the user - e.g. 10.0.0.1.
Sample hex UDP payload for a reply from the chat server:
Bytes (hex) | Meaning |
---|
00 00 00 02 | 2 users |
64 65 6d 6f 33 31 31 38 00 00 00 00 00 00 | 1st username = "demo3118" |
02 9a | 1st user's port = 666 |
95 ab 25 86 | 1st user's IP address = 149.171.37.134 |
6f 6b 00 00 00 00 00 00 00 00 00 00 00 00 | 2nd username = "ok" |
26 94 | 2nd user's port = 9876 |
3a 6f 8a 56 | 2nd user's IP address = 58.111.138.86 |
Part 2 [3 points]:Chat messagingserver/client: Once your code from part 1 registers with theserver and obtains the IP address and port number of other logged-inusers, this part will now require you to exchange chat messages withother users. These chat messages will be limited to 100 characters,and communicated using UDP. You therefore need to implement a UDPserver (operating on the port number that you advertised above in yourregistration message) that receives messages from other users, as wellas a UDP client that sends messages to other users. These can beimplemented as a single thread or as separate threads. All messages exchangedmust begin with the 14-byte name of the user sending the chatmessage. Your client code will need to implement the user interfacethat reads messages typed (on the keyboard) by the user, and sendsthem directly to the intended recipient. Likewise, your server codewill have a user interface that displays to the user messages receivedfrom other users. Points will be awarded based on the extent to which you achieved the required functionality, and how well the codeand interface are structured.
Part 3 [3 points]:File transferserver/client: You will now enhance your chat program to allowtransfer of files between between yourself and user "hassan" using TCP. You will send a chatmessage to "hassan" stating that you want to upload a specificfile. "hassan" will send you a chat message back telling you the portnumber (currently hard-coded to 15000) on which his TCP server is ready for upload. You willimplement a TCP client that connects to the server, uploads the file,and then disconnects. You will use this mechanism to upload yourproject source code to the assessor Hassan. Points will be awarded based onthe extent to which you achieved the required functionality, and how well the code and interface are structured.
The is also providedto you for part 3 of your project. You can run a local copy (specifyingthe port number as a command-line argument) and test that your TCPclient is able to transfer the file successfully. Once your client workswith the local server, then you can test your client with Hassan's serverwith IP address specified under user-name "hassan" and port number 15000.
Evaluation
When:Theworking code is to be demonstrated in the lab (343) during sessions that are during Thur/Fri lab time, in week 10-12 according to the schedule on the main TELE3118 web page. Marking will be done in week13. You must demonstrate your code in the session that is allocated for your lab group, and must be ready to demonstrate your code at the beginning of that session. What:When demonstrating your program(s) you should demonstrate that they achieve the required functionality, and use Wireshark to demonstrate that they achieve that functionality through network communication. The demonstration must occur in the lab, but need not use lab computers - you can provide laptops etc.
Warning:You should test your program(s) in the lab before the demonstration day to ensure that local issues (firewalls, availability of development environments, etc) will not impede your demonstration.
Implementation notes:
- If using a desktop/laptop PC, you are recommended to use C as the programming language (Python or Java may be used but will not be supported by the lab demonstrators). You can (which includes a C/C++ compiler) for free. During compilation of your C programs, you may need to link with socket libraries, e.g. using the "-lnsl" option in gcc.
- Use Wireshark to help debug your programs, e.g. to detect whether your program succeeds in sending messages or it should be receiving messages, and that the messages are complete and properly formatted.
- If packets don't seem to pass through the operating system to your programs, then check firewall logs/settings, and use “netstat -a” to check that servers are bound to the right ports.
- Don't try operating the project across address translators, e.g. between a machine on uniwide and a machine off uniwide, since such translators won't find and translate port numbers used in the messages. The project should work between devices on the same side of an address translator (e.g. 2 devices using uniwide). The project does work without address translation, e.g. within lab 343 and between lab 343 & the registration server.
- Development and demonstration on a mobile platform (e.g. iPhone or Android) will fetch up to 2 bonus marks. For app user interface design, you may get inspiration from apps such as .
- There are numerous tutorials and sample programs on the Internetthat illustrate the use of sockets. A sample primer is available. Useful templates for yourimplementation may be obtained (companion to the book "The Pocket Guide to TCP/IP Sockets - CVersion" by M. Donahoo and K. Calvert).
- Use "man" and "info" to learn more about the socket functionsused.