def __init__(self, ip=None, mac=None): super(Host, self).__init__(n_tips=1) self.tip = self.tips[0] if mac is None: mac = self.index + 1 if ip is None: ip = '1.0.0.{}'.format(self.index + 1) # physical layer - frame delimiter self.delimiter = BitDelimiter(self.tip) # link layer - flow control self.framer = Framer(self.delimiter, mac_to_bytes(mac)) # network layer - ARP self.packeter = Packeter(self.framer, ip_from_str(ip))
def l2send(self, data, to): self.framer.send(data, mac_to_bytes(to))
def mac(self, val): self.framer.mac = mac_to_bytes(val)