test_class.file: src/agents/apps/floodlight/floodlight-1.0/src/test/java/net/floodlightcontroller/packet/UDPTest.java
test_class.identifier: UDPTest
test_case.body: @Test
      public void testSerialize() {
          byte[] expected = new byte[] { 0x45, 0x00, 0x00, 0x1d, 0x56, 0x23,
                  0x00, 0x00, (byte) 0x80, 0x11, 0x48, 0x7f, (byte) 0xc0,
                  (byte) 0xa8, 0x01, 0x02, 0x0c, (byte) 0x81, (byte) 0xce, 0x02,
                  0x17, (byte) 0xe1, 0x04, 0x5f, 0x00, 0x09, 0x46, 0x6e,
                  0x01 };
          IPacket packet = new IPv4()
              .setIdentification((short) 22051)
              .setTtl((byte) 128)
              .setSourceAddress("192.168.1.2")
              .setDestinationAddress("12.129.206.2")
              .setPayload(new UDP()
                              .setSourcePort((short) 6113)
                              .setDestinationPort((short) 1119)
                              .setPayload(new Data(new byte[] {0x01}))
                         );
          byte[] actual = packet.serialize();
          assertTrue(Arrays.equals(expected, actual));
      }
test_case.class_method_signature: UDPTest.testSerialize()
test_case.full_signature: @Test public void testSerialize()
test_case.identifier: testSerialize
test_case.invocations: setPayload setDestinationAddress setSourceAddress setTtl setIdentification setPayload setDestinationPort setSourcePort serialize assertTrue equals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testSerialize()
focal_class.declarator: decodeMap
focal_class.modifier: public static
focal_class.original_string: public static Map<TransportPort, Class<? extends IPacket>> decodeMap;
focal_class.type: Map<TransportPort, Class<? extends IPacket>>
focal_class.var_name: decodeMap
focal_class.declarator: DHCP_CLIENT_PORT = TransportPort.of(68)
focal_class.modifier: public static final
focal_class.original_string: public static final TransportPort DHCP_CLIENT_PORT = TransportPort.of(68);
focal_class.type: TransportPort
focal_class.var_name: DHCP_CLIENT_PORT
focal_class.declarator: DHCP_SERVER_PORT = TransportPort.of(67)
focal_class.modifier: public static final
focal_class.original_string: public static final TransportPort DHCP_SERVER_PORT = TransportPort.of(67);
focal_class.type: TransportPort
focal_class.var_name: DHCP_SERVER_PORT
focal_class.declarator: sourcePort
focal_class.modifier: protected
focal_class.original_string: protected TransportPort sourcePort;
focal_class.type: TransportPort
focal_class.var_name: sourcePort
focal_class.declarator: destinationPort
focal_class.modifier: protected
focal_class.original_string: protected TransportPort destinationPort;
focal_class.type: TransportPort
focal_class.var_name: destinationPort
focal_class.declarator: length
focal_class.modifier: protected
focal_class.original_string: protected short length;
focal_class.type: short
focal_class.var_name: length
focal_class.declarator: checksum
focal_class.modifier: protected
focal_class.original_string: protected short checksum;
focal_class.type: short
focal_class.var_name: checksum
focal_class.file: src/agents/apps/floodlight/floodlight-1.0/src/main/java/net/floodlightcontroller/packet/UDP.java
focal_class.identifier: UDP
focal_class.class_method_signature: UDP.getSourcePort()
focal_class.full_signature: public TransportPort getSourcePort()
focal_class.identifier: getSourcePort
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: TransportPort
focal_class.signature: TransportPort getSourcePort()
focal_class.class_method_signature: UDP.setSourcePort(TransportPort sourcePort)
focal_class.full_signature: public UDP setSourcePort(TransportPort sourcePort)
focal_class.identifier: setSourcePort
focal_class.modifiers: public
focal_class.parameters: (TransportPort sourcePort)
focal_class.return: UDP
focal_class.signature: UDP setSourcePort(TransportPort sourcePort)
focal_class.class_method_signature: UDP.setSourcePort(short sourcePort)
focal_class.full_signature: public UDP setSourcePort(short sourcePort)
focal_class.identifier: setSourcePort
focal_class.modifiers: public
focal_class.parameters: (short sourcePort)
focal_class.return: UDP
focal_class.signature: UDP setSourcePort(short sourcePort)
focal_class.class_method_signature: UDP.getDestinationPort()
focal_class.full_signature: public TransportPort getDestinationPort()
focal_class.identifier: getDestinationPort
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: TransportPort
focal_class.signature: TransportPort getDestinationPort()
focal_class.class_method_signature: UDP.setDestinationPort(TransportPort destinationPort)
focal_class.full_signature: public UDP setDestinationPort(TransportPort destinationPort)
focal_class.identifier: setDestinationPort
focal_class.modifiers: public
focal_class.parameters: (TransportPort destinationPort)
focal_class.return: UDP
focal_class.signature: UDP setDestinationPort(TransportPort destinationPort)
focal_class.class_method_signature: UDP.setDestinationPort(short destinationPort)
focal_class.full_signature: public UDP setDestinationPort(short destinationPort)
focal_class.identifier: setDestinationPort
focal_class.modifiers: public
focal_class.parameters: (short destinationPort)
focal_class.return: UDP
focal_class.signature: UDP setDestinationPort(short destinationPort)
focal_class.class_method_signature: UDP.getLength()
focal_class.full_signature: public short getLength()
focal_class.identifier: getLength
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: short
focal_class.signature: short getLength()
focal_class.class_method_signature: UDP.getChecksum()
focal_class.full_signature: public short getChecksum()
focal_class.identifier: getChecksum
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: short
focal_class.signature: short getChecksum()
focal_class.class_method_signature: UDP.setChecksum(short checksum)
focal_class.full_signature: public UDP setChecksum(short checksum)
focal_class.identifier: setChecksum
focal_class.modifiers: public
focal_class.parameters: (short checksum)
focal_class.return: UDP
focal_class.signature: UDP setChecksum(short checksum)
focal_class.class_method_signature: UDP.resetChecksum()
focal_class.full_signature: @Override public void resetChecksum()
focal_class.identifier: resetChecksum
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void resetChecksum()
focal_class.class_method_signature: UDP.serialize()
focal_class.full_signature: public byte[] serialize()
focal_class.identifier: serialize
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: byte[]
focal_class.signature: byte[] serialize()
focal_class.class_method_signature: UDP.hashCode()
focal_class.full_signature: @Override public int hashCode()
focal_class.identifier: hashCode
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int hashCode()
focal_class.class_method_signature: UDP.equals(Object obj)
focal_class.full_signature: @Override public boolean equals(Object obj)
focal_class.identifier: equals
focal_class.modifiers: @Override public
focal_class.parameters: (Object obj)
focal_class.return: boolean
focal_class.signature: boolean equals(Object obj)
focal_class.class_method_signature: UDP.deserialize(byte[] data, int offset, int length)
focal_class.full_signature: @Override public IPacket deserialize(byte[] data, int offset, int length)
focal_class.identifier: deserialize
focal_class.modifiers: @Override public
focal_class.parameters: (byte[] data, int offset, int length)
focal_class.return: IPacket
focal_class.signature: IPacket deserialize(byte[] data, int offset, int length)
focal_class.superclass: extends BasePacket
focal_method.body: public byte[] serialize() {
          byte[] payloadData = null;
          if (payload != null) {
              payload.setParent(this);
              payloadData = payload.serialize();
          }
  
          this.length = (short) (8 + ((payloadData == null) ? 0
                  : payloadData.length));
  
          byte[] data = new byte[this.length];
          ByteBuffer bb = ByteBuffer.wrap(data);
  
          bb.putShort((short)this.sourcePort.getPort()); // UDP packet port numbers are 16 bit
          bb.putShort((short)this.destinationPort.getPort());
          bb.putShort(this.length);
          bb.putShort(this.checksum);
          if (payloadData != null)
              bb.put(payloadData);
  
          if (this.parent != null && this.parent instanceof IPv4)
              ((IPv4)this.parent).setProtocol(IpProtocol.UDP);
  
          // compute checksum if needed
          if (this.checksum == 0) {
              bb.rewind();
              int accumulation = 0;
  
              // compute pseudo header mac
              if (this.parent != null && this.parent instanceof IPv4) {
                  IPv4 ipv4 = (IPv4) this.parent;
                  accumulation += ((ipv4.getSourceAddress().getInt() >> 16) & 0xffff)
                          + (ipv4.getSourceAddress().getInt() & 0xffff);
                  accumulation += ((ipv4.getDestinationAddress().getInt() >> 16) & 0xffff)
                          + (ipv4.getDestinationAddress().getInt() & 0xffff);
                  accumulation += ipv4.getProtocol().getIpProtocolNumber() & 0xff;
                  accumulation += this.length & 0xffff;
              }
  
              for (int i = 0; i < this.length / 2; ++i) {
                  accumulation += 0xffff & bb.getShort();
              }
              // pad to an even number of shorts
              if (this.length % 2 > 0) {
                  accumulation += (bb.get() & 0xff) << 8;
              }
  
              accumulation = ((accumulation >> 16) & 0xffff)
                      + (accumulation & 0xffff);
              this.checksum = (short) (~accumulation & 0xffff);
              bb.putShort(6, this.checksum);
          }
          return data;
      }
focal_method.class_method_signature: UDP.serialize()
focal_method.full_signature: public byte[] serialize()
focal_method.identifier: serialize
focal_method.invocations: setParent serialize wrap putShort getPort putShort getPort putShort putShort put setProtocol rewind getInt getSourceAddress getInt getSourceAddress getInt getDestinationAddress getInt getDestinationAddress getIpProtocolNumber getProtocol getShort get putShort
focal_method.modifiers: public
focal_method.parameters: ()
focal_method.return: byte[]
focal_method.signature: byte[] serialize()