diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/lcaf/LispCanonicalAddressFormatEnum.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/lcaf/LispCanonicalAddressFormatEnum.java
index b6cfa71..7191a2e 100644
--- a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/lcaf/LispCanonicalAddressFormatEnum.java
+++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/lcaf/LispCanonicalAddressFormatEnum.java
@@ -25,18 +25,19 @@
  * https://tools.ietf.org/html/draft-ietf-lisp-lcaf-22
  */
 public enum LispCanonicalAddressFormatEnum {
+    UNKNOWN(-1),                // Unknown Type
+    UNSPECIFIED(0),             // Unspecified Type
     LIST(1),                    // AFI LIST Type
     SEGMENT(2),                 // Instance ID Type
     AS(3),                      // AS Number Type
     APPLICATION_DATA(4),        // Application Data Type
+    GEO_COORDINATE(5),          // Geo Coordinate Type
     NAT(7),                     // NAT Traversal Type
     NONCE(8),                   // Nonce Locator Type
     MULTICAST(9),               // Multi-cast Info Type
     TRAFFIC_ENGINEERING(10),    // Explicit Locator Path Type
     SECURITY(11),               // Security Key Type
-    SOURCE_DEST(12),            // Source/Dest Key Type
-    UNSPECIFIED(0),             // Unspecified Type
-    UNKNOWN(-1);                // Unknown Type
+    SOURCE_DEST(12);            // Source/Dest Key Type
 
     private byte lispCode;
 
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/lcaf/LispGeoCoordinateLcafAddress.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/lcaf/LispGeoCoordinateLcafAddress.java
new file mode 100644
index 0000000..d70fd03
--- /dev/null
+++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/lcaf/LispGeoCoordinateLcafAddress.java
@@ -0,0 +1,505 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.lisp.msg.types.lcaf;
+
+import io.netty.buffer.ByteBuf;
+import org.onlab.util.ByteOperator;
+import org.onosproject.lisp.msg.exceptions.LispParseError;
+import org.onosproject.lisp.msg.exceptions.LispReaderException;
+import org.onosproject.lisp.msg.exceptions.LispWriterException;
+import org.onosproject.lisp.msg.types.LispAddressReader;
+import org.onosproject.lisp.msg.types.LispAddressWriter;
+import org.onosproject.lisp.msg.types.LispAfiAddress;
+
+import java.util.Objects;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Geo Coordinate type LCAF address class.
+ * <p>
+ * Geo Coordinate type is defined in draft-ietf-lisp-lcaf-22
+ * https://tools.ietf.org/html/draft-ietf-lisp-lcaf-22#page-11
+ * <p>
+ * <pre>
+ * {@literal
+ *  0                   1                   2                   3
+ *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |           AFI = 16387         |     Rsvd1     |     Flags     |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |   Type = 5    |     Rsvd2     |            Length             |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |N|     Latitude Degrees        |    Minutes    |    Seconds    |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |E|     Longitude Degrees       |    Minutes    |    Seconds    |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |                            Altitude                           |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |              AFI = x          |         Address  ...          |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * }</pre>
+ */
+public final class LispGeoCoordinateLcafAddress extends LispLcafAddress {
+
+    private final boolean north;
+    private final short latitudeDegree;
+    private final byte latitudeMinute;
+    private final byte latitudeSecond;
+    private final boolean east;
+    private final short longitudeDegree;
+    private final byte longitudeMinute;
+    private final byte longitudeSecond;
+    private final int altitude;
+    private final LispAfiAddress address;
+
+    /**
+     * Initializes geo coordinate type LCAF address.
+     *
+     * @param north           north flag
+     * @param latitudeDegree  latitude degree
+     * @param latitudeMinute  latitude minute
+     * @param latitudeSecond  latitude second
+     * @param east            east flag
+     * @param longitudeDegree longitude degree
+     * @param longitudeMinute longitude minute
+     * @param longitudeSecond longitude second
+     * @param altitude        altitude
+     * @param address         AFI address
+     */
+    private LispGeoCoordinateLcafAddress(boolean north, short latitudeDegree,
+                                         byte latitudeMinute, byte latitudeSecond,
+                                         boolean east, short longitudeDegree,
+                                         byte longitudeMinute, byte longitudeSecond,
+                                         int altitude, LispAfiAddress address) {
+        super(LispCanonicalAddressFormatEnum.GEO_COORDINATE);
+        this.north = north;
+        this.latitudeDegree = latitudeDegree;
+        this.latitudeMinute = latitudeMinute;
+        this.latitudeSecond = latitudeSecond;
+        this.east = east;
+        this.longitudeDegree = longitudeDegree;
+        this.longitudeMinute = longitudeMinute;
+        this.longitudeSecond = longitudeSecond;
+        this.altitude = altitude;
+        this.address = address;
+    }
+
+    /**
+     * Obtains north flag value.
+     *
+     * @return north flag value
+     */
+    public boolean isNorth() {
+        return north;
+    }
+
+    /**
+     * Obtains latitude degree.
+     *
+     * @return latitude degree
+     */
+    public short getLatitudeDegree() {
+        return latitudeDegree;
+    }
+
+    /**
+     * Obtains latitude minute.
+     *
+     * @return latitude minute
+     */
+    public byte getLatitudeMinute() {
+        return latitudeMinute;
+    }
+
+    /**
+     * Obtains latitude second.
+     *
+     * @return latitude second
+     */
+    public byte getLatitudeSecond() {
+        return latitudeSecond;
+    }
+
+    /**
+     * Obtains east flag value.
+     *
+     * @return east flag vlaue
+     */
+    public boolean isEast() {
+        return east;
+    }
+
+    /**
+     * Obtains longitude degree.
+     *
+     * @return longitude degree
+     */
+    public short getLongitudeDegree() {
+        return longitudeDegree;
+    }
+
+    /**
+     * Obtains longitude minute.
+     *
+     * @return longitude minute
+     */
+    public byte getLongitudeMinute() {
+        return longitudeMinute;
+    }
+
+    /**
+     * Obtains longitude second.
+     *
+     * @return longitude second
+     */
+    public byte getLongitudeSecond() {
+        return longitudeSecond;
+    }
+
+    /**
+     * Obtains altitude.
+     *
+     * @return altitude
+     */
+    public int getAltitude() {
+        return altitude;
+    }
+
+    /**
+     * Obtains AFI address.
+     *
+     * @return AFI address
+     */
+    public LispAfiAddress getAddress() {
+        return address;
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(north, latitudeDegree, latitudeMinute, latitudeSecond,
+                            east, longitudeDegree, longitudeMinute, longitudeSecond,
+                            altitude, address);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+
+        if (obj instanceof LispGeoCoordinateLcafAddress) {
+            final LispGeoCoordinateLcafAddress other =
+                    (LispGeoCoordinateLcafAddress) obj;
+            return Objects.equals(this.north, other.north) &&
+                    Objects.equals(this.latitudeDegree, other.latitudeDegree) &&
+                    Objects.equals(this.latitudeMinute, other.latitudeMinute) &&
+                    Objects.equals(this.latitudeSecond, other.latitudeSecond) &&
+                    Objects.equals(this.east, other.east) &&
+                    Objects.equals(this.longitudeDegree, other.longitudeDegree) &&
+                    Objects.equals(this.longitudeMinute, other.longitudeMinute) &&
+                    Objects.equals(this.longitudeSecond, other.longitudeSecond) &&
+                    Objects.equals(this.altitude, other.altitude) &&
+                    Objects.equals(this.address, other.address);
+        }
+        return false;
+    }
+
+    @Override
+    public String toString() {
+        return toStringHelper(this)
+                .add("north", north)
+                .add("latitude degree", latitudeDegree)
+                .add("latitude minute", latitudeMinute)
+                .add("latitude second", latitudeSecond)
+                .add("east", east)
+                .add("longitude degree", longitudeDegree)
+                .add("longitude minute", longitudeMinute)
+                .add("longitude second", longitudeSecond)
+                .add("altitude", altitude)
+                .add("address", address)
+                .toString();
+    }
+
+    public static final class GeoCoordinateAddressBuilder
+                        extends LcafAddressBuilder<GeoCoordinateAddressBuilder> {
+        private boolean north;
+        private short latitudeDegree;
+        private byte latitudeMinute;
+        private byte latitudeSecond;
+        private boolean east;
+        private short longitudeDegree;
+        private byte longitudeMinute;
+        private byte longitudeSecond;
+        private int altitude;
+        private LispAfiAddress address;
+
+        /**
+         * Sets north flag value.
+         *
+         * @param north north flag value
+         * @return GeoCoordinateAddressBuilder object
+         */
+        public GeoCoordinateAddressBuilder withIsNorth(boolean north) {
+            this.north = north;
+            return this;
+        }
+
+        /**
+         * Sets latitude degree.
+         *
+         * @param latitudeDegree latitude degree
+         * @return GeoCoordinateAddressBuilder object
+         */
+        public GeoCoordinateAddressBuilder withLatitudeDegree(short latitudeDegree) {
+            this.latitudeDegree = latitudeDegree;
+            return this;
+        }
+
+        /**
+         * Sets latitude minute.
+         *
+         * @param latitudeMinute latitude minute
+         * @return GeoCoordinateAddressBuilder object
+         */
+        public GeoCoordinateAddressBuilder withLatitudeMinute(byte latitudeMinute) {
+            this.latitudeMinute = latitudeMinute;
+            return this;
+        }
+
+        /**
+         * Sets latitude second.
+         *
+         * @param latitudeSecond latitude second
+         * @return GeoCoordinateAddressBuilder object
+         */
+        public GeoCoordinateAddressBuilder withLatitudeSecond(byte latitudeSecond) {
+            this.latitudeSecond = latitudeSecond;
+            return this;
+        }
+
+        /**
+         * Sets east flag value.
+         *
+         * @param east east flag
+         * @return GeoCoordinateAddressBuilder object
+         */
+        public GeoCoordinateAddressBuilder withIsEast(boolean east) {
+            this.east = east;
+            return this;
+        }
+
+        /**
+         * Sets longitude degree.
+         *
+         * @param longitudeDegree longitude degree
+         * @return GeoCoordinateAddressBuilder object
+         */
+        public GeoCoordinateAddressBuilder withLongitudeDegree(short longitudeDegree) {
+            this.longitudeDegree = longitudeDegree;
+            return this;
+        }
+
+        /**
+         * Sets longitude minute.
+         *
+         * @param longitudeMinute longitude minute
+         * @return GeoCoordinateAddressBuilder object
+         */
+        public GeoCoordinateAddressBuilder withLongitudeMinute(byte longitudeMinute) {
+            this.longitudeMinute = longitudeMinute;
+            return this;
+        }
+
+        /**
+         * Sets longitude second.
+         *
+         * @param longitudeSecond longitude second
+         * @return GeoCoordinateAddressBuilder object
+         */
+        public GeoCoordinateAddressBuilder withLongitudeSecond(byte longitudeSecond) {
+            this.longitudeSecond = longitudeSecond;
+            return this;
+        }
+
+        /**
+         * Sets altitude.
+         *
+         * @param altitude altitude
+         * @return GeoCoordinateAddressBuilder object
+         */
+        public GeoCoordinateAddressBuilder withAltitude(int altitude) {
+            this.altitude = altitude;
+            return this;
+        }
+
+        /**
+         * Sets AFI address.
+         *
+         * @param address AFI address
+         * @return GeoCoordinateAddressBuilder object
+         */
+        public GeoCoordinateAddressBuilder withAddress(LispAfiAddress address) {
+            this.address = address;
+            return this;
+        }
+
+        /**
+         * Builds LispGeoCoordinateLcafAddress instance.
+         *
+         * @return LispGeoCoordinateLcafAddress instance
+         */
+        public LispGeoCoordinateLcafAddress build() {
+
+            checkNotNull(address, "Must specify an AFI address");
+
+            return new LispGeoCoordinateLcafAddress(north, latitudeDegree,
+                        latitudeMinute, latitudeSecond, east, longitudeDegree,
+                        longitudeMinute, longitudeSecond, altitude, address);
+        }
+    }
+
+    /**
+     * GeoCoordinate LCAF address reader class.
+     */
+    public static class GeoCoordinateLcafAddressReader
+                    implements LispAddressReader<LispGeoCoordinateLcafAddress> {
+
+        private static final int NORTH_INDEX = 7;
+        private static final int EAST_INDEX = 7;
+        private static final int FLAG_SHIFT = 8;
+
+        @Override
+        public LispGeoCoordinateLcafAddress readFrom(ByteBuf byteBuf)
+                                    throws LispParseError, LispReaderException {
+
+            LispLcafAddress.deserializeCommon(byteBuf);
+
+            // north flag -> 1 bit
+            byte flagWithLatitude = byteBuf.readByte();
+
+            boolean north = ByteOperator.getBit(flagWithLatitude, NORTH_INDEX);
+
+            // latitude degree -> 15 bits
+            short latitudeFirst = flagWithLatitude;
+            if (north) {
+                latitudeFirst = (short) (flagWithLatitude & 0x7F);
+            }
+            short latitude = (short) ((latitudeFirst << FLAG_SHIFT) + byteBuf.readByte());
+
+            // latitude minute -> 8 bits
+            byte latitudeMinute = byteBuf.readByte();
+
+            // latitude second -> 8 bits
+            byte latitudeSecond = byteBuf.readByte();
+
+            // east flag -> 1 bit
+            byte flagWithLongitude = byteBuf.readByte();
+
+            boolean east = ByteOperator.getBit(flagWithLongitude, EAST_INDEX);
+
+            // longitude degree -> 15 bits
+            short longitudeFirst = flagWithLongitude;
+            if (east) {
+                longitudeFirst = (short) (flagWithLongitude & 0x7F);
+            }
+            short longitude = (short) ((longitudeFirst << FLAG_SHIFT) + byteBuf.readByte());
+
+            // longitude minute -> 8 bits
+            byte longitudeMinute = byteBuf.readByte();
+
+            // longitude second -> 8 bits
+            byte longitudeSecond = byteBuf.readByte();
+
+            // altitude -> 32 bits
+            int altitude = byteBuf.readInt();
+
+            LispAfiAddress address = new AfiAddressReader().readFrom(byteBuf);
+
+            return new GeoCoordinateAddressBuilder()
+                            .withIsNorth(north)
+                            .withLatitudeDegree(latitude)
+                            .withLatitudeMinute(latitudeMinute)
+                            .withLatitudeSecond(latitudeSecond)
+                            .withIsEast(east)
+                            .withLongitudeDegree(longitude)
+                            .withLongitudeMinute(longitudeMinute)
+                            .withLongitudeSecond(longitudeSecond)
+                            .withAltitude(altitude)
+                            .withAddress(address)
+                            .build();
+        }
+    }
+
+    /**
+     * GeoCoordinate LCAF address writer class.
+     */
+    public static class GeoCoordinateLcafAddressWriter
+                    implements LispAddressWriter<LispGeoCoordinateLcafAddress> {
+
+        private static final int NORTH_SHIFT_BIT = 15;
+        private static final int EAST_SHIFT_BIT = 15;
+
+        private static final int ENABLE_BIT = 1;
+        private static final int DISABLE_BIT = 0;
+
+        @Override
+        public void writeTo(ByteBuf byteBuf, LispGeoCoordinateLcafAddress address)
+                                                    throws LispWriterException {
+
+            int lcafIndex = byteBuf.writerIndex();
+            LispLcafAddress.serializeCommon(byteBuf, address);
+
+            // north flag + latitude degree
+            short north = DISABLE_BIT;
+            if (address.isNorth()) {
+                north = (short) (ENABLE_BIT << NORTH_SHIFT_BIT);
+            }
+
+            byteBuf.writeShort(north + address.latitudeDegree);
+
+            // latitude minute
+            byteBuf.writeByte(address.latitudeMinute);
+
+            // latitude second
+            byteBuf.writeByte(address.latitudeSecond);
+
+            // east flag + longitude degree
+            short east = DISABLE_BIT;
+            if (address.isEast()) {
+                east = (short) (ENABLE_BIT << EAST_SHIFT_BIT);
+            }
+
+            byteBuf.writeShort(east + address.longitudeDegree);
+
+            // longitude minute
+            byteBuf.writeByte(address.longitudeMinute);
+
+            // longitude second
+            byteBuf.writeByte(address.longitudeSecond);
+
+            // altitude
+            byteBuf.writeInt(address.altitude);
+
+            // address
+            AfiAddressWriter writer = new AfiAddressWriter();
+            writer.writeTo(byteBuf, address.getAddress());
+
+            LispLcafAddress.updateLength(lcafIndex, byteBuf);
+        }
+    }
+}
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/lcaf/LispLcafAddress.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/lcaf/LispLcafAddress.java
index 920d356..cd63b8d 100644
--- a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/lcaf/LispLcafAddress.java
+++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/types/lcaf/LispLcafAddress.java
@@ -30,6 +30,7 @@
 
 import static com.google.common.base.MoreObjects.toStringHelper;
 import static org.onosproject.lisp.msg.types.lcaf.LispCanonicalAddressFormatEnum.APPLICATION_DATA;
+import static org.onosproject.lisp.msg.types.lcaf.LispCanonicalAddressFormatEnum.GEO_COORDINATE;
 import static org.onosproject.lisp.msg.types.lcaf.LispCanonicalAddressFormatEnum.LIST;
 import static org.onosproject.lisp.msg.types.lcaf.LispCanonicalAddressFormatEnum.MULTICAST;
 import static org.onosproject.lisp.msg.types.lcaf.LispCanonicalAddressFormatEnum.NAT;
@@ -413,6 +414,10 @@
                 return new LispSegmentLcafAddress.SegmentLcafAddressReader().readFrom(byteBuf);
             }
 
+            if (lcafType == GEO_COORDINATE.getLispCode()) {
+                return new LispGeoCoordinateLcafAddress.GeoCoordinateLcafAddressReader().readFrom(byteBuf);
+            }
+
             if (lcafType == NONCE.getLispCode()) {
                 return new LispNonceLcafAddress.NonceLcafAddressReader().readFrom(byteBuf);
             }
@@ -461,6 +466,10 @@
                     new LispSegmentLcafAddress.SegmentLcafAddressWriter().writeTo(byteBuf,
                             (LispSegmentLcafAddress) address);
                     break;
+                case GEO_COORDINATE:
+                    new LispGeoCoordinateLcafAddress.GeoCoordinateLcafAddressWriter().writeTo(byteBuf,
+                            (LispGeoCoordinateLcafAddress) address);
+                    break;
                 case NONCE:
                     new LispNonceLcafAddress.NonceLcafAddressWriter().writeTo(byteBuf,
                             (LispNonceLcafAddress) address);
diff --git a/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/lcaf/LispGeoCoordinateLcafAddressTest.java b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/lcaf/LispGeoCoordinateLcafAddressTest.java
new file mode 100644
index 0000000..fe65c9c
--- /dev/null
+++ b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/lcaf/LispGeoCoordinateLcafAddressTest.java
@@ -0,0 +1,142 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.lisp.msg.types.lcaf;
+
+import com.google.common.testing.EqualsTester;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.packet.IpAddress;
+import org.onosproject.lisp.msg.exceptions.LispParseError;
+import org.onosproject.lisp.msg.exceptions.LispReaderException;
+import org.onosproject.lisp.msg.exceptions.LispWriterException;
+import org.onosproject.lisp.msg.types.LispIpv4Address;
+import org.onosproject.lisp.msg.types.lcaf.LispGeoCoordinateLcafAddress.GeoCoordinateAddressBuilder;
+import org.onosproject.lisp.msg.types.lcaf.LispGeoCoordinateLcafAddress.GeoCoordinateLcafAddressReader;
+import org.onosproject.lisp.msg.types.lcaf.LispGeoCoordinateLcafAddress.GeoCoordinateLcafAddressWriter;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+
+/**
+ * Unit tests for LispGeoCoordinateLcafAddress class.
+ */
+public class LispGeoCoordinateLcafAddressTest {
+
+    private static final String IP_ADDRESS_1 = "192.168.1.1";
+    private static final String IP_ADDRESS_2 = "192.168.1.2";
+
+    private LispGeoCoordinateLcafAddress address1;
+    private LispGeoCoordinateLcafAddress sameAsAddress1;
+    private LispGeoCoordinateLcafAddress address2;
+
+    @Before
+    public void setup() {
+
+        GeoCoordinateAddressBuilder builder1 = new GeoCoordinateAddressBuilder();
+
+        LispIpv4Address ipv4Address1 =
+                        new LispIpv4Address(IpAddress.valueOf(IP_ADDRESS_1));
+
+        address1 = builder1
+                        .withIsNorth(true)
+                        .withLatitudeDegree((short) 1)
+                        .withLatitudeMinute((byte) 1)
+                        .withLatitudeSecond((byte) 1)
+                        .withIsEast(false)
+                        .withLongitudeDegree((short) 1)
+                        .withLongitudeMinute((byte) 1)
+                        .withLongitudeSecond((byte) 1)
+                        .withAltitude(1)
+                        .withAddress(ipv4Address1)
+                        .build();
+
+        GeoCoordinateAddressBuilder builder2 = new GeoCoordinateAddressBuilder();
+
+        sameAsAddress1 = builder2
+                            .withIsNorth(true)
+                            .withLatitudeDegree((short) 1)
+                            .withLatitudeMinute((byte) 1)
+                            .withLatitudeSecond((byte) 1)
+                            .withIsEast(false)
+                            .withLongitudeDegree((short) 1)
+                            .withLongitudeMinute((byte) 1)
+                            .withLongitudeSecond((byte) 1)
+                            .withAltitude(1)
+                            .withAddress(ipv4Address1)
+                            .build();
+
+        GeoCoordinateAddressBuilder builder3 = new GeoCoordinateAddressBuilder();
+
+        LispIpv4Address ipv4Address2 =
+                        new LispIpv4Address(IpAddress.valueOf(IP_ADDRESS_2));
+
+        address2 = builder3
+                        .withIsNorth(false)
+                        .withLatitudeDegree((short) 2)
+                        .withLatitudeMinute((byte) 2)
+                        .withLatitudeSecond((byte) 2)
+                        .withIsEast(true)
+                        .withLongitudeDegree((short) 2)
+                        .withLongitudeMinute((byte) 2)
+                        .withLongitudeSecond((byte) 2)
+                        .withAltitude(2)
+                        .withAddress(ipv4Address2)
+                        .build();
+    }
+
+    @Test
+    public void testEquality() {
+        new EqualsTester()
+                .addEqualityGroup(address1, sameAsAddress1)
+                .addEqualityGroup(address2).testEquals();
+    }
+
+    @Test
+    public void testConstruction() {
+        LispGeoCoordinateLcafAddress address = address1;
+
+        LispIpv4Address ipv4Address =
+                        new LispIpv4Address(IpAddress.valueOf(IP_ADDRESS_1));
+
+        assertThat(address.isNorth(), is(true));
+        assertThat(address.getLatitudeDegree(), is((short) 1));
+        assertThat(address.getLatitudeMinute(), is((byte) 1));
+        assertThat(address.getLatitudeSecond(), is((byte) 1));
+        assertThat(address.isEast(), is(false));
+        assertThat(address.getLongitudeDegree(), is((short) 1));
+        assertThat(address.getLongitudeMinute(), is((byte) 1));
+        assertThat(address.getLongitudeSecond(), is((byte) 1));
+        assertThat(address.getAltitude(), is(1));
+        assertThat(address.getAddress(), is(ipv4Address));
+    }
+
+    @Test
+    public void testSerialization() throws LispWriterException,
+                                           LispParseError, LispReaderException {
+
+        ByteBuf byteBuf = Unpooled.buffer();
+
+        GeoCoordinateLcafAddressWriter writer = new GeoCoordinateLcafAddressWriter();
+        writer.writeTo(byteBuf, address1);
+
+        GeoCoordinateLcafAddressReader reader = new GeoCoordinateLcafAddressReader();
+        LispGeoCoordinateLcafAddress deserialized = reader.readFrom(byteBuf);
+
+        new EqualsTester().addEqualityGroup(address1, deserialized).testEquals();
+    }
+}
