代做COMP3331/9331 Computer Networks and Applications Assignment for Term 2, 2024代做留学生Java程序

COMP3331/9331 Computer Networks and Applications

Assignment for Term 2, 2024

DNS Implementation

1. Goal and Learning Objectives

In this assignment, you will have the opportunity to implement a simplified version of DNS. Your applications are based on a client-server model consisting of one server and multiple clients, where:

1.   A client can accept some user query, send it to the server, wait for a response, and upon receiving a response, display the results.

2.   A server waits for client queries, and upon receiving a query, attempts to resolve it using resource records found in a master file, then replies with the appropriate response.

All client-server communication will be over UDP (TCP cannot be used for this assignment).

You will additionally submit a report.

On completing this assignment, you will gain sufficient expertise in the following skills:

1.   A deeper understanding of how DNS works.

2.   Socket programming for UDP transport protocol.

3.   Designing an application layer protocol.

2. Master File

The master file is a text file that contains resource records (RRs) in text form. Each line contains one record. Any number of spaces act as a delimiter between the separate items that make up a record. The items that make up a record, in the order they appear on a line, are:

Where:

•   domain-name: is said to be the "owner" of the record. The labels in the domain name are expressed as character strings and are separated by dots.

-    All domain names will end with a dot.

-    All domain names will be 256 characters or less.

-    All domain names will be in lower case.

-    All labels within a domain name will start with a letter, end with a letter or digit, and have as interior characters only letters a-z, digits 0-9, and hyphens.

-    All labels will be 63 characters or less.

•   type: specifies the type of the resource in the resource record, which will be one of the following:

-    A: a host address.

-    CNAME: identifies the canonical name of an alias.

-    NS: the authoritative name server for the domain.

•   data: is the type-dependent data which describes the resource:

-    A: a 32-bit IP address expressed as four decimal numbers separated by dots and without any embedded spaces.

-    CNAME: a domain name, which follows the previously stated rules for domain names, and specifies the canonical or primary name for the owner.  The owner name is an alias.

-    NS: a domain name, which follows the previously stated rules for domain names, and specifies a host which should be authoritative for the domain.

Resource records with the same domain-name and type form. a resource set.  The order of RRs in a set is not significant, and need not be preserved by the client or server.

You may assume that each resource record in the master file will be unique, but you should not assume any particular ordering of the master file.

You may assume that the master file contains at least one NS record for the root zone, and its corresponding A record, meaning the server can always refer the client to some other name server which will provide eventual access to an answer. You may also assume there will be no circular CNAME references, and no NS records that point to a CNAME record.

The master file will be named master.txt.  It will be located in the working directory of the server, and it will follow the format and rules stated above.

Do not hard-code any resource records within your server program.  The records must be read from the file when the server is executed. Failure to do so will likely result in your applications not passing any testing.

Do not hard-code any path to the master file, or assume any name other than master.txt, within your server program. The program must read the file master.txt from the current working directory. Failure to do so will likely result in your applications not passing any testing.

You may assume that the master file will contain no more than 256 records, there will be no blank lines, and there will be no leading or trailing whitespace on any line.  Furthermore, the final record will have no trailing newline.

A sample master file is provided. A different master file will be used during marking. You may assume the file will be present, will have the same name, and will follow the same format and rules.

3. Message Format

You are to design the message format. Your design may utilise a single format for both queries and responses, or they may be distinct. However, conceptually the messages should include the information detailed below. You may assume that the resource records contained within any message, stripped of any whitespace between the fields, will not exceed 2048 bytes.

3.1. Client Query

+---------------------+

|         Header        |

+---------------------+

|        Question       | the question for the server

+---------------------+

Minimally the header section should include:

qid: A 16-bit unsigned integer, randomly generated by the client, as an identifier for the query.

This identifier is copied into the corresponding response by the server. The question section should include:

•   qtype: The type of the query, and will be one of the types listed in Section 2. Master File.

•   qname: The target domain name of the query, which will follow the rules detailed in Section 2. Master File

3.2. Server Response

+---------------------+

|          Header         |

+---------------------+

|        Question        | the question for the server

+---------------------+

|          Answer         | RRs answering the question

+---------------------+

|      Authority       | RRs pointing toward an authority

+---------------------+

|      Additional      | RRs holding additional information

+---------------------+

Minimally the header section should include:

•   qid: The 16-bit unsigned integer identifier of the query to which this is a response. Similar to the qid, the question section duplicates the question section of the query.

The last three sections have the same format: a possibly empty list of concatenated resource records (RRs). The answer section contains RRs that answer the question; the authority section contains RRs that point toward an authoritative name server; the additional section contains RRs which relate to the query, but are not strictly answers for the question.  All RRs will follow the rules detailed in Section2. Master File.

4. Client

4.1. File Name and Arguments

The main code for the client must be contained in one of the following files:

•    client.c

Client.java

•    client.py

You are free to create additional helper files and name them as you wish. The client should accept the following arguments:

1.   server_port: The UDP port number on which the server is listening.  This will be the same argument supplied to the server.

2.   qname: The target domain name of the query. This will be well formed, as discussed in Section 2. Master File, will always be provided in lower case, and will always include a trailing  . to represent the root domain.

3.   qtype: The type of the query.  This will be one of the types listed in Section 2. Master File, and will always be provided in upper case.

4.   timeout: The duration in seconds, greater than 0 but no more than 15, which the client should wait for a response before considering it a failure and terminating.

Execution of your client should be initiated as follows:

C:

$ ./client server_port qname qtype timeout

Java:

$ java Client server_port qname qtype timeout

Python:

$ python3 client.py server_port qname qtype timeout

During testing, we will ensure that the command-line arguments provided are in the correct format. We will not test for erroneous arguments, missing arguments, etc.  That said, it is good programming practice to check for such input errors.

4.2. Client Operation

Upon execution, the client should:

1.   Construct a message that will carry the provided qname and qtype in its question section.

2.   Assign a randomly generated, 16-bit unsigned integer as the qid.

3.   Using an ephemeral port (i.e. one allocated by the operating system), send the message to the server_port of the localhost (127.0.0.1).

4.   Wait up to timeout seconds for a response.

5.   If received, print the response, otherwise, print an error message.

6.   Terminate.

4.3. Client Output

You are free to nominate the output format, provided it is easily human readable, but minimally it must include:

The qid carried in the response, as a decimal integer.

•   A Question section heading, followed by the qname and qtype found in the response.

•   For each of the Answer, Authority, and Additional sections:

-    A section heading, followed by the resource records contained in that section of the response.

-    You are free to choose whether or not a heading is printed out for any section that does not contain any records.

Important: Tutors will be relying on the output in order to mark your client. If it does not produce any output, then it cannot be marked. If the output is difficult to read, or some of the output is missing, then you should not expect full marks, even if your implementation is otherwise correct.

Please do not email course staff or post on the forum asking if your output is acceptable. This is not scalable for a course of this size. If you are unsure of your output, then you should follow the example output.

Examples are provided in Appendix G. Sample Interactions.

5. Server

5.1. File Name and Arguments

The main code for the server must be contained in one of the following files:

server.c

Server.java

server.py

You are free to create additional helper files and name them as you wish. The server should accept the following argument:

1.   server_port: The UDP port number on which the server should listen for client queries. We recommend using a random port number between 49152 and 65535 (the dynamic port number range).  This will be the same port argument supplied to the client.

Execution of your server should be initiated as follows:

C:

$ ./server server_port

Java:

$ java Server server_port

Python:

$ python3 server.py server_port

During testing, we will ensure that the command-line arguments provided are in the correct format. We will not test for erroneous arguments, missing arguments, etc.  That said, it is good programming practice to check for such input errors.

5.2. Server Operation

Upon execution, the server should:

1.   Read in the master file, and initialise an in-memory cache with these records.

a.   You are free to design the cache internals, with the help of any general purpose (i.e. non-DNS) standard libraries, as you see fit.

2.   Bind to the server_port of the loopback interface (127.0.0.1).

a.   During testing the server and all clients will be executed on the same host.

3.   Loop forever, listening for queries. Upon receiving a query, the server should:

a.   Delay processing the query for a random amount of time of 0,  1, 2, 3, or 4 seconds. Meanwhile the server should still be able to listen for (and similarly delay/process) other queries.  This will allow us to assess how well your server can multiplex queries from multiple clients.

b.   Once the delay period has elapsed for a given query, construct the appropriate response, utilising its cache.

c.   Send the response back to the client.

The server needs to support multiple clients simultaneously.  A robust way to achieve this is to use multithreading.  In this approach, you might have a main thread to listen for new queries.  When a query is received the server might spawn a new thread, which will sleep for the delay duration, process the query, send a response, and then terminate.  However, we do not mandate any specifics.  You may elect to solve this some other way.  Regardless of your approach, you should not assume any arbitrary limits on the number and frequency of clients.

You may also note that during testing the server will always be started before any client requests are made, the server will not be manually terminated, and should the server crash, it will be restarted.

5.3. Query Processing

1.   Attempt to match the qname.

a.   If the whole of qname is matched, we have found the node.

If the data at the node is a CNAME, and qtype doesn't match CNAME, copy the CNAME RR into the answer section of the response, change qname to the canonical name found in the CNAME RR, and start again. Note, in this scenario the ordering of the CNAME records in the answer section should follow the order in which they're added, which should also be reflected in the client output.

Otherwise, copy all RRs which match qtype into the answer section, and go to step 2.

b.   If the match fails, we have a referral.

Find the closest ancestor zone to qname for which there are known name servers. Copy all NS RRs for the zone into the authority section.  For each name server, copy any known A records into the additional section.  Go to step 2.

2.   Send the response.

You may assume that all queries are resolvable, via an answer and/or a referral.

5.4. Server Output

You are free to nominate the output format, provided it is easily human readable, but it must log to the terminal all messages sent and received, and minimally include:

•   A timestamp of when the message was sent or received, with at least millisecond precision.

•   Whether the message was sent or received.

•   The client port number.

The qid of the message, as a decimal integer.

•   The qname and qtype carried in the message.

•   If the message is a query received, the period of delay until the query will be processed.

-    Note, this should be printed when the query is received, not when the  query is processed.

A general template may look like:

:  (delay: s)

Important: Tutors will be relying on the output in order to mark your server. If it does not produce any output, then it cannot be marked. If the output is difficult to read, or some of the output is missing, then you should not expect full marks, even if your implementation is otherwise correct.

Please do not email course staff or post on the forum asking if your output is acceptable. This is not scalable for a course of this size. If you are unsure of your output, then you should follow the example output.

Examples are provided in Appendix G. Sample Interactions.

6. Report

You should submit a small report (no more than 2 pages) named report.pdf. This should include:

•   Details of which language you have used (e.g., C) and the organisation of your code (Makefile, directories if any, etc.).

•   The overall program design and any data structure design, for example, any data structures used to represent resource records, application messages, and the cache.

•   Known limitations, for example, if your program does not work under certain circumstances, then report those circumstances.

•   Also indicate any segments of code that you have borrowed from the Web or other sources.








热门主题

课程名

mktg2509 csci 2600 38170 lng302 csse3010 phas3226 77938 arch1162 engn4536/engn6536 acx5903 comp151101 phl245 cse12 comp9312 stat3016/6016 phas0038 comp2140 6qqmb312 xjco3011 rest0005 ematm0051 5qqmn219 lubs5062m eee8155 cege0100 eap033 artd1109 mat246 etc3430 ecmm462 mis102 inft6800 ddes9903 comp6521 comp9517 comp3331/9331 comp4337 comp6008 comp9414 bu.231.790.81 man00150m csb352h math1041 eengm4100 isys1002 08 6057cem mktg3504 mthm036 mtrx1701 mth3241 eeee3086 cmp-7038b cmp-7000a ints4010 econ2151 infs5710 fins5516 fin3309 fins5510 gsoe9340 math2007 math2036 soee5010 mark3088 infs3605 elec9714 comp2271 ma214 comp2211 infs3604 600426 sit254 acct3091 bbt405 msin0116 com107/com113 mark5826 sit120 comp9021 eco2101 eeen40700 cs253 ece3114 ecmm447 chns3000 math377 itd102 comp9444 comp(2041|9044) econ0060 econ7230 mgt001371 ecs-323 cs6250 mgdi60012 mdia2012 comm221001 comm5000 ma1008 engl642 econ241 com333 math367 mis201 nbs-7041x meek16104 econ2003 comm1190 mbas902 comp-1027 dpst1091 comp7315 eppd1033 m06 ee3025 msci231 bb113/bbs1063 fc709 comp3425 comp9417 econ42915 cb9101 math1102e chme0017 fc307 mkt60104 5522usst litr1-uc6201.200 ee1102 cosc2803 math39512 omp9727 int2067/int5051 bsb151 mgt253 fc021 babs2202 mis2002s phya21 18-213 cege0012 mdia1002 math38032 mech5125 07 cisc102 mgx3110 cs240 11175 fin3020s eco3420 ictten622 comp9727 cpt111 de114102d mgm320h5s bafi1019 math21112 efim20036 mn-3503 fins5568 110.807 bcpm000028 info6030 bma0092 bcpm0054 math20212 ce335 cs365 cenv6141 ftec5580 math2010 ec3450 comm1170 ecmt1010 csci-ua.0480-003 econ12-200 ib3960 ectb60h3f cs247—assignment tk3163 ics3u ib3j80 comp20008 comp9334 eppd1063 acct2343 cct109 isys1055/3412 math350-real math2014 eec180 stat141b econ2101 msinm014/msing014/msing014b fit2004 comp643 bu1002 cm2030
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图