libmemif: example app can generate ICMP, dev perf tests (using icmpr-epoll)
Change-Id: Ib72ede51559754f606c0a1d57f4fb624d032caa6 Signed-off-by: Jakub Grajciar <Jakub.Grajciar@pantheon.tech>
This commit is contained in:

committed by
Damjan Marion

parent
6184db357d
commit
e4bb5bc7c1
94
extras/libmemif/docs/devperftest_doc.md
Normal file
94
extras/libmemif/docs/devperftest_doc.md
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
## Development performance test {#libmemif_devperftest_doc}
|
||||||
|
|
||||||
|
Simle test cases using ICMP. icmpr-epoll example app generates and transmits packets over memif interface.
|
||||||
|
|
||||||
|
#### TC1: LIB-VPP
|
||||||
|
|
||||||
|
Start icmpr-epoll example app and VPP.
|
||||||
|
|
||||||
|
VPP-side config:
|
||||||
|
```
|
||||||
|
DBGvpp# create memif id 0 master
|
||||||
|
DBGvpp# set int state memif0/0 up
|
||||||
|
DBGvpp# set int ip address memif0/0 192.168.1.1/24
|
||||||
|
```
|
||||||
|
icmpr-epoll:
|
||||||
|
```
|
||||||
|
conn 0 0 1
|
||||||
|
```
|
||||||
|
> Last argument specifies interrupt function to use. This function only respondes to ARP requests. This is important because, packet generation and transmitting is handled by a separate thread. Calling memif_tx_burst from multiple threads writing on same queue could transmit uninitialized buffers.
|
||||||
|
Once connection is established, you can send ping from VPP to icmpr-epoll app to learn its mac address.
|
||||||
|
```
|
||||||
|
DBGvpp# ping 192.168.1.2
|
||||||
|
```
|
||||||
|
> There should be no ICMP response. Only ARP response.
|
||||||
|
Now send ICMP requests from icmpr-epoll:
|
||||||
|
```
|
||||||
|
send <index> <num-of-packets> <ip_daddr> <hw_daddr>
|
||||||
|
send 0 5 192.168.1.1 02:fe:ff:ff:ff:ff
|
||||||
|
```
|
||||||
|
this command will create new thread which will generate icmp packets and transmit them over memif connection with specified index. Once the sequence is finished status will be printed.
|
||||||
|
|
||||||
|
###### Example results (owerview of test data)
|
||||||
|
|
||||||
|
(This test was run with modofication in VPP-memif plugin. The modification disallows memif tx node to allocate last ring buffer)
|
||||||
|
lib-tx: 200M (if ring full don't drop packets)
|
||||||
|
vpp-rx: 200M
|
||||||
|
vpp-tx: 200M - 50K (if ring full drop packets)
|
||||||
|
lib-rx: =vpp-tx
|
||||||
|
drop: ~0.025% (full ring)
|
||||||
|
pps: ~650K
|
||||||
|
multiple interfaces:
|
||||||
|
pps: divided
|
||||||
|
drop: constant
|
||||||
|
|
||||||
|
#### TC2: LIB-LIB
|
||||||
|
|
||||||
|
This test case will not drop packets if memif ring is full. Instead it will loop until all required packets have been sent.
|
||||||
|
|
||||||
|
Start two instances of icmpr-epoll example app.
|
||||||
|
instance 1:
|
||||||
|
```
|
||||||
|
conn 0 1 0
|
||||||
|
```
|
||||||
|
instance 2:
|
||||||
|
```
|
||||||
|
conn 0 0 1
|
||||||
|
send 0 5 192.168.1.1 aa:aa:aa:aa:aa:aa
|
||||||
|
```
|
||||||
|
> icmpr-epoll example app doesn't check ip or mac address so as long as the format is correct you can type anything as ip_daddr and hw_daddr arguments.
|
||||||
|
|
||||||
|
###### Example results (owerview of test data)
|
||||||
|
|
||||||
|
lib1-tx: 200M (if ring full don't drop packets)
|
||||||
|
lib2-rx: 200M
|
||||||
|
lib2-tx: 200M (if ring full don't drop packets)
|
||||||
|
lib1-rx: 200M
|
||||||
|
drop: obsolete
|
||||||
|
pps: 4.5M
|
||||||
|
multiple interfaces:
|
||||||
|
not tested (excpected same as TC1)
|
||||||
|
|
||||||
|
#### TC3: LIB-LIB
|
||||||
|
|
||||||
|
Start two instances of icmpr-epoll example app.
|
||||||
|
instance 1:
|
||||||
|
```
|
||||||
|
conn 0 1
|
||||||
|
```
|
||||||
|
instance 2:
|
||||||
|
```
|
||||||
|
conn 0 0 1
|
||||||
|
send 0 5 192.168.1.1 aa:aa:aa:aa:aa:aa
|
||||||
|
```
|
||||||
|
|
||||||
|
###### Example results (owerview of test data)
|
||||||
|
|
||||||
|
lib1-tx: 200M (if ring full don't drop packets)
|
||||||
|
lib2-rx: 200M
|
||||||
|
lib2-tx: 169626182 (if ring full drop packets)
|
||||||
|
lib1-rx: =lib2-tx
|
||||||
|
drop: ~15%
|
||||||
|
pps: ~6M
|
||||||
|
multiple interfaces:
|
||||||
|
not tested (excpected same as TC1)
|
@ -187,7 +187,7 @@ Statistics: 5 sent, 4 received, 20% packet loss
|
|||||||
|
|
||||||
#### icmp_responder master icmp_responder slave
|
#### icmp_responder master icmp_responder slave
|
||||||
|
|
||||||
> Example apps can only repond to ping. This setup creates connection between two applications using libmemif. Traffic functionality is the same as when connection to VPP. App can receive ARP/ICMP request and transmit response, but can not send ARP/ICMP request.
|
> This setup creates connection between two applications using libmemif. Traffic functionality is the same as when connection to VPP. App can receive ARP/ICMP request and transmit response.
|
||||||
|
|
||||||
Run two instances of icmpr-epoll example.
|
Run two instances of icmpr-epoll example.
|
||||||
> If not running in container, make sure folder /run/vpp/ exists before creating memif master.
|
> If not running in container, make sure folder /run/vpp/ exists before creating memif master.
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -137,8 +137,9 @@ resolve_eth_arp (struct ether_arp *eth_arp, void *eth_arp_resp,
|
|||||||
|
|
||||||
memcpy (resp->arp_sha,
|
memcpy (resp->arp_sha,
|
||||||
(((struct ether_header *) (eth_arp_resp -
|
(((struct ether_header *) (eth_arp_resp -
|
||||||
sizeof (struct ether_header)))->
|
sizeof (struct
|
||||||
ether_shost), 6);
|
ether_header)))->ether_shost),
|
||||||
|
6);
|
||||||
|
|
||||||
memcpy (resp->arp_spa, ip_addr, 4);
|
memcpy (resp->arp_spa, ip_addr, 4);
|
||||||
|
|
||||||
@ -172,7 +173,7 @@ resolve_ip (struct iphdr *ip, void *ip_resp, uint8_t ip_addr[4])
|
|||||||
resp->version = 4;
|
resp->version = 4;
|
||||||
resp->tos = 0;
|
resp->tos = 0;
|
||||||
/*len updated later */
|
/*len updated later */
|
||||||
resp->tot_len = 0x5400;
|
resp->tot_len = 0x0000;
|
||||||
resp->id = 0;
|
resp->id = 0;
|
||||||
resp->frag_off = 0;
|
resp->frag_off = 0;
|
||||||
resp->ttl = 0x40;
|
resp->ttl = 0x40;
|
||||||
@ -183,7 +184,7 @@ resolve_ip (struct iphdr *ip, void *ip_resp, uint8_t ip_addr[4])
|
|||||||
((uint8_t *) & resp->saddr)[3] = ip_addr[3];
|
((uint8_t *) & resp->saddr)[3] = ip_addr[3];
|
||||||
resp->daddr = ip->saddr;
|
resp->daddr = ip->saddr;
|
||||||
|
|
||||||
resp->check = cksum (resp, sizeof (struct iphdr));
|
/* resp->check = cksum (resp, sizeof (struct iphdr)); */
|
||||||
|
|
||||||
return sizeof (struct iphdr);
|
return sizeof (struct iphdr);
|
||||||
}
|
}
|
||||||
@ -192,7 +193,7 @@ static ssize_t
|
|||||||
resolve_icmp (struct icmphdr *icmp, void *icmp_resp)
|
resolve_icmp (struct icmphdr *icmp, void *icmp_resp)
|
||||||
{
|
{
|
||||||
struct icmphdr *resp = (struct icmphdr *) icmp_resp;
|
struct icmphdr *resp = (struct icmphdr *) icmp_resp;
|
||||||
resp->type = ICMP_ECHOREPLY;
|
resp->type = 0x00;
|
||||||
resp->code = 0;
|
resp->code = 0;
|
||||||
resp->un.echo.id = icmp->un.echo.id;
|
resp->un.echo.id = icmp->un.echo.id;
|
||||||
resp->un.echo.sequence = icmp->un.echo.sequence;
|
resp->un.echo.sequence = icmp->un.echo.sequence;
|
||||||
@ -208,10 +209,13 @@ resolve_packet (void *in_pck, ssize_t in_size,
|
|||||||
{
|
{
|
||||||
struct ether_header *eh;
|
struct ether_header *eh;
|
||||||
struct ether_arp *eah;
|
struct ether_arp *eah;
|
||||||
struct iphdr *ip;
|
struct iphdr *ip, *ip_out;
|
||||||
struct icmphdr *icmp;
|
struct icmphdr *icmp;
|
||||||
*out_size = 0;
|
*out_size = 0;
|
||||||
|
|
||||||
|
if ((in_pck == NULL) || (out_pck == NULL))
|
||||||
|
return -1;
|
||||||
|
|
||||||
eh = (struct ether_header *) in_pck;
|
eh = (struct ether_header *) in_pck;
|
||||||
*out_size = resolve_eth (eh, out_pck);
|
*out_size = resolve_eth (eh, out_pck);
|
||||||
|
|
||||||
@ -227,6 +231,7 @@ resolve_packet (void *in_pck, ssize_t in_size,
|
|||||||
print_packet (in_pck + *out_size);
|
print_packet (in_pck + *out_size);
|
||||||
#endif
|
#endif
|
||||||
ip = (struct iphdr *) (in_pck + *out_size);
|
ip = (struct iphdr *) (in_pck + *out_size);
|
||||||
|
ip_out = (struct iphdr *) (out_pck + *out_size);
|
||||||
*out_size += resolve_ip (ip, out_pck + *out_size, ip_addr);
|
*out_size += resolve_ip (ip, out_pck + *out_size, ip_addr);
|
||||||
if (ip->protocol == 1)
|
if (ip->protocol == 1)
|
||||||
{
|
{
|
||||||
@ -240,7 +245,95 @@ resolve_packet (void *in_pck, ssize_t in_size,
|
|||||||
memcpy (out_pck + *out_size, in_pck + *out_size,
|
memcpy (out_pck + *out_size, in_pck + *out_size,
|
||||||
in_size - *out_size);
|
in_size - *out_size);
|
||||||
*out_size = in_size;
|
*out_size = in_size;
|
||||||
|
ip_out->tot_len =
|
||||||
|
__bswap_16 (*out_size - sizeof (struct ether_header));
|
||||||
|
ip_out->check = cksum (ip_out, sizeof (struct iphdr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ssize_t
|
||||||
|
generate_eth (struct ether_header *eh, uint8_t hw_daddr[6])
|
||||||
|
{
|
||||||
|
uint8_t hw_addr[6];
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < 6; i++)
|
||||||
|
{
|
||||||
|
hw_addr[i] = 'a';
|
||||||
|
}
|
||||||
|
memcpy (eh->ether_shost, hw_addr, 6);
|
||||||
|
memcpy (eh->ether_dhost, hw_daddr, 6);
|
||||||
|
|
||||||
|
eh->ether_type = 0x0008;
|
||||||
|
|
||||||
|
return sizeof (struct ether_header);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ssize_t
|
||||||
|
generate_ip (struct iphdr *ip, uint8_t saddr[4], uint8_t daddr[4])
|
||||||
|
{
|
||||||
|
ip->ihl = 5;
|
||||||
|
ip->version = 4;
|
||||||
|
ip->tos = 0;
|
||||||
|
/*len updated later */
|
||||||
|
ip->tot_len = 0x5400;
|
||||||
|
ip->id = 0;
|
||||||
|
ip->frag_off = 0;
|
||||||
|
ip->ttl = 0x40;
|
||||||
|
ip->protocol = 1;
|
||||||
|
/* saddr */
|
||||||
|
((uint8_t *) & ip->saddr)[0] = saddr[0];
|
||||||
|
((uint8_t *) & ip->saddr)[1] = saddr[1];
|
||||||
|
((uint8_t *) & ip->saddr)[2] = saddr[2];
|
||||||
|
((uint8_t *) & ip->saddr)[3] = saddr[3];
|
||||||
|
/* daddr */
|
||||||
|
((uint8_t *) & ip->daddr)[0] = daddr[0];
|
||||||
|
((uint8_t *) & ip->daddr)[1] = daddr[1];
|
||||||
|
((uint8_t *) & ip->daddr)[2] = daddr[2];
|
||||||
|
((uint8_t *) & ip->daddr)[3] = daddr[3];
|
||||||
|
|
||||||
|
ip->check = cksum (ip, sizeof (struct iphdr));
|
||||||
|
|
||||||
|
return sizeof (struct iphdr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static ssize_t
|
||||||
|
generate_icmp (struct icmphdr *icmp, uint32_t seq)
|
||||||
|
{
|
||||||
|
icmp->type = ICMP_ECHO;
|
||||||
|
icmp->code = 0;
|
||||||
|
icmp->un.echo.id = 0;
|
||||||
|
icmp->un.echo.sequence = seq;
|
||||||
|
|
||||||
|
return sizeof (struct icmphdr);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
generate_packet (void *pck, uint32_t * size, uint8_t saddr[4],
|
||||||
|
uint8_t daddr[4], uint8_t hw_daddr[6], uint32_t seq)
|
||||||
|
{
|
||||||
|
struct ether_header *eh;
|
||||||
|
struct iphdr *ip;
|
||||||
|
struct icmphdr *icmp;
|
||||||
|
|
||||||
|
*size = 0;
|
||||||
|
|
||||||
|
eh = (struct ether_header *) pck;
|
||||||
|
*size += generate_eth (eh, hw_daddr);
|
||||||
|
|
||||||
|
ip = (struct iphdr *) (pck + *size);
|
||||||
|
*size += generate_ip (ip, saddr, daddr);
|
||||||
|
|
||||||
|
icmp = (struct icmphdr *) (pck + *size);
|
||||||
|
*size += generate_icmp (icmp, seq);
|
||||||
|
|
||||||
|
((struct icmphdr *) (pck + *size - sizeof (struct icmphdr)))->checksum =
|
||||||
|
cksum (pck + *size - sizeof (struct icmphdr), sizeof (struct icmphdr));
|
||||||
|
|
||||||
|
ip->tot_len = __bswap_16 (*size - sizeof (struct ether_header));
|
||||||
|
ip->check = 0;
|
||||||
|
ip->check = cksum (ip, sizeof (struct iphdr));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@ -21,6 +21,9 @@
|
|||||||
int resolve_packet (void *in_pck, ssize_t in_size, void *out_pck,
|
int resolve_packet (void *in_pck, ssize_t in_size, void *out_pck,
|
||||||
uint32_t * out_size, uint8_t ip_addr[4]);
|
uint32_t * out_size, uint8_t ip_addr[4]);
|
||||||
|
|
||||||
|
int generate_packet (void *pck, uint32_t * size, uint8_t saddr[4],
|
||||||
|
uint8_t daddr[4], uint8_t hw_daddr[6], uint32_t seq);
|
||||||
|
|
||||||
int print_packet (void *pck);
|
int print_packet (void *pck);
|
||||||
|
|
||||||
#endif /* _ICMP_PROTO_H_ */
|
#endif /* _ICMP_PROTO_H_ */
|
||||||
|
@ -72,3 +72,4 @@ Continue with @ref libmemif_example_setup which contains instructions on how to
|
|||||||
- @subpage libmemif_examples_doc
|
- @subpage libmemif_examples_doc
|
||||||
- @subpage libmemif_example_setup_doc
|
- @subpage libmemif_example_setup_doc
|
||||||
- @subpage libmemif_gettingstarted_doc
|
- @subpage libmemif_gettingstarted_doc
|
||||||
|
- @subpage libmemif_devperftest_doc
|
||||||
|
Reference in New Issue
Block a user