Skip to content

Commit

Permalink
Removed necessity for hard-coding IPs of host
Browse files Browse the repository at this point in the history
Fix for the TypeError
TypeError: 'module' object is not callable error happening because of call to pcap_to_ditg.
Removed necessity for hard-coding IPs of host
Clear a debug message
  • Loading branch information
prabodh1194 committed Feb 9, 2017
1 parent f3e1d00 commit dbf973f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 22 deletions.
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ Usage

::

Host,Start_row,End_row,Number
h1,1734,1902,169
h2,1528,1733,206
Host,Start_row,End_row,Number,IP
h1,1734,1902,169,10.0.0.1
h2,1528,1733,206,10.0.0.2
.
.
.
Expand Down
2 changes: 1 addition & 1 deletion examples/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def getArgParser():
'orig_ports': args.orig_ports,
}

pToD = pcap_to_ditg(
pToD = pcap_to_ditg.pcap_to_ditg(
args.pcap_file, # Pcap file to read
args.mapper_file, # File with mapping of IPs to topology hosts
args.list_file, # File with list of IPs
Expand Down
22 changes: 4 additions & 18 deletions pcap_to_ditg/pcap_to_ditg.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def __init__(self,
'end_time' : 30,
'ps_opts': '',
'orig_ports': False,
}
):
}
):
super(pcap_to_ditg, self).__init__()
self.pcap_file = pcap_file
self.mapper_file = mapper_file
Expand Down Expand Up @@ -113,21 +113,6 @@ def __addToFlows(self, key, timestamp, size, rp, L4type='TCP'):
l[3] = rp
self.__Flows[key] = l

@classmethod
def __getIpForHost(self, host):
if host == 'h1':
return '10.0.1.10'
elif host == 'h2':
return '10.0.1.20'
elif host == 'h3':
return '10.0.2.10'
elif host == 'h4':
return '10.0.2.20'
elif host == 'h5':
return '10.0.10.1'
elif host == 'h6':
return '10.0.5.2'

def __writeFlowToFile(self, key):
origSIP = self.__getSrcIPAddrFromKey(key)
origDIP = self.__getDstIPAddrFromKey(key)
Expand Down Expand Up @@ -198,6 +183,7 @@ def __readPartitions(self):
endPoints = []
endPoints.append(line.split(',')[1]) # start
endPoints.append(line.split(',')[2]) # end
endPoints.append(line.split(',')[4][:-1]) # ip
Partitions[host] = endPoints
return Partitions
except Exception, e:
Expand All @@ -213,7 +199,7 @@ def __generateMapper(self):
if os.path.exists(self.list_file):
for i in range(int(endPoints[0]), int(endPoints[1]) + 1):
ip = linecache.getline(self.list_file, i).strip().strip(',')
(self.__IpMapDict)[ip] = pcap_to_ditg.__getIpForHost(p)
(self.__IpMapDict)[ip] = endPoints[2]
else:
print('*** The file \'' + self.list_file + '\' could not be read\n')
raise IOError('The file \'' + self.list_file + '\' could not be read\n')
Expand Down

0 comments on commit dbf973f

Please sign in to comment.