A3: TCP socket programming

TCP socket programming

The third assignment is dedicated to TCP socket programming with Java and analyzing the traffic generated by your programs with Wireshark. You will start with your Assignment 2 results and change implementation to support TCP and concurrency, then you will record and analyze the traffic in virtual networking environment from your host machine.

Reference material

Problem 1

You can start with your implementation of UDP echo server / client from Assignment 2.

The task is to implement the same echo server / client functionality (including support for several options), but using TCP instead of UDP.

A little clarification on message size / server buffer size: these values refer to sizes of byte arrays used as buffers, not to Socket class methods that manipulate underlying OS mechanisms. For example, you are supposed to use InputStream.read(byte[]) method instead of InputStream.read() that would fetch one byte at a time, and the size of array used as buffer for this task is supposed to be configured.

However, the server must support multiple client connections. To achieve this, you have to modify server code to use Java threads: upon accepting connection from client, new thread with request handling code must be created and executed. After sending response (echo), the thread execution should stop (main server thread, as in previous assignments, is supposed to run in a loop until manual termination).

Copy Java classes / JAR files of server program to your virtual machine and use client from host machine. Test your programs (as described in Assignment 2) and include screenshots in your report!

Problem 2

This part of assignment involves using Wireshark. Install this tool and run it (you will need Administrator / root privileges!). The good idea is to read one of dedicated tutorials (plenty of them are free available on the Internet).

Choose the virtual networking interface on your host machine (check VirtualBox settings to find out its title).

Start capturing the traffic and repeat a testing session for your programs. Include screenshot of Wireshark (or paste text) in your report!

Besides your experiments with small buffer size (Assignment 2), try to set and use buffer size that is higher than the packet size (which you can find out with Wireshark). What happens in this case? Include screenshot (or paste text) and explain this situation in your report!

Submission

The deadline for submitting your assignment is March 14, 2013, 23:59.

This assignment may be done individually or in a group of two students (in this case, only one submission should be made and names / IDs of both partners must be included in submission letter).

Submission must be packed in a single ZIP archive and it must include:

  • all of your source code files in non-default Java packages (e.g., your classes should belong to package “1dv201.my_package_name”); your source code files are expected to have sufficient amount of comments
  • report with answers for problems, specified example outputs / screenshots, short comments on implementation, etc. as a PDF or HTML file

Submission archive must be sent to Kostiantyn ( kk222bt@student.lnu.se ); please include “1DV201 Assignment 3” in your email topic and include your name and student ID (e.g., “kk222bt”) in your email body.

Welcome to CoursePress

en utav Linnéuniversitets lärplattformar. Som inloggad student kan du kommunicera, hålla koll på dina kurser och mycket mer. Du som är gäst kan nå de flesta kurser och dess innehåll utan att logga in.

Läs mer lärplattformar vid Linnéuniversitetet

Student account

To log in you need a student account at Linnaeus University.

Read more about collecting your account

Log in LNU