Wiki

Clone wiki

aiengine / InteractiveShellPython

Interactive shell

One of the functionalities of the engine is the ability to interact with on real time without unload the main script. Lets see how works:

Create a new PacketDispatcher and the IPv6 stack and connect them.

import pyaiengine

if __name__ == '__main__':

    st = pyaiengine.StackLanIPv6()
Allocate the maximum number of flows on the stack
    st.udp_flows = 163840
    st.tcp_flows = 163840
The PacketDispatcher enables a python shell in order to give back the control of the script to the user, so the user can interact with the system as wants.
    with pyaiengine.PacketDispatcher("eth0") as pd:
        pd.stack = st
        pd.enable_shell = True
        pd.run()
Once the script executes the method run of the PacketDispatcher and have the shell enable, the user will see a different prompt.
    AIEngine 1.2 shell
    ==> [02/15/14 22:57:12] Processing packets from device eth0
    ==> print pd
    PacketDispatcher(0x19b15f0) statistics
    Connected to Lan IPv6 network stack
    Total packets:                  77
    Total bytes:                  5914

Updated