OpenTTCN/Training/TTCN-3 Basics/Exercises/2.1
From OpenTTCN
Exercise 2.1: Preparations for DNS server testing
In these following exercises we are going to refine a DNS server testing environment at the same pace as we are learning new features during this TTCN-3 Basics course.
Goal: In this exercise we are preparing for DNS server testing.
Step 1: Introduction to DNS
"The Domain Name System or Domain Name Server (DNS) is a system that stores information associated with domain names in a distributed database on networks, such as the Internet. The domain name system (Domain Name Server) associates many types of information with domain names, but most importantly, it provides the IP address associated with the domain name. It also lists mail exchange servers accepting e-mail for each domain. In providing a worldwide keyword-based redirection service, DNS is an essential component of contemporary Internet use.", quotation from Wikipedia. See DNS in Wikipedia.
DNS is specified in RFC 1034 (introduction of concepts) and RFC 1035 (detailed specification).
Step 2: OpenTTCN server is running
In the first exercise you started OpenTTCN server and the server should be already running. If you don't have OpenTTCN server running, you need to start it now.
- Hint: ot start
Step 3: Create a new testing session
It is always handy to create a new testing session for each different testing project. Here create "dnsc" testing session. We specify the name of session here so that we can refer this testing session later with that name.
- Hint: session
Step 4: Create a new TTCN-3 module
It is necessary to have a new TTCN-3 module for each different test suite. Here create "DNSMainModule.ttcn" TTCN-3 file with "DNSMainModule" TTCN-3 module in it. We specify the name of TTCN-3 file and the name of TTCN-3 module here so that we can refer these (TTCN-3 file and TTCN-3 module) later with these names.
- Hint: Use your favorite text editor
Load the created TTCN-3 file into the "dnsc" testing session to make sure your simple TTCN-3 file does not have any syntax errors.
- Hint: importer3
OpenTTCN Tester contains flexible mechanism for transforming TTCN-3 file into state that allows its direct execution. You can use this feature to frequently check that your TTCN-3 module is according to TTCN-3 syntax and semantics allowed by using "importer3 load" command.
Step 5a: Start Loop-back Adapter
In the beginning of the exercises, use the following instructions:
Type start robo -s 127.0.0.1:5500:dnsc TRI TRI (and press return) to start a loop-back adapter that is more useful in the beginning of exercises than a real DNS SUT Adapter. The previous command registers the loop-back adapter to the "dnsc" testing session.
Step 6: Check status of a testing session
Check the status of "dnsc" testing session that you created during Step 3. You should verify that "Adapter" section shows the adapter registered with name "TRI" having status "ALIVE". You can also verify that "Suites and modules" section shows "DNSModule" TTCN-3 module loaded into as of type "TTCN-3". This module came grom the module you loaded into this testing session.
- Hint: session
Step 7: Extract information about DNS messages from RFCs Extract information about the DNS messages and the packet formats they use from RFC 1035. Please check the RFC for couple of minutes and then you will be discussing about the messages with an instructor. Extracts from RFC 1035:
...
4. MESSAGES
4.1. Format
All communications inside of the domain protocol are carried in a single
format called a message. The top level format of message is divided
into 5 sections (some of which are empty in certain cases) shown below:
+---------------------+
| Header |
+---------------------+
| Question | the question for the name server
+---------------------+
| Answer | RRs answering the question
+---------------------+
| Authority | RRs pointing toward an authority
+---------------------+
| Additional | RRs holding additional information
+---------------------+
The header section is always present. The header includes fields that
specify which of the remaining sections are present, and also specify
whether the message is a query or a response, a standard query or some
other opcode, etc.
...
4.1.1. Header section format
The header contains the following fields:
1 1 1 1 1 1
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| ID |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|QR| Opcode |AA|TC|RD|RA| Z | RCODE |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| QDCOUNT |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| ANCOUNT |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| NSCOUNT |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| ARCOUNT |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
...
Summary
Congratulations! You have completed your preparations for DNS server testing. You are ready to proceed to the next exercise.
