March 2, 2014

Raw sockets in Go: IP layer

Posted in Uncategorized at 00:41 by graham

In the Internet protocol suite we usually work at the transport layer, with TCP or UDP. Go (golang) has good support for working with lower layers. This post is about working one layer down, at the IP layer.

If you want to use protocols other than TCP or UDP, or craft your own packets, you need to connect at the IP layer.


Let’s read the first ICMP packet on localhost:

package main

import (

func main() {
    protocol := "icmp"
    netaddr, _ := net.ResolveIPAddr("ip4", "")
    conn, _ := net.ListenIP("ip4:"+protocol, netaddr)

    buf := make([]byte, 1024)
    numRead, _, _ := conn.ReadFrom(buf)
    fmt.Printf("% X\n", buf[:numRead])

Read the rest of this entry »

December 11, 2008

Linux on a potato

Posted in Uncategorized at 08:38 by graham

Offered with no further comment: Hackers successfully install Linux on a potato