Opendpi Integration Manual: Date: 4 September 2009
Opendpi Integration Manual: Date: 4 September 2009
Version: 1.0
Date: 4 September 2009
www.opendpi.org
OpenDPI Integration Manual
Table of Contents
Introduction.................................................................................................3
About............................................................................................................................3
Supported Protocols.......................................................................................................3
P2P File Sharing.........................................................................................................................3
Voice over IP..............................................................................................................................3
Instant Messaging.......................................................................................................................3
Streaming Protocols....................................................................................................................3
Tunnel Protocols..........................................................................................................................3
Standard Protocols......................................................................................................................3
Gaming Protocols.......................................................................................................................3
False Positive and False Negative rate...........................................................................4
Differences between OpenDPI and PACE.........................................................................4
OpenDPI Integration....................................................................................7
Page 2/9
OpenDPI Integration Manual
Introduction
About
OpenDPI is a software library designed to classify Internet traffic according to network protocols. For this
purpose mainly deep packet inspection (DPI) is used.
OpenDPI is derived from PACE, the traffic classification engine of ipoque, a provider of carrier!grade DPI and
bandwidth management solutions. In contrast to ipoque's PACE engine, OpenDPI does not support the
detection of encrypted protocols and it does not use any heuristic and behavioral analysis for classification.
Supported Protocols
The following protocols are supported by OpenDPI. The complete list of protocols supported by PACE is
available at http://www.ipoque.com/products/protocol!support.
Voice over IP
SIP, IAX, RTP
Instant Messaging
Yahoo, Oscar, IRC, unencrypted Jabber, Gadu!Gadu, MSN
Streaming Protocols
ORB, RTSP, Flash, MMS, MPEG, Quicktime, Joost, WindowsMedia, RealMedia, TVAnts, SOPCast, TVUPlayer,
PPStream, PPLive, QQLive, Zattoo, VeohTV, AVI, Feidian, Ececast, Kontiki, Move, RTSP, SCTP, SHOUTcast
Tunnel Protocols
IPsec,GRE, SSL, SSH, IP in IP
Standard Protocols
HTTP, Direct download links (1!click file hosters), POP, SMTP, IMAP, FTP, BGP, DHCP, DNS, EGP, ICMP, IGMP,
MySQL, NFS, NTP, OSPF, pcAnywhere, PostgresSQL, RDP, SMB, SNMP, SSDP, STUN, Telnet, Usenet, VNC,
IPP, MDNS, NETBIOS, XDMCP, RADIUS, SYSLOG, LDAP
Gaming Protocols
World of Warcraft, Halflife, Steam, Xbox, Quake, Second Life
Page 3/9
OpenDPI Integration Manual
1 A flow is a bidirectional communication channel between two network applications. It is identified by the 5!tuple (SRC IP, DST IP, SRC
PORT, DST PORT, IP PROTOCOL) in combination with an idle time!out. This definition applies for both TCP and UDP. A flow is
sometimes also referred to as a connection or session.
Page 4/9
OpenDPI Integration Manual
Install Wireshark
To test OpenDPI, please record a pcap file, for example using Wireshark. Wireshark can be installed under
Page 5/9
OpenDPI Integration Manual
detected protocols:
unknown packets: 70 bytes: 4556 flows: 26
HTTP packets: 2829 bytes: 2734479 flows: 2
NETBIOS packets: 27 bytes: 3692 flows: 5
ICMP packets: 6 bytes: 758 flows: 6
This output displays that 70 packets have been identified as “unknown”, 2829 packets as “HTTP”, 27 packets
as NETBIOS and 6 packets as ICMP in this trace.
Page 6/9
OpenDPI Integration Manual
OpenDPI Integration
Usage of include file
Only a single header file from the include directory must be included:
#include "ipq_api.h"
All other header files from the include directory must not be included.
Initialization
OpenDPI uses just one global structure which stores all settings and temporary variables for the packet
processing. It can be defined with:
static struct ipoque_detection_module_struct *ipoque_struct = NULL;
OpenDPI is designed to use custom optimized allocation and free function. This example uses two simple
malloc and free wrappers for both functions.
static void *malloc_wrapper(unsigned long size)
{
return malloc(size);
}
As different systems have different timestamp resolutions, OpenDPI works with resolutions ranging from one
second to one millisecond. The recommended resolution is 1ms or 10ms.
The OpenDPI initialization requires the timestamp resolution as a parameter. The value is the timer resolution
per second. A millisecond resolution is used in this example. The value is:
static u32 ipq_tick_resolution = 1000; // use millisecond resolution in OpenDPI
OpenDPI is initialized by two calls. The first call will allocate and initialize the global OpenDPI structure with
the given data:
ipoque_struct = ipoque_init_detection_module(ipq_tick_resolution,
malloc_wrapper, NULL);
The last parameter is for debugging only and must be set to NULL. The initialization is the only place where a
memory allocation takes place. For performance and stability reasons, OpenDPI does not use any memory
allocations during packet processing.
The second call will activate a number of protocols for detection. For this call, a bitmask is required. Each bit is
used to activate (1) or deactivate (0) one protocol. To define a bitmask, use:
IPOQUE_PROTOCOL_BITMASK all;
Page 7/9
OpenDPI Integration Manual
ipoque_set_protocol_detection_bitmask2(ipoque_struct, &all);
Packet Processing
Packet information
OpenDPI needs access to the packet. The required components are:
! pointer to IP header
! accessible length of the packet starting from the IP header
! packet timestamp
The accessible length is needed to avoid invalid reads when the detection would rely on the IP total length
information, which could be wrong.
unsigned char *packet; // pointer to the packet at Layer 3 (IP)
unsigned short int packet_length; /* number of bytes which can be accessed
* from the packet pointer */
unsigned int timestamp; // arrival timestamp of the packet
Connection information
The state of every TCP and UDP flow is maintained along with internal values. The memory size of the state
buffer is fixed and depends on the number of compiled protocols.
In the following code example, the variable 'flow' will be used for the connection tracking:
void *flow; // pointer to the final state machine of the connection
The pointer must not be NULL for TCP/UDP traffic. For other traffic (where for example a connection tracking is
impossible), NULL is accepted.
Subscriber information
A similar state buffer is maintained for every subscriber. In most situations, a subscriber is identified by its
internal IP address. In this case, a memory buffer for every internal IP address must be maintained.
OpenDPI is designed to work in different network situations. There are two different situations for the subscriber
mapping.
In an access gateway situation, every packet belongs to one subscriber. The subscriber is either the sender or
Page 8/9
OpenDPI Integration Manual
the receiver of the packet. In this case, either the source or the destination subscriber is known.
In a non!access gateway, every packet could belong to up to 2 subscribers. This happens when one subscriber
is the sender while the other is the receiver. In this case, both subscribers can be passed to OpenDPI.
In the following code example, the variable 'src' and 'dst' will be used for the sender and receiver subscriber.
void *src; // pointer to the final state machine of the sender subscriber
void *dst; // pointer to the final state machine of the dest subscriber
The required size for each element is the return value of a built!in function in OpenDPI:
unsigned int ipoque_detection_get_sizeof_ipoque_id_struct(void);
In an access gateway situation where only one subscriber is required, either 'src' or 'dst' can be NULL.
The returned protocol is one protocol from the protocol list in 'include/ipq_protocols_osdpi.h'.
As an example, the returned protocol can be printed to the console with:
static const char *protocol_long_str[] = { IPOQUE_PROTOCOL_LONG_STRING };
printf(“Packet has protocol: %s\n”, protocol_long_str[protocol]);
Termination
OpenDPI is terminated by a single call, which frees the memory of the detection structure:
ipoque_exit_detection_module(ipoque_struct, free_wrapper);
Page 9/9