Skip to content
This repository was archived by the owner on Oct 9, 2023. It is now read-only.

Commit b9191fa

Browse files
committedJul 25, 2019
net: NAT draft
1 parent 621c962 commit b9191fa

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
 

‎net.go

+24
Original file line numberDiff line numberDiff line change
@@ -203,3 +203,27 @@ func (n *Net) ListenPacket(network, address string) (net.PacketConn, error) {
203203
n.peers[addrKey(a)] = pc
204204
return pc, nil
205205
}
206+
207+
// NAT implements facility for Network Address Translation simulation.
208+
//
209+
// Basic example:
210+
// [ A ] <-----> [ NAT1 ] <-----> [ NAT2 ] <-----> [ B ]
211+
// IPa IPa' IPb' IPb
212+
//
213+
// 1) A sends packet P with dst = IPb'
214+
// 2) NAT1 receives packet P and changes it's src to IPa',
215+
// sending it to NAT2 from IPa'.
216+
// 3) NAT2 receives packet P from IPa' to IPb', does a lookup to
217+
// NAT translation table and finds association IPb' <-> IPb.
218+
// Then it sends packet P to B.
219+
// 4) B receives packet P from NAT2, observing that it has src = IPa'.
220+
//
221+
// Now B can repeat steps 1-4 and send packet back.
222+
//
223+
// IPa = 10.5.0.1:30000
224+
// IPa' = 83.30.100.1:23100
225+
// IPb' = 91.10.100.1:13000
226+
// IPb = 10.1.0.1:20000
227+
type NAT struct {
228+
// TODO(ar): implement
229+
}

0 commit comments

Comments
 (0)
This repository has been archived.