IPv6 addresses problem

IPv6 is proposed as an almost unlimited source of addresses to overcome the IPv4 address shortage some people have suggested. As IPv6 addresses are 128-bit long, 2^128 (aprox 3.4 x 10^38 ) addresses are possible. This should be large enough.

To put things into perspective consider the following problem: How many IPv6 addresses could you put into each squared centimeter of the planet? (Assume the Earth is a regular sphere of 40.000 Km of perimeter).

And a second part ... compare the above number of IPv6 addresses per square centimeter to the total address space of IPv4.

Fragmentation exercise


A 4000 byte-long datagram has to be transmitted over a network whose MTU is 512 bytes. Determine the number of fragments and, for each one of them, write down the fragment offset field contents and the number of data bytes of each fragment.

Solution was presented as a spreadsheet in the class. Here you have a copy. You can export it to your favorite spreadsheet software too (to see the formulas).

Third assignment announcement


Third and forth assignments will be based on a peer-to-peer protocol invented for the occasion. The so-called "P+2" protocol has been created to be one of the simplest P2P protocols (but not any simpler). You need to read and to understand the protocol specification. Protocol was already presented in the class but if there is general call I will repeat the explanation.

This assignment covers three different servers needed to create a full implementation. Assignment's servers can be tested to work using either telnet, netcat (nc) or sock commands. Java language is mandatory for Spanish students but the rest may use the language of your choice. A working implementation of a peer is available too (just a binary version).

You can download assignment text from here. Or you can just go to the file repository (linked on the top right corner, under the new stuff title).

There is a sample peer running too. You may not need it yet for this assignment. Anyway, it is available at 158.42.53.17:7777

You are welcome to ask me for help. Please remember you have to write code by yourself. As assignments are marked individually, it is not something you can develop jointly with a classmate. If two or more assignments are copied from each other all the involved parties will fail the assignment. Due date is March 13th.

p_2

Second term starts

Chapter 4 slides are already available. For those of you joining us for the second term please note you should read the syllabus that contains important details about how the subject works.

Next week we'll start with the lab again. Lab#6 is out too.
 

Marks are out

Not all of you have sent me your own grading of your exam. The reason I was asking you to do that is not because I can save some work this way but because I want you to have a look at your own answers. Most of your marks are quite close to what I've got, at least from the set of students who sent them to me.

You can check your mark on-line. There a few more students who have never attended lectures that will appear at the end of the list of names. This marks are not final as you still have a choice to check your exam. If you want to do that, please tell me so next week in the classroom (or send me an e-mail).

You can see we have a tie on the top performers. I want to congratulate both: Rasmus and Juliusz. Keep up the good work!

Solved 1st term exam Feb 2009

Feb2009 Solved

You know what you have answered. Now you know the right answers. So please check them out, use a binary logic (an answer is either right or wrong, and it scores or not) and calculate your mark and email it to me.

My mark after the exam ...

  1. Exam will be marked from 0 to 10 (being 10 the best mark possible).
  2. Attendance is already marked as a value from 0 to 1 (expressed as a %).
  3. Assignments have been marked too (0 to 2).
First term mark (again from 0 to 10) we'll be calculated as:

1st-term = attendance + (9-assignments)*exam/10 + assignments

Same process will hold for the second term. Course mark will be obtained by averaging both terms. There is not a minimum average you need to obtain on each term, but course average needs to be equal or higher than 5 points to pass the course.

To know more about threads synchronization


Assignment#2 presented you an scenario where multiple threads handle one client each. However, given that each thread has to send a text line to each any other thread's client, a synchronization problem may happen.

If all you use to test server's code is a few telnet clients running on your computer, it is difficult you see any problem (as only one client is typing at a time). If you're interested on researching this topic further, you may use IMTester.java code. This program will throw one hundred simultaneous clients to your server, each one sending on hundred text lines and then the mandatory quit command.

You may well see errors like this "Exception in thread "Thread-85" java.util.ConcurrentModificationException" on the server program. It basically means that an object was modified while others were reading from it (not a good thing). While I was not interested on raising this topic of synchronization, some of you pointed it out, so I cannot avoid explaining a bit more.

The main problem happens because the list of clients may change while one (or more) thread is iterating through it. If the client list changes while messages are being sent to other clients it is possible that either a client is missing the message or that a message is attempted to be delivered to client who is gone.

The solution is pretty simple but not obvious, and most of you failed to provide a proper one (not that it was a requirement though). I'm including an slightly modified version of my sample implementation for you that addresses the synchronization problem. The basic idea is that looping through client list and removing a client from the list are performed exclusively.

Update: A Vector object should have been used instead of ArrayList (as Vector is Thread safe and ArrayList is not).

Assignment #2 is marked


You should have got an email answer about your work. At any rate, marks are on the usual place (assignments tab). Those with a 0 mark still can try to fix it by Thursday 15th.

If any of you is missing a mark, please let me know.



You can have a look at my implementation.

December 18th


Today's class was used to explain the basics of a P2P protocol that will be used for assignments #3 and #4. Same explanation is here.

Please note the text of the assignments will not be provided until the beginning of the second term lectures after the exams break.

Not sure how useful it will be ...


It's been suggested that having all the information in one place might be interesting. So I am putting everything together on a Google site (as an excuse to learn a bit about that feature).

First term last lab


You're required to write a concurrent web server. Here you have the source code of the lab (which appears written on the lab document). You're not supposed to waste your time re-typing it.

Second assignment is out


Now that assignment#1 is due I'm publishing assignment#2 text.

This second assignment is about writing a multithreaded server application for an instant messaging server. Not that you're going to program the next Messenger server (at least not yet) but I hope it'll be fun.

Please remember this assignment is due on January 12th, 2009.

Third lab

Some programming will be required for the third lab.

TCP sockets programming

Here you can find a copy of the source code java files I wrote during last class.

This is the client.

import java.net.Socket;
import java.io.*;
import java.util.Scanner;

class TestTCP {
public static void main(String args[]) throws java.net.UnknownHostException, java.io.IOException , java.lang.InterruptedException{
Socket s = new Socket ( "www.upv.es", 80 );
// Thread.sleep(100000);
PrintWriter output = new PrintWriter( s.getOutputStream(), true);
output.println("GET / HTTP/1.0");
output.println("");
Scanner input = new Scanner( s.getInputStream());
while(true) System.out.println(input.nextLine());
}
}


And this is the server code:

import java.net.*;
import java.io.*;
import java.util.Scanner;

class Server {

public static void main(String args[]) throws IOException, InterruptedException{
ServerSocket ss = new ServerSocket(8080);
while(true) {
Socket s = ss.accept();
Scanner input = new Scanner( s.getInputStream());
PrintWriter output = new PrintWriter( s.getOutputStream(), true);
System.out.println(input.nextLine()); // reads a line from the socket (client)
output.println("Hello client!");
s.close();
}
}
}



Please note that I detailed during the class some DOs and DON'Ts that not necessarily show in my (quick and dirty) code.

First assignment is out


You have till December 1st to turn in this first assignment. You may need to have a look to SMTP protocol specification (RFC 821). Please note that this RFC has been obsoleted by newer versions. However, for the purpose of this assignment, the original version of SMTP specs are ok.

Second chapter

Here you have second chapter slides and second lab too.

I know some of you still need to get a valid user account and I'm sorry. While this is not fixed, please ask the lab teacher to pair you with another student with a valid user account so you can do the lab.