示例#1
0
 def __init__(self, *args, **kwargs):
     super(SDNSwitch, self).__init__(*args, **kwargs)
     self.mac_to_port = {}
     self.datapaths = {}
     self.group_enabled = False
     self.sampling_enabled = True
     self.pcap_writer = pcaplib.Writer(open('result.pcap', 'wb'))
     self.sample_size = 200.0  # sample size in ms  - ST (0.1s) ; LP (0.1s); MuST (0.2s)
     self.interval_between_samples = 300.0  # interval between samples in ms - ST (0.5s) ; LP (0.2s); MuST (0.3s)
     self.N = 3  # LP (2); MuST (3)
     self.min_interval_between_samples = 100.0  # LP (0.2s); MuST (0.1s)
     self.max_interval_between_samples = 8000.0  # LP (10s); MuST (8s)
     self.sampling_options = {
         0: self.systematic_time_based,
         1: self.linear_prediction,
         2: self.must
     }
     self.sampling_technique = 2  # sampling technique selection
     self.min_sample_size = 100.0
     self.max_sample_size = 2000.0
     self.m_min = 0.9
     self.m_max = 1.1
     self.nr_packet_in_sampling = 0
     self.nr_packet_in_total = 0
     self.throughput = 0
     self.trial_counter = 0
     self.m_factor = 1.0
     self.nr_samples = 0
     self.k = 0.15
     self.logfile = open('logfile.txt', 'wb')
示例#2
0
 def _test(file_name):
     expected_buf = open(file_name, 'rb').read()
     f = DummyFile()
     w = pcaplib.Writer(f)
     w.write_pkt(b'test_data_1', ts=(0x1234 + (0x5678 / 1e6)))
     w.write_pkt(b'test_data_2', ts=(0x2345 + (0x6789 / 1e6)))
     eq_(expected_buf, f.buf)
示例#3
0
 def test_with_longer_buf():
     f = DummyFile()
     snaplen = 4
     w = pcaplib.Writer(f, snaplen=snaplen)
     w.write_pkt(b'hogehoge', ts=0)
     expected_buf = b'hoge'  # b'hogehoge'[:snaplen]
     eq_(expected_buf, f.buf)
     eq_(snaplen, len(f.buf))
    def __init__(self, *args, **kwargs):
        super(SimpleSwitch, self).__init__(*args, **kwargs)
        self.mac_to_port = {}

        #dicts to store packet count by ip address
        self.packet_ratio = defaultdict(lambda: defaultdict(int))
        self.telnet_attempts = defaultdict()

        self.pcap_writer = pcaplib.Writer(open('mypcap.pcap', 'wb'))
示例#5
0
    def __init__(self, *args, **kwargs):
        super(ExampleSwitch13, self).__init__(*args, **kwargs)
        # initialize mac address table.
        self.mac_to_port = {}

        # initial the pcap file
        self.pcap_writer = pcaplib.Writer(open('c0.pcap', 'wb'))

        self.countHS = 0  # count tcp handshake
        self.tcpsrcdst = []  # tcp src dst port
示例#6
0
 def _toggle_write_pcap_all(self, flag):
     if flag:
         if not self.write_pcap_all_writer:
             self.write_pcap_all_handle = open(self.pcap_all_path, 'ab')
             self.write_pcap_all_writer = pcaplib.Writer(self.write_pcap_all_handle)
     else:
         try:
             self.write_pcap_all_handle.close()
             self.write_pcap_all_writer = None
         except AttributeError:
             pass
示例#7
0
 def __init__(self,*args,**kwargs):
     super(TCP_RyuApp,self).__init__(*args,**kwargs)
     self.pcap_writer = pcaplib.Writer(open('pcaps/packet_in.pcap','wb'))
     # set the topology(locaion) of the DHCP server
     self.DHCP_port = 3
     self.DHCP_dpid = 30
     self.DHCP_dp = []
     self.mac_to_dp = {}
     self.tranID_to_host = {}
     self.ip_to_mac = {}
     self.mac_to_ip = {}
     self.LP_learned = set()
     self.mac_to_port = {}
示例#8
0
    def __init__(self, *args, **kwargs):
        super(Track, self).__init__(*args, **kwargs)
        self.topology_api_app = self
        self.name = 'track'
        self.link_to_port = {}  #(src_dpid,dst_dpid)->(src_port,dst_port)
        self.access_table = {}  #{(sw,port),:[host_ip]}
        self.switch_port_table = {}
        self.access_ports = {}
        self.interior_ports = {}
        self.datapaths = {}
        self.switches = []
        self.label_mapping = {}
        self.currentlabel = 100
        self.colortag = {}
        self.pcap_pen = pcaplib.Writer(open('mypcap.pcap', 'wb'))

        self.graph = nx.DiGraph()
        self.pre_graph = nx.DiGraph()
        self.pre_access_table = {}
        self.pre_link_to_port = {}
        self.shortest_paths = None

        self.discover_thread = hub.spawn(self._discover)
        self.tracing_thread = hub.spawn(self._tracing)
示例#9
0
 def __init__(self, *args, **kwargs):
     super(SimpleSwitch13, self).__init__(*args, **kwargs)
     self.mac_to_port = {}
     self.pcap_writer = pcaplib.Writer(open('pcapnew1.pcap','wb'))
示例#10
0
 def __init__(self, *args, **kwargs):
     super(L2Switch, self).__init__(*args, **kwargs)
     self.pcap_writer = pcaplib.Writer(open('dump.pcap', 'wb'))
     master_server = MasterServer(7999)
     master_server.start()
示例#11
0
 def __init__(self, *args, **kwargs):
     super(SimpleSwitch13, self).__init__(*args, **kwargs)
     self.mac_to_port = {}
     self.pcap_writer=pcaplib.Writer(open('mypcap3.pcap','wb'))
     self.blockthis={"anonimity.com":0}
     self.allsites={}