Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Titan » DNS Example from book
DNS Example from book [message #1834216] Thu, 05 November 2020 09:13 Go to next message
Evelina Ivanova is currently offline Evelina IvanovaFriend
Messages: 7
Registered: November 2020
Junior Member
Hello,

I try to run my first TTCN project and I am following the steps from here https://www.eclipse.org/forums/index.php/t/1071947/ about the DNS Test.

Before you ask I run successfull the HelloWorld project.

When I run the DNS Test I see in the log file that the message is sent but never received, so I never receive an answer.

index.php/fa/39205/0/
Re: DNS Example from book [message #1834220 is a reply to message #1834216] Thu, 05 November 2020 09:42 Go to previous messageGo to next message
Elemer Lelik is currently offline Elemer LelikFriend
Messages: 1120
Registered: January 2015
Senior Member
Hi Evelina,

first and foremost, make sure you have a DNS server working on 127.0.0.1, (which is your own host BTW), e.g.
 nslookup google.com 127.0.0.1


If yes, then pls. trace the message sent by Titan with Wireshark ; the message should be correctly decoded ; you can also compare it with a similar message sent by some other client , such as nslookup.

If everything looks OK so far, then you should look into your DNS and figure out why it does not reply your message.
Alternatively, you can direct your query to some other DNS , changing the IP address in your configuration.

I hope this helps

BR

Elemer








Re: DNS Example from book [message #1834222 is a reply to message #1834220] Thu, 05 November 2020 09:48 Go to previous messageGo to next message
Evelina Ivanova is currently offline Evelina IvanovaFriend
Messages: 7
Registered: November 2020
Junior Member
Hello,

I tried nslookup google.com 127.0.0.1 but there is no answer. What to do now?
Re: DNS Example from book [message #1834225 is a reply to message #1834222] Thu, 05 November 2020 10:06 Go to previous messageGo to next message
Elemer Lelik is currently offline Elemer LelikFriend
Messages: 1120
Registered: January 2015
Senior Member
Hi Evelina,

this probably means that you do not have a local DNS;

try to redirect your query to another DNS:

-see if
nslookup google.com 8.8.8.8 
works
8.8.8.8 is one of Google's public DNS servers

If it does, then change the IP address in your config file from 127.0.0.1 to 8.8.8.8
and see what happens.


BR Elemer


Re: DNS Example from book [message #1834228 is a reply to message #1834225] Thu, 05 November 2020 10:16 Go to previous messageGo to next message
Elemer Lelik is currently offline Elemer LelikFriend
Messages: 1120
Registered: January 2015
Senior Member
Alternatively, you can check which DNS server works with you:

 nslookup google.com


This will be replied by the DNS server closest to you:
nslookup google.com
Server:         A.B.C.D
Address:        A.B.C.D#53

Non-authoritative answer:
Name:   google.com
Address: 172.217.19.110
Name:   google.com
Address: 2a00:1450:400d:804::200e


so then change your target IP address to "A.B.C.D"

BR

Elemer
Re: DNS Example from book [message #1834229 is a reply to message #1834225] Thu, 05 November 2020 10:34 Go to previous messageGo to next message
Evelina Ivanova is currently offline Evelina IvanovaFriend
Messages: 7
Registered: November 2020
Junior Member
Hi,

this is the result:



index.php/fa/39207/0/





index.php/fa/39208/0/



This is my configuration file:

[MODULE_PARAMETERS]
# This section shall contain the values of all parameters that are defined in your TTCN-3 modules.
tsp_remHost:="8.8.8.8"
tsp_remPort:=53;

[LOGGING]
# In this section you can specify the name of the log file and the classes of events
# you want to log into the file or display on console (standard error).

FileMask := LOG_ALL | TTCN_ERROR | TTCN_USER | MATCHING | TTCN_DEBUG
#|LOG_ALL | TTCN_WARNING | TTCN_TESTCASE | TTCN_STATISTICS | TTCN_PORTEVENT
ConsoleMask := TTCN_ERROR | TTCN_USER
#| TTCN_PORTEVENT
LogSourceInfo := Yes
TimeStampFormat := DateTime
LogEventTypes := Yes
SourceInfoFormat := Single
LogSourceInfo := Yes


[TESTPORT_PARAMETERS]
# In this section you can specify parameters that are passed to Test Ports.
*.serverPort.debugging := "yes"
*.serverPort.mode := "basic"
*.serverPort.localIPAddr := "localhost"
*.serverPort.localPort := "35000"

[DEFINE]
# In this section you can create macro definitions,
# that can be used in other configuration file sections except [INCLUDE] and [ORDERED_INCLUDE].

[INCLUDE]
# To use configuration settings given in other configuration files,
# the configuration files just need to be listed in this section, with their full or relative pathnames.

[ORDERED_INCLUDE]
# To use configuration settings given in other configuration files,
# the configuration files just need to be listed in this section, with their full or relative pathnames.

[EXTERNAL_COMMANDS]
# This section can define external commands (shell scripts) to be executed by the ETS
# whenever a control part or test case is started or terminated.

#BeginTestCase := ""
#EndTestCase := ""
#BeginControlPart := ""
#EndControlPart := ""

[EXECUTE]
# In this section you can specify what parts of your test suite you want to execute.
DNSTester.tc_ExampleTestResolveNokia1


[GROUPS]
# In this section you can specify groups of hosts. These groups can be used inside the
# [COMPONENTS] section to restrict the creation of certain PTCs to a given set of hosts.

[COMPONENTS]
# This section consists of rules restricting the location of created PTCs.

[MAIN_CONTROLLER]
# The options herein control the behavior of MC.

TCPPort := 0
KillTimer := 10.0
# NumHCs := 0
# LocalAddress :=



And this is my .ttcn file:

module DNSTester {

import from UDPasp_Types all;
import from UDPasp_PortType all;

type integer Identification (0..65535) with{ variant "FIELDLENGTH(16)"} ;
type enumerated MessageKind{e_Question,e_Answer} with{ variant "FIELDLENGTH(16)"} ;
type charstring Question with{ variant ""};
type charstring Answer with{ variant ""};

type record DNSMessage{
Identification identification,
MessageKind messageKind,
Question question,
Answer answer optional
}with{ variant ""};

type port DNSPort message{
// inout DNSMessage //DNSMessage is allowed to move in and out through this
out
DNSMessage
in
DNSMessage,
ASP_UDP_open_result
}with
{ extension
"user UDPasp_PT
out(
DNSMessage -> ASP_UDP: function(f_enc_DNS)
)
in(
ASP_UDP -> DNSMessage : function(f_dec_DNS);
ASP_UDP_message -> - : discard;
ASP_UDP_open_result -> - : discard
)
"

}

function f_enc_DNS
( in DNSMessage pl_in,
out ASP_UDP pl_out) return integer
{
pl_out.data := enc_DNSMessage(pl_in);
pl_out.addressf := tsp_remHost;
pl_out.portf := tsp_remPort;

return 0;
}with {extension "prototype(backtrack)" }

modulepar {
charstring tsp_remHost:="127.0.0.1"
integer tsp_remPort:=53;
}

function f_dec_DNS
(in ASP_UDP pl_in,
out DNSMessage pl_out) return integer
{

pl_out := dec_DNSMessage(pl_in.data);

return 0;
} with {extension "prototype(backtrack)" }

type component DNSClient{
port DNSPort serverPort //component use only one port for in/out
}



template DNSMessage a_DNSQuestion(Identification p_id, Question p_question):={
//template defines the exact message that will be communicated
identification:=p_id,
messageKind :=e_Question,
question :=p_question,
answer :=omit //since wuestion do not contain answer part so omit it

}


template DNSMessage a_DNSAnswer(Identification p_id, Answer p_Answer):={
//template defines the exact message that will be communicated
identification:=p_id,
messageKind :=e_Answer,
question :=?,
answer :=omit //since wuestion do not contain answer part so omit it

}


external function enc_DNSMessage(in DNSMessage pdu) return octetstring
with { extension "prototype(convert) encode(RAW)" };
external function dec_DNSMessage(in octetstring stream) return DNSMessage
with { extension "prototype(convert) decode(RAW)" };

testcase tc_ExampleTestResolveNokia1() runs on DNSClient{
timer replyTimer;
//send question on serverPort
map(self:serverPort, system:serverPort);
serverPort.send(a_DNSQuestion(12345,"www.nokia.com"));
replyTimer.start(20.0);
alt{

//receive answer from DNS
[] serverPort.receive(a_DNSAnswer(12345,"172.21.56.98")){
setverdict(pass);
replyTimer.stop;
}
[] serverPort.receive{
setverdict(fail,"Unexpected Response");
replyTimer.stop;
}
[] replyTimer.timeout{
setverdict(fail,"No respons since 20 sec from SUT");
}
}
stop;

}


control{
execute(tc_ExampleTestResolveNokia1());
}

} //end of module
with {encode "RAW" }


Re: DNS Example from book [message #1834230 is a reply to message #1834229] Thu, 05 November 2020 10:37 Go to previous messageGo to next message
Evelina Ivanova is currently offline Evelina IvanovaFriend
Messages: 7
Registered: November 2020
Junior Member
It is the same with 8.8.8.8 and A.B.C.D
Re: DNS Example from book [message #1834237 is a reply to message #1834230] Thu, 05 November 2020 12:51 Go to previous messageGo to next message
Elemer Lelik is currently offline Elemer LelikFriend
Messages: 1120
Registered: January 2015
Senior Member
Hi Evelina,

remove the below lines from your config file ( I have commented out the last two lines):

[TESTPORT_PARAMETERS]
# In this section you can specify parameters that are passed to Test Ports.
*.serverPort.debugging := "yes"
*.serverPort.mode := "basic"
#*.serverPort.localIPAddr := "localhost"
#*.serverPort.localPort := "35000"


The last two parameters contain confusing info for the test port, suggesting that it should work in server(listener) mode.

What I'm getting now is:


2020/Nov/05 13:40:49.375009 EXECUTOR - TTCN-3 Main Test Component started on HU-00001378. Version: CRL 113 200/7 R1B.
2020/Nov/05 13:40:49.375239 EXECUTOR - TTCN Logger v2.2 options: TimeStampFormat:=DateTime; LogEntityName:=No; LogEventTypes:=Yes; SourceInfoFormat:=Single; *.FileMask:=LOG_ALL | MATCHING | DEBUG; *.ConsoleMask:=ERROR | USER; LogFileSize:=0; LogFileNumber:=1; DiskFullAction:=Error
2020/Nov/05 13:40:49.376635 EXECUTOR - Connected to MC.
2020/Nov/05 13:40:49.388226 EXECUTOR - Executing test case tc_ExampleTestResolveNokia1 in module DNSTester.
2020/Nov/05 13:40:49.388684 TESTCASE DNSTester.ttcn:97 Test case tc_ExampleTestResolveNokia1 started.
2020/Nov/05 13:40:49.388788 PARALLEL DNSTester.ttcn:97 Initializing variables, timers and ports of component type DNSTester.DNSClient inside testcase tc_ExampleTestResolveNokia1.
2020/Nov/05 13:40:49.388861 DEBUG DNSTester.ttcn:97 UDP test port (serverPort): leaving UDPasp__PT::set_parameter(debugging, yes)
2020/Nov/05 13:40:49.388929 DEBUG DNSTester.ttcn:97 UDP test port (serverPort): entering UDPasp__PT::set_parameter(mode, basic)
2020/Nov/05 13:40:49.388986 DEBUG DNSTester.ttcn:97 UDP test port (serverPort): leaving UDPasp__PT::set_parameter(mode, basic)
2020/Nov/05 13:40:49.389027 PORTEVENT DNSTester.ttcn:97 Port serverPort was started.
2020/Nov/05 13:40:49.389077 PARALLEL DNSTester.ttcn:97 Component type DNSTester.DNSClient was initialized.
2020/Nov/05 13:40:49.389122 PARALLEL DNSTester.ttcn:100 Mapping port mtc:serverPort to system:serverPort.
2020/Nov/05 13:40:49.389559 DEBUG DNSTester.ttcn:100 UDP test port (serverPort): entering UDPasp__PT::user_map()
2020/Nov/05 13:40:49.389619 DEBUG DNSTester.ttcn:100 UDP test port (serverPort): entering UDPasp__PT::setUpSocket()
2020/Nov/05 13:40:49.389718 DEBUG DNSTester.ttcn:100 UDP test port (serverPort): Binding port...
2020/Nov/05 13:40:49.390267 DEBUG DNSTester.ttcn:100 UDP test port (serverPort): leaving UDPasp__PT::setUpSocket()
2020/Nov/05 13:40:49.390354 DEBUG DNSTester.ttcn:100 UDP test port (serverPort): leaving UDPasp__PT::user_map()
2020/Nov/05 13:40:49.390475 PORTEVENT DNSTester.ttcn:100 Port serverPort was mapped to system:serverPort.
2020/Nov/05 13:40:49.391266 PARALLEL DNSTester.ttcn:100 Map operation of mtc:serverPort to system:serverPort finished.
2020/Nov/05 13:40:49.391528 PORTEVENT DNSTester.ttcn:101 Sent on serverPort to system @DNSTester.DNSMessage : { identification := 12345, messageKind := e_Question (0), question := "www.nokia.com", answer := omit }
2020/Nov/05 13:40:49.391671 DEBUG DNSTester.ttcn:44 enc_DNSMessage(): Encoding @DNSTester.DNSMessage: { identification := 12345, messageKind := e_Question (0), question := "www.nokia.com", answer := omit }
2020/Nov/05 13:40:49.391737 DEBUG DNSTester.ttcn:44 enc_DNSMessage(): Stream after encoding: '393000007777772E6E6F6B69612E636F6D'O
2020/Nov/05 13:40:49.391798 PORTEVENT DNSTester.ttcn:101 Outgoing message was mapped to @UDPasp_Types.ASP_UDP : { data := '393000007777772E6E6F6B69612E636F6D'O, addressf := "8.8.8.8", portf := 53 }
2020/Nov/05 13:40:49.391847 DEBUG DNSTester.ttcn:101 UDP test port (serverPort): entering UDPasp__PT::outgoing_send(ASP__UDP)
2020/Nov/05 13:40:49.391881 DEBUG DNSTester.ttcn:101 Sending data: Size: 17,
Msg:  39 30 00 00 77 77 77 2e 6e 6f 6b 69 61 2e 63 6f 6d

2020/Nov/05 13:40:49.391920 DEBUG DNSTester.ttcn:101 UDP test port (serverPort): UDPasp__PT::getHostId called
2020/Nov/05 13:40:49.391955 DEBUG DNSTester.ttcn:101 UDP test port (serverPort): Host name: 8.8.8.8, Host address: 134744072
2020/Nov/05 13:40:49.391990 DEBUG DNSTester.ttcn:101 UDP test port (serverPort): UDPasp__PT::getHostId exited
2020/Nov/05 13:40:49.393759 DEBUG DNSTester.ttcn:101 UDP test port (serverPort): Nr of bytes sent = 17
2020/Nov/05 13:40:49.393838 DEBUG DNSTester.ttcn:101 UDP test port (serverPort): leaving UDPasp__PT::outgoing_send(ASP__UDP)
2020/Nov/05 13:40:49.393870 TIMEROP DNSTester.ttcn:102 Start timer replyTimer: 20 s
2020/Nov/05 13:40:49.397222 DEBUG DNSTester.ttcn:103 UDP test port (serverPort): entering UDPasp__PT::Event_Handler()
2020/Nov/05 13:40:49.397289 DEBUG DNSTester.ttcn:103 Message received:  Size: 12,
Msg:  39 30 80 01 00 00 00 00 00 00 00 00

2020/Nov/05 13:40:49.397322 DEBUG DNSTester.ttcn:103 UDP test port (serverPort): The remote port:          13568
2020/Nov/05 13:40:49.397352 DEBUG DNSTester.ttcn:103 UDP test port (serverPort): The remote address:       8.8.8.8
2020/Nov/05 13:40:49.397375 DEBUG DNSTester.ttcn:103 Recevied PDU   Size: 12,
Msg:  39 30 80 01 00 00 00 00 00 00 00 00

2020/Nov/05 13:40:49.397409 PORTEVENT DNSTester.ttcn:103 Message enqueued on serverPort from system @UDPasp_Types.ASP_UDP : { data := '393080010000000000000000'O, addressf := "8.8.8.8", portf := 53 } id 1
2020/Nov/05 13:40:49.397448 DEBUG DNSTester.ttcn:61 dec_DNSMessage(): Stream before decoding: '393080010000000000000000'O
2020/Nov/05 13:40:49.397489 WARNING DNSTester.ttcn:61 Warning: While RAW-decoding type '@DNSTester.DNSMessage': Invalid enum value '384' for '@DNSTester.MessageKind': 
2020/Nov/05 13:40:49.397519 DEBUG DNSTester.ttcn:61 dec_DNSMessage(): Decoded @DNSTester.DNSMessage: { identification := 12345, messageKind := <unknown> (2), question := char(0, 0, 0, 0) & char(0, 0, 0, 0) & char(0, 0, 0, 0) & char(0, 0, 0, 0) & char(0, 0, 0, 0) & char(0, 0, 0, 0) & char(0, 0, 0, 0) & char(0, 0, 0, 0), answer := omit }
2020/Nov/05 13:40:49.397551 PORTEVENT DNSTester.ttcn:103 Incoming message was mapped to @DNSTester.DNSMessage : { identification := 12345, messageKind := <unknown> (2), question := char(0, 0, 0, 0) & char(0, 0, 0, 0) & char(0, 0, 0, 0) & char(0, 0, 0, 0) & char(0, 0, 0, 0) & char(0, 0, 0, 0) & char(0, 0, 0, 0) & char(0, 0, 0, 0), answer := omit } id 1
2020/Nov/05 13:40:49.397583 DEBUG DNSTester.ttcn:103 UDP test port (serverPort): leaving UDPasp__PT::Event_Handler()
2020/Nov/05 13:40:49.397611 MATCHING DNSTester.ttcn:106 Matching on port serverPort <unknown> (2) with e_Answer (1) unmatched: First message in the queue does not match the template: 
2020/Nov/05 13:40:49.397648 MATCHING DNSTester.ttcn:110 Matching on port serverPort succeeded.
2020/Nov/05 13:40:49.397672 PORTEVENT DNSTester.ttcn:110 Receive operation on port serverPort succeeded, message from system(): @DNSTester.DNSMessage: { identification := 12345, messageKind := <unknown> (2), question := char(0, 0, 0, 0) & char(0, 0, 0, 0) & char(0, 0, 0, 0) & char(0, 0, 0, 0) & char(0, 0, 0, 0) & char(0, 0, 0, 0) & char(0, 0, 0, 0) & char(0, 0, 0, 0), answer := omit } id 1
2020/Nov/05 13:40:49.397700 PORTEVENT DNSTester.ttcn:110 Message with id 1 was extracted from the queue of serverPort.
2020/Nov/05 13:40:49.397722 VERDICTOP DNSTester.ttcn:111 setverdict(fail): none -> fail reason: "Unexpected Response", new component reason: "Unexpected Response"
2020/Nov/05 13:40:49.397753 TIMEROP DNSTester.ttcn:112 Stop timer replyTimer: 20 s
2020/Nov/05 13:40:49.397776 PARALLEL DNSTester.ttcn:118 Stopping test component execution.
2020/Nov/05 13:40:49.398141 FUNCTION DNSTester.ttcn:118 Test case tc_ExampleTestResolveNokia1 was stopped.
2020/Nov/05 13:40:49.398207 PARALLEL DNSTester.ttcn:118 Terminating component type DNSTester.DNSClient.
2020/Nov/05 13:40:49.398238 PORTEVENT DNSTester.ttcn:118 Removing unterminated mapping between port serverPort and system:serverPort.
2020/Nov/05 13:40:49.398279 DEBUG DNSTester.ttcn:118 UDP test port (serverPort): entering UDPasp__PT::user_unmap()
2020/Nov/05 13:40:49.398302 DEBUG DNSTester.ttcn:118 UDP test port (serverPort): entering UDPasp__PT::closeDownSocket()
2020/Nov/05 13:40:49.398453 DEBUG DNSTester.ttcn:118 UDP test port (serverPort): entering UDPasp__PT::closeDownSocket()
2020/Nov/05 13:40:49.398517 DEBUG DNSTester.ttcn:118 UDP test port (serverPort): leaving UDPasp__PT::user_unmap()
2020/Nov/05 13:40:49.398541 PORTEVENT DNSTester.ttcn:118 Port serverPort was unmapped from system:serverPort.
2020/Nov/05 13:40:49.398836 PORTEVENT DNSTester.ttcn:118 Port serverPort was stopped.
2020/Nov/05 13:40:49.398891 PARALLEL DNSTester.ttcn:118 Component type DNSTester.DNSClient was shut down inside testcase tc_ExampleTestResolveNokia1.
2020/Nov/05 13:40:49.398951 EXECUTOR DNSTester.ttcn:118 Waiting for PTCs to finish.
2020/Nov/05 13:40:49.399471 VERDICTOP DNSTester.ttcn:118 Setting final verdict of the test case.
2020/Nov/05 13:40:49.399558 VERDICTOP DNSTester.ttcn:118 Local verdict of MTC: fail reason: "Unexpected Response"
2020/Nov/05 13:40:49.399589 VERDICTOP DNSTester.ttcn:118 No PTCs were created.
2020/Nov/05 13:40:49.399614 TESTCASE DNSTester.ttcn:118 Test case tc_ExampleTestResolveNokia1 finished. Verdict: fail reason: Unexpected Response
2020/Nov/05 13:40:49.409628 STATISTICS - Verdict statistics: 0 none (0.00 %), 0 pass (0.00 %), 0 inconc (0.00 %), 1 fail (100.00 %), 0 error (0.00 %).
2020/Nov/05 13:40:49.409822 STATISTICS - Test execution summary: 1 test case was executed. Overall verdict: fail
2020/Nov/05 13:40:49.409866 EXECUTOR - Exit was requested from MC. Terminating MTC.


So an answer is received, but it cannot be correctly decoded within the boundaries of the oversimplistic structural definition of the DNS messages that has been defined here.

I suggest you use the more complete and correct definitions in
https://github.com/eclipse/titan.ProtocolModules.DNS

instead.

BR

Elemer
Re: DNS Example from book [message #1834240 is a reply to message #1834237] Thu, 05 November 2020 13:33 Go to previous message
Evelina Ivanova is currently offline Evelina IvanovaFriend
Messages: 7
Registered: November 2020
Junior Member
Hi, Elemer,

Thank you very much. It is working! I'will try now the correct definition.
Previous Topic:The type of the expression must be union or anytype
Next Topic:Unexpected behavior of port.halt?
Goto Forum:
  


Current Time: Fri Apr 19 00:20:49 GMT 2024

Powered by FUDForum. Page generated in 0.02961 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top