Exemplo n.º 1
0
 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))
Exemplo n.º 2
0
    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('received packet = %s' % str(pkt_S))

        print("\n(Host %s) received message: %s" % (str(self), pkt_S))

        return pkt_S
Exemplo n.º 3
0
 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":
             m_fr = MPLSFrame.from_byte_S(pkt_S)  #parse a frame out
             self.process_MPLS_frame(m_fr, i)
         else:
             raise ('%s: unknown frame type: %s' % (self, fr.type))
Exemplo n.º 4
0
 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
             print(pkt_S)
             m_fr = MPLSFrame.from_byte_S(pkt_S)  #parse a frame out
             #for now, we just relabel the packet as an MPLS frame without encapsulation
             print("m_fr from process_queues    ", m_fr)
             #m_fr = p
             #send the MPLS frame for processing
             self.process_MPLS_frame(m_fr, i)
         else:
             raise ('%s: unknown frame type: %s' % (self, fr.type))