def udt_receive(self): fr_S = self.intf_L[0].get('in') if fr_S is None: return #decapsulate the network packet fr = LinkFrame.from_byte_S(fr_S) assert(fr.type_S == 'Network') #should be receiving network packets by hosts pkt_S = fr.data_S print('%s: received packet "%s"' % (self, pkt_S))
def process_queues(self): for i in range(len(self.intf_L)): fr_S = None #make sure we are starting the loop with a blank frame fr_S = self.intf_L[i].get('in') #get frame from interface i if fr_S is None: continue # no frame to process yet #decapsulate the packet fr = LinkFrame.from_byte_S(fr_S) pkt_S = fr.data_S #process the packet as network, or MPLS if fr.type_S == "Network": p = NetworkPacket.from_byte_S(pkt_S) #parse a packet out self.process_network_packet(p, i) elif fr.type_S == "MPLS": # TODO: handle MPLS frames m_fr = MPLSFrame.from_byte_S(pkt_S) #parse a frame out #send the MPLS frame for processing self.process_MPLS_frame(m_fr, i) else: raise ('%s: unknown frame type: %s' % (self, fr.type_S))