Hi all, nice to meet you! New user both to Go and to the forum here!
So, my issue is as follows:
I have a simulated 5G core network deployed in my computer (the project is Free5GC). I need to generate different kinds of traffic (I’m beginning with a simple Http get to a given URL). This traffic will be sent to a local IP address which is the simulated UE (user equipment). Then this UE would keep routing the traffic outside of the network and it would also give the response back to me. This part of the process is transparent for me (I can observe it with Wireshark).
All I have for now is the code that the project gives for testing a ping, which is as follows:
// ping IP(tunnel IP) from 60.60.0.2(127.0.0.1) to 60.60.0.20(127.0.0.8)
gtpHdr, err := hex.DecodeString("32ff00340000000100000000")
assert.Nil(t, err)
icmpData, err := hex.DecodeString("8c870d0000000000101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f3031323334353637")
assert.Nil(t, err)
ipv4hdr := ipv4.Header{
Version: 4,
Len: 20,
Protocol: 1,
Flags: 0,
TotalLen: 48,
TTL: 64,
Src: net.ParseIP("60.60.0.1").To4(),
Dst: net.ParseIP("60.60.0.101").To4(),
ID: 1,
}
checksum := test.CalculateIpv4HeaderChecksum(&ipv4hdr)
ipv4hdr.Checksum = int(checksum)
v4HdrBuf, err := ipv4hdr.Marshal()
assert.Nil(t, err)
tt := append(gtpHdr, v4HdrBuf...)
m := icmp.Message{
Type: ipv4.ICMPTypeEcho, Code: 0,
Body: &icmp.Echo{
ID: 12394, Seq: 1,
Data: icmpData,
},
}
b, err := m.Marshal(nil)
assert.Nil(t, err)
b[2] = 0xaf
b[3] = 0x88
_, err = upfConn.Write(append(tt, b...))
assert.Nil(t, err)
It’s quite unclear to me what I have to do, honestly. I know that to make a http get request I could use:
resp, err := http.Get(url)
But since I have to send that to an IP address which then has a GTP tunnel, I don’t know how to do it.
Should I create an ipv4 message? How would I put inside the information for it to be a http get request?
Sorry I couldn’t be any more specific, but I’m kinda lost on this topic and I haven’t been able to found useful information about it.
Waiting for your response.
Regards, Víctor.