@SuppressWarnings("unchecked")
    public ItemPDU<V> fromBuffer(ByteBuffer buf) throws Exception {        
        SyncPeer from;
        SyncPeer to;
        byte[]   setID;
        long     tag;
        
        int i         = buf.getInt();
        byte[] magic  = new byte[i]; 
        buf.get(magic, 0, i);     
        if (!Arrays.equals(MAGIC, magic)) {System.out.println("Magic failure"); return null;}
        if (version != buf.get()) {System.out.println("Wrong version"); return null;}        
        i             = buf.getInt();
        byte[] faddr  = new byte[i];
        buf.get(faddr, 0, i);
        InetAddress f = InetAddress.getByAddress(faddr);
        int fport     = buf.getInt();       
        from          = new SyncPeer(f, fport);
        i             = buf.getInt();
        byte[] taddr  = new byte[i];
        buf.get(taddr, 0, i);
        InetAddress t = InetAddress.getByAddress(taddr);
        int tport     = buf.getInt(); 
        to            = new SyncPeer(t, tport);
        i             = buf.getInt();
        setID         = new byte[i];
        buf.get(setID, 0, i);
        tag           = buf.getLong();
        i             = buf.getInt();        
        byte[] itemBytes = new byte[i];
        buf.get(itemBytes, 0, i);
        
        ByteArrayInputStream bis = new ByteArrayInputStream(itemBytes);
        ObjectInput in = null;
        Object item;
        try {
          in = new ObjectInputStream(bis);
          item = in.readObject(); 
          bis.close();
          in.close();
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
        
        this.from = from;
        this.to = to;
        this.setID = setID;
        this.tag = tag;
        this.item = (V) item;
        return this;
    }