match = self.packet_regex.search(self.buffer)
if match and match.groups():
    groups = match.groups()
if ord(groups[1]) - 4 == len(groups[4]) + len(groups[5]) + len(groups[6]):
    pass
python regex use capture group to define another groups length { }