dpdk
所属分类:网络编程
开发工具:C
文件大小:0KB
下载次数:6
上传日期:2022-11-26 14:28:39
上 传 者:
sh-1993
说明: DPDK实现的网络堆栈,
(Network stack implemented by DPDK,)
文件列表:
Makefile (1914, 2022-11-26)
arp-config.md (1870, 2022-11-26)
arp.c (6981, 2022-11-26)
arp.h (1014, 2022-11-26)
bpf/ (0, 2022-11-26)
bpf/Makefile (881, 2022-11-26)
bpf/bash.bt (299, 2022-11-26)
bpf/bpf_program.c (384, 2022-11-26)
bpf/bpf_program.o (936, 2022-11-26)
bpf/loader.c (230, 2022-11-26)
config.h (218, 2022-11-26)
context.c (1878, 2022-11-26)
context.h (507, 2022-11-26)
ddos.c (3732, 2022-11-26)
ddos.h (98, 2022-11-26)
dns.c (11935, 2022-11-26)
dns.h (3048, 2022-11-26)
env-set-up.md (2077, 2022-11-26)
epoll.c (6275, 2022-11-26)
epoll.h (1602, 2022-11-26)
file.c (1099, 2022-11-26)
file.h (106, 2022-11-26)
hash.c (1138, 2022-11-26)
hash.h (265, 2022-11-26)
icmp.c (3722, 2022-11-26)
icmp.h (509, 2022-11-26)
images/ (0, 2022-11-26)
images/dpdk-mem.png (681126, 2022-11-26)
images/net-server-arch.png (139634, 2022-11-26)
kni.c (5976, 2022-11-26)
kni.h (224, 2022-11-26)
list.h (751, 2022-11-26)
main.c (5092, 2022-11-26)
main.h (137, 2022-11-26)
rb_tree.h (28948, 2022-11-26)
socket.c (12029, 2022-11-26)
socket.h (2360, 2022-11-26)
tcp.c (17773, 2022-11-26)
... ...
# Environment Setup
[Setup](https://github.com/Jemmy512/dpdk/blob/master/./env-set-up.md)
# Architecture
![](https://github.com/Jemmy512/dpdk/blob/master/./images/net-server-arch.png)
## Hierarchy
* **pkt rx tx** thread is responsible to receive the packages from NIC, stores the packages into systemm input ring; transmit the package sent by application layer to NIC.
* **net stack handler** functions to analysis packges received from lower layer, dispatches the packges to the approprite service layer.
* **tcp udp dns server** apply application sepesific functions.
## Files
* **socket.c** imtplements `socket`, `bind`, `listen`, `send`, `recv`, `sendto`, `recvfrom`, `close` APIs.
* **tcp.c** implements tcp package encoding, three ways handshakes, four way handshakes and tcp stream management.
* **udp.c** implement UDP package encoding, UDP echo server.
* **icmp.c** implements icmp protocol and package encoding.
* **arp.c** implements arp protocol and packge encoding.
* **epoll.c** monitors file descriptors based on event drive design.
* **dns.c** implements dns server.
* **kni.c** forwards ARP, ICMP packages to Linux Kernel and let kernel handle these protocols.
* **context.c** allocats system memory pool and get local mac.
* **hash.c** uses cuckoo algorithm to store and find sock with key combinad by src_ip, src_port, dst_port, dst_port, protocol.
[:link: DPDK Source Code Anatomy](https://github.com/Jemmy512/dpdk/blob/master/https://github.com/Jemmy512/software-engineer/blob/master/OpenSource/DPDK/README.md)
![](https://github.com/Jemmy512/dpdk/blob/master/https://raw.githubusercontent.com/Jemmy512/dpdk/master/images/dpdk-mem.png)
# TCP
```
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Source Port | Destination Port |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Sequence Number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Acknowledgment Number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Data | |U|A|P|R|S|F| |
| Offset| Reserved |R|C|S|S|Y|I| Window |
| | |G|K|H|T|N|N| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Checksum | Urgent Pointer |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Options | Padding |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| data |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
```
# UDP
```
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Source Port | Destination Port |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Length | Checksum |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| data octets |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
```
# IP
```
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Version| IHL |Type of Service| Total Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Identification |Flags| Fragment Offset |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Time to Live | Protocol | Header Checksum |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Source Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Destination Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Options | Padding |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
```
IHL: 4 bits
* Internet Header Length is the length of the internet header in 32 bit words, and thus points to the beginning of the data. Note that the minimum value for a correct header is 5.
Type of Service: 8 bits
* Bits 0-2: Precedence.
* Bit 3: 0 = Normal Delay, 1 = Low Delay.
* Bits 4: 0 = Normal Throughput, 1 = High Throughput.
* Bits 5: 0 = Normal Relibility, 1 = High Relibility.
* Bit 6-7: Reserved for Future Use.
* Precedence
* 111 - Network Control
* 110 - Internetwork Control
* 101 - CRITIC/ECP
* 100 - Flash Override
* 011 - Flash
* 010 - Immediate
* 001 - Priority
* 000 - Routine
Identification: 16 bits
* An identifying value assigned by the sender to aid in assembling the fragments of a datagram.
Flags: 3 bits
* Bit 0: reserved, must be zero
* Bit 1: (DF) 0 = May Fragment, 1 = Don't Fragment.
* Bit 2: (MF) 0 = Last Fragment, 1 = More Fragments.
# ARP
```
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Hardware Type | Protocol Type |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Hard Addr Len | Prot Addr Len | Operation |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Sender Hardware Address |
| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| | Sender IP Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Target Hardware Address |
| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| | Target IP Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Identifier | Sequence Number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
```
# ICMP
```
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Type | Code | Checksum |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Identifier | Sequence Number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Data |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
```
Type:
* 8 for echo message;
* 0 for echo reply message.
Code
* 0
Identifier
* If code = 0, an identifier to aid in matching echos and replies, may be zero.
近期下载者:
相关文件:
收藏者: