NPRG042 Programming in Parallel Environment [2021/22]

Assignment 1


Asynchronous DNS resolver
C# .NET Core Tasks
Assigned: 28.2.2022
Deadline: 12.3.2022 23:59 (CET)
Supervisor: Martin Kruliš
ReCodEx: assignment
Results: w201 (32 threads), w202 (64 threads)
speedup points
1× or less 0
1× to 2× 1
2× to 4× 2
4× or more 3
(possible bonus) +1 point

The objective is to write recursive DNS resolver in C# .NET Core using already implemented methods for individual DNS queries. Of course, all network operations will be simulated by mocks. And since the DNS resolving is rather complex, we have simplified it significantly for the purposes of this assignment:

Your implementation will get an object implementing IDNSClient interface. The interface will provide the following methods:

Your job is to implement class with IRecursiveResolver interface, which has only one method -- Task<IP4Addr> ResolveRecursive(string domain). This method gets full domain name and yields its address. File Serial.cs holds trivial implementation of the resolver. Your codes goes into Solution.cs file, which is also the only file you should submit.

All the interfaces yield Tasks, which might suggest a course of action. Besides low-level tasks, you may also employ async/await approach. The main objective is to use parallelism to lower (average) query latency and increase throughput.

We would suggest implementing the following optimizations: First, when two similar queries are executed simultaneously (e.g., mff.cuni.cz and ff.cuni.cz) the common part may be resolved only once. It can save time by saving resources and it may reduce latency of the query which was started later. Second, you may use whatever caching you deem necessary, but beware that the addresses may change in time. Therefore, you need to verify data from cache (e.g., by reverse translation) before yielding the result.

On the other hand, it is expected that you will not employ any hacking techniques or aggressive methods that might work in real world. E.g., you are forbidden from trying guessing IP addresses of server or scanning the entire IP range.

Your solution will be tested on .NET Core 6.0 (which is both in ReCodEx and on Parlab). The initial solution is in /home/_teaching/para/01-dns-netcore or you may simply download it here. You may compile it using dotnet command:

$> dotnet build -c Release ./dns-netcore.sln

The compiled binary will appear in ./bin subdir.

Please note that ReCodEx is only a first-instance verification. You solution will be subjected to performance evaluation on Parlab after the deadline (all solutions are collected and tested together).