Cisco Cisco Application Extension Platform for SRE
Cisco Application eXtension Platform 1.1 Developer Guide
Swap Space and Memory Allocation
103
Swap Space and Memory Allocation
•
manual pages; for example, man 3 pcap
•
tutorial:
Note
An application running inside a virtual instance can use a raw socket to monitor all the available network
interfaces on the Cisco AXP service module.
interfaces on the Cisco AXP service module.
Raw Socket: Example
#include <stdio.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <linux/if_ether.h>
#include <linux/if_arp.h>
#include <errno.h>
int main (int argc, char* argv[]){
int result = 0;
int s = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
if(s != -1){
struct sockaddr_ll socket_address;
socket_address.sll_family = AF_PACKET;
socket_address.sll_protocol = htons(ETH_P_ALL);
bind(s, (struct sockaddr*) &socket_address, sizeof(socket_address));
char* buffer= (char*)malloc(ETH_FRAME_LEN+1);
int length=recvfrom(s, buffer, ETH_FRAME_LEN,0,NULL,NULL);
}
else{
printf("Socket creation error %d\n",errno);
result = s;
}
return result;
}
Swap Space and Memory Allocation
Swap space allows processes or parts of processes to move between physical memory and disk. This
frees up space in physical memory and allows more processes to run simultaneously.
frees up space in physical memory and allows more processes to run simultaneously.
Memory allocation for Cisco AXP applications is dependent upon Linux overcommit_memory and the
physical memory limit for the virtual instance.
physical memory limit for the virtual instance.
Linux overcommit_memory mode has a default value of 0. In this mode, the Linux memory manager
heuristically determines how memory is allocated. Overcommit handling enables a greater amount of
memory to be allocated by a process than would normally be allowed using the available memory.
heuristically determines how memory is allocated. Overcommit handling enables a greater amount of
memory to be allocated by a process than would normally be allowed using the available memory.
However, when a process accesses a page with allocated memory that does not have physical RAM, an
out of memory (OOM) condition exists—the Linux kernel then attempts to kill the process to preserve
the integrity of the system.
out of memory (OOM) condition exists—the Linux kernel then attempts to kill the process to preserve
the integrity of the system.
A physical memory limit can be setup for the Cisco AXP Virtual Instance (using the "--memory-limit"
argument of the packaging tool).
argument of the packaging tool).
Swap space can be turned on or off during packaging and is available on the following NME modules:
NME-APPRE-302-K9, NME-APPRE-502-K9, and NME-APPRE-522-K9.
NME-APPRE-302-K9, NME-APPRE-502-K9, and NME-APPRE-522-K9.
Swap space is not available on the following AIM form factor module: AIM-APPRE-102-K9.