# ossincn/alienvaultossim2 architecture

> Architecture diagram of the GitHub repository ossincn/alienvaultossim2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ossincn/alienvaultossim2
- Repository: https://github.com/ossincn/alienvaultossim2

## Overview

##### Project type and purpose
- From the file tree and README (“alienvaultossim2”), this is an open-source, C-based Security Information and Event Management (SIEM) engine (the OSSIM 2 core).
- It ingests security events (e.g., from Snort, SMTP, network packets), classifies and correlates them, and stores results in a database, supporting plugins for extensibility.

##### File structure
- Top-level C modules:
- sim-server.c/h         – the central “engine” / main daemon
- sim-sensor.c/h         – captures raw events (Snort, SMTP, network)
- sim-event.c/h          – event objects & lifecycle
- sim-classification.c/h – classifies events into categories and severities
- sim-correlators (sim-net-level, sim-host-level) – correlates events across hosts or networks
- sim-database.c/h       – persistence layer (likely MySQL)
- sim-plugin*.c/h        – plugin API (SID, state, generic plugin hooks)
- sim-config.c/h & sim-xml-* – XML-driven configuration loader and directive parser
- sim-scheduler.c/h      – schedules periodic tasks (e.g., cleanup, stats)
- sim-log.c/h            – logging subsystem
- sim-command.c/h        – CLI or remote control command interface
- Support libraries: libos-sim.h, os-sim.h
- Build infrastructure: Makefile.*, autogen.sh, configure.ac, config.dtd

##### README for additional insights
- The README is terse, so the primary architectural cues come from file names and typical OSSIM design:
- Modular, monolithic C daemon with plugin extensibility
- Event ingestion → classification → correlation → storage → notification/alerting

##### Detail
- Every major sim-*.c module by grouping them within the appropriate layer (e.g., list “sim-host-level, sim-net-level” under Correlation)

## Diagram (Mermaid)

```mermaid
flowchart TD
    title["OSSIM2 Core Architecture\nVersion: 2.0\nDate: 2024-06\nAuthor: AI Architect"]

    subgraph "Ingestion Layer"
        direction TB
        ING1["sim-sensor.c/h"]:::ingestion
        ING2["sim-snort.c/h"]:::ingestion
        ING3["sim-smtp.c/h"]:::ingestion
        ING4["sim-packet.c/h"]:::ingestion
        ING5["sim-net.c/h"]:::ingestion
        ING6["sim-inet.c/h"]:::ingestion
    end

    subgraph "Core Engine"
        direction TB
        CORE1["sim-server.c/h"]:::core
        CORE2["sim-event.c/h"]:::core
        CORE3["sim-classification.c/h"]:::core
        CORE4["sim-host-level.c/h"]:::core
        CORE5["sim-net-level.c/h"]:::core
        CORE6["sim-scheduler.c/h"]:::core
        CORE7["sim-log.c/h"]:::core
        CORE8["sim-command.c/h"]:::core
    end

    subgraph "Plugin Framework"
        direction TB
        PLG1["sim-plugin.c/h"]:::plugin
        PLG2["sim-plugin-sid.c/h"]:::plugin
        PLG3["sim-plugin-state.c/h"]:::plugin
    end

    subgraph "Configuration & Rules"
        direction TB
        CFG1["sim-config.c/h"]:::config
        CFG2["sim-xml-config.c/h"]:::config
        CFG3["sim-xml-directive.c/h"]:::config
        CFG4["sim-directive.c/h"]:::config
        CFG5["sim-directive-group.c/h"]:::config
    end

    subgraph "Data Layer"
        direction TB
        DATA["sim-database.c/h"]:::data
    end

    subgraph "External Integrations"
        direction TB
        EXT1["Snort Engine"]:::external
        EXT2["SMTP Server"]:::external
        EXT3["Network Tap"]:::external
        EXT4["MySQL DB"]:::external
    end

    %% Data flows
    EXT1 -->|EventRecord| ING2
    EXT2 -->|EventRecord| ING3
    EXT3 -->|EventRecord| ING4
    ING1 -->|RawEvent| CORE1
    ING2 -->|RawEvent| CORE1
    ING3 -->|RawEvent| CORE1
    ING4 -->|RawEvent| CORE1
    ING5 -->|RawEvent| CORE1
    ING6 -->|RawEvent| CORE1

    CORE1 -->|EventRecord| CORE2
    CORE2 -->|ClassifiedEvent| CORE3
    CORE3 -->|TaggedEvent| CORE5
    CORE3 -->|TaggedEvent| CORE4
    CORE4 -->|CorrelatedEvent| CORE1
    CORE5 -->|CorrelatedEvent| CORE1

    CORE1 -->|"Persist"| DATA
    DATA -->|Ack| CORE1

    CORE1 -->|HookCall| PLG1
    PLG1 -->|PluginResult| CORE1
    CORE1 -->|HookCall| PLG2
    CORE1 -->|HookCall| PLG3

    CORE1 -->|LoadOnStart/Reload| CFG1
    CORE1 -->|LoadOnStart/Reload| CFG2
    CORE1 -->|LoadOnStart/Reload| CFG3
    CORE1 -->|LoadOnStart/Reload| CFG4
    CORE1 -->|LoadOnStart/Reload| CFG5

    CORE6 -->|TimerEvent| CORE1
    CORE6 -->|TimerEvent| PLG1

    CORE8 -->|AdminCmd| CORE1
    CORE1 -->|CmdResponse| CORE8

    %% External DB flow
    DATA -->|WriteEvent| EXT4
    EXT4 -->|DBAck| DATA

    %% Click Events
    click ING1 "https://github.com/ossincn/alienvaultossim2/blob/main/sim-sensor.c"
    click ING2 "https://github.com/ossincn/alienvaultossim2/blob/main/sim-snort.c"
    click ING3 "https://github.com/ossincn/alienvaultossim2/blob/main/sim-smtp.c"
    click ING4 "https://github.com/ossincn/alienvaultossim2/blob/main/sim-packet.c"
    click ING5 "https://github.com/ossincn/alienvaultossim2/blob/main/sim-net.c"
    click ING6 "https://github.com/ossincn/alienvaultossim2/blob/main/sim-inet.c"
    click CORE1 "https://github.com/ossincn/alienvaultossim2/blob/main/sim-server.c"
    click CORE2 "https://github.com/ossincn/alienvaultossim2/blob/main/sim-event.c"
    click CORE3 "https://github.com/ossincn/alienvaultossim2/blob/main/sim-classification.c"
    click CORE4 "https://github.com/ossincn/alienvaultossim2/blob/main/sim-host-level.c"
    click CORE5 "https://github.com/ossincn/alienvaultossim2/blob/main/sim-net-level.c"
    click CORE6 "https://github.com/ossincn/alienvaultossim2/blob/main/sim-scheduler.c"
    click CORE7 "https://github.com/ossincn/alienvaultossim2/blob/main/sim-log.c"
    click CORE8 "https://github.com/ossincn/alienvaultossim2/blob/main/sim-command.c"
    click PLG1 "https://github.com/ossincn/alienvaultossim2/blob/main/sim-plugin.c"
    click PLG2 "https://github.com/ossincn/alienvaultossim2/blob/main/sim-plugin-sid.c"
    click PLG3 "https://github.com/ossincn/alienvaultossim2/blob/main/sim-plugin-state.c"
    click CFG1 "https://github.com/ossincn/alienvaultossim2/blob/main/sim-config.c"
    click CFG2 "https://github.com/ossincn/alienvaultossim2/blob/main/sim-xml-config.c"
    click CFG3 "https://github.com/ossincn/alienvaultossim2/blob/main/sim-xml-directive.c"
    click CFG4 "https://github.com/ossincn/alienvaultossim2/blob/main/sim-directive.c"
    click CFG5 "https://github.com/ossincn/alienvaultossim2/blob/main/sim-directive-group.c"
    click DATA "https://github.com/ossincn/alienvaultossim2/blob/main/sim-database.c"

    %% Styles
    classDef ingestion fill:#E0F7FA,stroke:#00796B,color:#004D40;
    classDef core fill:#BBDEFB,stroke:#0D47A1,color:#0D47A1;
    classDef plugin fill:#C8E6C9,stroke:#1B5E20,color:#1B5E20;
    classDef config fill:#FFF9C4,stroke:#F57F17,color:#F57F17;
    classDef data fill:#FFE0B2,stroke:#E65100,color:#E65100;
    classDef external fill:#E0E0E0,stroke:#757575,color:#424242;
```
