| 327 | } |
| 328 | |
| 329 | func (i *InMemoryNetwork) virtualInternet(pkt []byte, len int, from, to bindtest.ChannelEndpoint2) { |
| 330 | // simulate network conditions |
| 331 | i.cfg.linksMu.RLock() |
| 332 | idx := slices.IndexFunc(i.cfg.Links, func(link *VirtualLink) bool { |
| 333 | return link.Edge.V1 == from && link.Edge.V2 == to |
| 334 | }) |
| 335 | var link *VirtualLink |
| 336 | if idx != -1 { |
| 337 | link = i.cfg.Links[idx] |
| 338 | } |
| 339 | i.cfg.linksMu.RUnlock() |
| 340 | if link == nil { |
| 341 | return // no connection, dropped packet |
| 342 | } |
| 343 | link.simulate(pkt, len, from, to, i) |
| 344 | } |
| 345 | |
| 346 | func (i *InMemoryNetwork) Bind(node state.NodeId) conn.Bind { |
| 347 | i.Lock() |