This is a simple dns server system developped in C Language.
It has been complied in Linux and debugged through dig tool.
When getting this exercise,I think there are 3 key points to consider:
1. how to store and look up A-records effectively
2. how to decode dns query messages from clients and encode response messages to clients.
3. to create an UDP socket server to do data transport
My solution is as below:
1. use hash table algorithm to store and search A-records.
When the process starts, A-records are loaded from /etc/hosts file and inserted into hash table.
Because A records are correspondence between domain name and IP address, so I adopted BKDR string hash algorithm.
There are 1024 buckets in the hash table totally.
Hash value is computed through BKDR string hash algorithm, If the value is h, then this item is stored in bucket[h] list.
When the DNS server receives a dns query message, hash value of the domain name is computed through hash algorithm.
If the value is h, then comparision between domain name in the query message and domain name of hash node in bucket[h] list is carried out. If there exists the same domain name, then the corresponding IP address is returned to dns client.
2. To make clear of frame structure of DNS standard query and response message, I referenced RFC 1034 and RFC 1035.
When get acquainted of this, the decoding of query and encoding of responce messages becomes clear.
3. An UDP socket using epoll method is created.
Different from common select() function, the efficiency of epoll is apparently higher when handling large number of socket connections.
Because we just moniter one socket here, so the effect is not that obvious. I'd just want to do an attempt.
Also, there are several points to Note:
1. simpledns process moniters on port 53, so root permission is necessary.
2. dig tool can be used to test dimpledns.
For example, "[email protected] locolhost" can executed to query IP address of localhost from server 127.0.0.1
My test result (dns.pcap) is attached.
3. host and name correspodence must be configured in pairs in /etc/hosts.
Multiple addresses and alias are not supported.

bhxwzq
- 粉丝: 1
最新资源
- 区卫生计生系统安全生产管理的工作总结.doc
- 信息化工作总结报告范文.doc
- 2023年FLASH齐齐哈尔信息工程学校网络学院题库.doc
- 苏宁易购B2C现状调研与发展规划-中国电子商务研究中心.ppt
- 希格智能家居系统方案书.doc
- 电子商务实验一网上购物流程.doc
- 临床微生物实验室自动化建设-.pptx
- 项目管理班子的人员配备素质及管理经验.docx
- 第四代移动通信技术标准.docx
- 2023年扬州大学网络职前教育题库.doc
- 适应性精英种群策略的遗传算法用于多模函数优化公开课一等奖优质课大赛微课获奖课件.pptx
- AirPower-Transformer-Typescript资源
- 基于嵌入式的智能家居系统资料.doc
- 医药电子商务ppt课件.pptx
- 系统集成与弱电工程.pptx
- go-ldap-admin-Go资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



- 1
- 2
- 3
- 4
前往页