TELEMATICA II ESAME SCRITTO 27 Ottobre 2010 NOTE SULLO

annuncio pubblicitario
Corso di Laurea
Ingegneria Informatica
TELEMATICA II
ESAME SCRITTO
27 Ottobre 2010
NOTE SULLO SVOLGIMENTO DELLA PROVA SCRITTA:
1. SCRIVERE IL PROPRIO NOME, COGNOME E NUMERO DI MATRICOLA IN ALTO SU OGNI FOGLIO
UTILIZZATO
2. NON E’ POSSIBILE CONSULTARE NESSUN TIPO DI DOCUMENTAZIONE
3. NON E’ POSSIBILE UTILIZZARE DISPOSITIVI ELETTRONICI. SPEGNERE I CELLULARI
4. PRIMA DI SCRIVERE LA SOLUZIONE DELL’ESERCIZIO, INSERIRE IL NUMERO DI ESERCIZIO CHE
SI STA RISOLVENDO
5. NON COPIARE DAL VICINO E NON PERMETTETE AL VICINO DI COPIARE (IN TAL CASO I DUE
COMPITI VERRANNO ANNULLATI)
6. ALLA FINE DELLA PROVA, RICONSEGNARE TUTTI I FOGLI UTILIZZATI. LA CONSEGNA DEVE
ESSERE EFFETTUATA ENTRO E NON OLTRE L’ORARIO INDICATO SULLA LAVAGNA
PARTE 1 : TEORIA DEI PROTOCOLLI / JAVA
ESERCIZIO 1 (2 punti)
Illustrare che cosa si intende per “query inversa” e le modalità di implementazione,
aiutandosi con un esempio di PTR QUERY.
ESERCIZIO 2 (2 punti)
Descrivere l’ereditarietà e il polimorfismo in JAVA illustrando un esempio. Infine
descrivere l’ereditarietà multipla in JAVA.
ESERCIZIO 3 (2 punti)
Descrivere le modalità di esecuzione di una sessione SMTP tramite “telnet”, aiutandosi
tramite un esempio.
1
Corso di Laurea
Ingegneria Informatica
TELEMATICA II
ESAME SCRITTO
27 Ottobre 2010
PARTE 2 : APPLICAZIONI TELEMATICHE
ESERCIZIO 4 (8 punti)
1) Si realizzi il metodo "String decBencoding(String code)" che realizza la decodifica di
una stringa codificata tramite Bencoding (solo tipo dizionario) e restituisce la stringa
decodificata.
In particolare si supponga che la stringa passata al metodo contenga un dizionario con
una serie di coppie chiave-valore, le quali possono contenere stringhe o numeri in base
alla codifica. Il metodo deve far in modo che venga restituita la stringa decodificata
ipotizzando di separare le varie coppie con dei CRLF e la chiave dal valore con dei “:”.
Esempio:
stringa in ingresso al metodo stringa restituita dal metodo
d8:filename11:miofile.txt4:sizei76500e
filename:miofile.txt
size:76500
2) Si completi il codice del punto 1) aggiungendo la gestione di liste all’interno del
dizionario.
3) Si faccia un esempio di mappa in JAVA e si spieghi come viene gestita dalle JAVA
Framework Collections
2
Corso di Laurea
Ingegneria Informatica
ESERCIZIO 5 (13 punti)
Supponiamo di avere un’architettura di tipo client/server come in figura.
POP3
H3
CLIENT
H2
CRYPTOSERVER
UDP
H1
ORIGIN
CLIENT
Sull’host H1 con indirizzo IP (192.63.21.123) è residente l’applicativo ORIGIN-CLIENT.
Sull’host H2 con indirizzo IP (193.85.124.20) è residente l’applicativo CRYPTO-SERVER.
Sull’host H3 con indirizzo IP (200.14.94.15) è residente l’applicativo CLIENT per la
ricezione dei messaggi mediante protocollo POP3.
L’obiettivo è di ricevere un messaggio di testo da parte del client H3 tramite protocollo
POP3 e inviato da H2 CRYPTO-SERVER. Il messaggio inviato da H2 verso H3 è stato a
sua volta ricevuto dal client H1 con protocollo UDP e opportunamente codificato.
Dopo aver fatto eventuali ipotesi aggiuntive ed esemplificative, implementare in
linguaggio JAVA i seguenti applicativi client o server richiesti:
1) Implementazione del client UDP su H1 per l’invio del messaggio ad H2.
2) Implementazione del client POP3 su H3.
3) Si implementi l’applicazione mini-server POP3 lato H2 (anche se non completamente
conforme alla RFC, ma in linea con le indicazioni ricevute durante il corso) con la sola
gestione dei comandi USER, PASS, LIST, RETR n, QUIT verso il client H3. Il comando
“RETR n” deve prevedere la ricezione del messaggio n-esimo il cui contenuto è presente
dopo l’header Content-Transfer-Encoding.
Sullo stesso host H2 è necessario implementare la ricezione del messaggio da H1 con la
successiva codifica del messaggio stesso. La codifica su H2 sarà basata sull’inversione
dell’ordine dei caratteri del messaggio di testo. Ad esempio se abbiamo una riga :
“oggi è una bella giornata”, essa sarà codificata in “atanroig alleb anu è iggo”.
3
Corso di Laurea
Ingegneria Informatica
TELEMATICA II
ESAME SCRITTO
27 Ottobre 2010
Javadoc
java.lang.Integer
public static int parseInt(String s) throws NumberFormatException
Parses the string argument as a signed decimal integer.
Parameters: s - a String containing the int representation to be parsed
Returns: the integer value represented by the argument in decimal.
Throws: NumberFormatException - if the string does not contain a parsable
integer.
java.lang.String
public boolean endsWith(String suffix)
Tests if this string ends with the specified suffix.
public boolean equals(Object o)
Compares this string to the specified object.
public int length()
Returns the length of this string.
public boolean startsWith(String prefix)
Tests if this string starts with the specified prefix.
public String substring(int beginIndex)
Returns a new string that is a substring of this string.
public String substring(int beginIndex, int endIndex)
Returns a new string that is a substring of this string.
public String(byte[ ] bytes,int offset,int length)
Constructs a new String by decoding the specified subarray of bytes using the
platform's default charset.
public int indexOf(String str,int fromIndex)
Returns the index within this string of the first occurrence of the specified
substring, starting at the specified index.
public byte[ ] getBytes()
Encodes this String into a sequence of bytes using the platform's default
charset, storing the result into a new byte array.
java.lang.StringBuffer
public StringBuffer append(String str)
Appends the string to this string buffer.
Parameters: str - a string.
Returns: a reference to this StringBuffer
public String toString()
Returns a string representing the data in this sequence
java.util.Map<K,V>
public V get(K key)
Returns the value to which this map maps the specified key. Returns null if the
map contains no mapping for this key.
Parameters: key - key whose associated value is to be returned.
Returns: the value to which this map maps the specified key, or null if the map
contains no mapping for this key.
4
Scarica