API Documentation

Botnet Basic Command Meta Description

class core.CMD(desc=None)

Command Meta Description. Define a set of commands that can be run.

dispatcher(sock, data)

data may contain one or more command Args:

  • sock: the socket that receive the data.

  • data: data is a sequence of json encode string. “event” key

    is required and is the name of the command that will be run a example is: {“password”: [“1234”], “event”: [“verify_master”]}

Returns:
None
Raises:
UnknownEventException
install(node)

install the command set to node.

start()

start the command set, execuate the start_action specifed in desc

class core.Server.ServerCMD(desc={'srv_port': 3333, 'request_timeout': 10, 'initial': 'waiting', 'start_action': 'initialize', 'srv_addr': '127.0.0.1'})[source]
dispatcher(sock, data)[source]

just enclosure of CMD dispatcher

echo_bots(sock, data)[source]

send echo command to all bots

initialize()[source]

initialize the server. If the server is real node. It will call Accept method in blocking way. if the server is simulated. It will set the SetAcceptCallBack

recv_request_conn(client_sock, address)[source]

call back for receive the connection request

verify_master(sock, data)[source]

verify the identity of the master

class core.Client.ClientCMD(desc=None)[source]

Client Command Meta Description define the handle of each transition each CMD should claim the basic function set a node much provide

connection_refused()[source]

call back when the connection request has been refused by server

echo(sock, data)[source]

echo the message

recv_ack()[source]

call back when receive ack message from server

recv_disconn_req(sock)[source]

call back when receive the disconnect request from server

request_connect()[source]

request a connection to server

request_time_out()[source]

call back when the connection request has time out

BaseNode

class core.BaseNode.BaseNode[source]

Virtual Base Class For all nodes All Type of Nodes Should Implment API in this abstract first

accept(sock)[source]

accept from the sock, will return the accepted socket

bind(sock, port)[source]

bind sock to port

client_socks[source]

all sockets whose type is client

close(sock)[source]

close the sock

close_socks(socks_seq_set, _type='client')[source]

sock_seq_set is the sequence of socks in this type of sock. for example, if _type = ‘client’, socks_seq_set = [0], then the first client sock need to be closed.

connect(sock, addr_port)[source]

connect the sock to the server with address and port specfied by addr_port

create_sock(desc)[source]

create_sock with parameter specified by desc, desc can be the address and port it tries to connect and the type of the connection

listen(sock, backlog)[source]

listen to the sock. backlog is the max number of connection it can maintain

now[source]

get current time, either simulation time or real time.

ping(sock, data, threaded=False)[source]

send ping traffic using sock and the server information is stored in data. A new thread will be created if the threaded is true

recv(sock, bufsize, dispatcher, threaded=False)[source]

receive some data from sock, - bufsize is the max size for the buffer. - dispatecher is a function handler that will manipulate the data - threaded if it is true a new thread wiill be created to avoid

blocking the main process. Only real node suppport this. in sim Node and netns3 node, threading is not allowed.
send(sock, data)[source]

set data from sock.

sendto(sock, data, addr, port)[source]

send data from sock to addr and port, use UDP protocol

set_master_sock(sock)[source]

set the sock to be the master sock. If a sock is master sock, then node will for commands from the master socks

sleep(t, call_back=None)[source]

sleep the node for a t seconds, if call_back is specified, it will be called after node wake from sleep

start()[source]

start the node

stop_app(sock, app_name)[source]

stop the app run on sock with app_name

Emulation

This section contains the functions for emulation support.

Simulation

Topology Mode

class core.ns3.Topology.TopologyReader(fileName=None, NodeCreator=<type 'network.Node'>)[source]

base class for Topology Reader

class core.ns3.Topology.InetTopologyReader(fileName=None, NodeCreator=<type 'network.Node'>)[source]

reader for inet topology generator file

class core.ns3.Topology.TopologyReaderHelper[source]

This is python implementation of NS3 topology-reader module pybindgen is far from mature and cannot generate usable python binding for this module, so I simply reimplement it in python.

class core.ns3.Topology.ComplexNet(NodeCreator, net_settings, *args, **kwargs)[source]

Complex Network contains different types of Subnets.

For example, some parts is Csma Network, which some other parts is PointToPoint Network.

class core.ns3.Topology.InetTopologyReader(fileName=None, NodeCreator=<type 'network.Node'>)[source]

reader for inet topology generator file

class core.ns3.Topology.ManualTopologyNet(_input, _format, NodeCreator, *args, **kwargs)[source]

Topology network with manual ip settings

init_net_device(net_settings, *args, **kwargs)[source]

Initial the ip address and network devices

search_ipi(addr)[source]

search the ip interface from addr

class core.ns3.Topology.TopologyNet(_input, _format, NodeCreator, *args, **kwargs)[source]

Load Topology File and Contruct the Network Accordingly

Construct Point to Point Link in the Network

init_net_device(*args, **kwargs)[source]

Initial the ip address and network devices

install_stack(routing_helper_list=None)[source]

Install Internet Stack

load_file()[source]

Load Topology File

class core.ns3.Topology.TopologyReader(fileName=None, NodeCreator=<type 'network.Node'>)[source]

base class for Topology Reader

class core.ns3.Topology.TopologyNet(_input, _format, NodeCreator, *args, **kwargs)[source]

Load Topology File and Contruct the Network Accordingly

init_link()[source]

Construct Point to Point Link in the Network

init_net_device(*args, **kwargs)[source]

Initial the ip address and network devices

install_stack(routing_helper_list=None)[source]

Install Internet Stack

load_file()[source]

Load Topology File

Netns3 Mode

This section contains the functions for NS3 support.

class core.ns3.Experiment.ImalseExperiment

Base class for all ImalseExperiment

get_node(i)

get ith nodes

node_run(node, *args, **kwargs)

run a command on a specific node

print_srv_addr()

print out the address of the server

start_nodes()

specify when each node should start

Pure Simulation Mode

class core.ns3.Node.ImalseNetnsSimNode(name=None, *args, **kwargs)

Simulated Node in NS3 Adapted for Imalse Simulation

static add_msg(p, msg)

add message to pacekt

static add_msg_deprec(p, msg)

encode the message to the packet

after(t, method, *args, **kwargs)

schedue a even after t seconds

connect(sock, addr_port)

Will set Connect callback function. If succeeded, self.recv will be called. otherwise the sock will be closed

dispatcher(sock)

node level dispatcher, it will read data from the socket, parse the data into approariate format and handle the data to cmd.dispatcher()

static get_msg(p)

get message from the pacetk

static get_msg_deprec(p)

get_msg and add_msg are two hack function

ping(sock, data, threaded)

The attributes you can customize

StartTime StopTime Remote: The address of the machine we want to ping. Verbose: Produce usual output. Interval: Wait interval seconds between sending each packet. Size: The number of data bytes to be sent, real packet will

be 8 (ICMP) + 20 (IP) bytes longer.
class core.ns3.Experiment.ImalsePureSimExperiment

Pure Sim Experiemtn Doesn’t depend on netns3 can run in simulated time

static event(time, func, *args, **kwds)

schedule an event to simulator

Contents:

Indices and tables

Table Of Contents

This Page