mirror of
https://github.com/KusakabeShi/EtherGuard-VPN.git
synced 2024-11-21 23:03:08 +01:00
Update default MTU to 1402
This commit is contained in:
parent
92e2c7d2e1
commit
ad4ffff985
@ -501,7 +501,7 @@ func (peer *Peer) RoutineSequentialReceiver() {
|
||||
should_receive = true
|
||||
case mtypes.NodeID_Broadcast:
|
||||
should_receive = true
|
||||
case mtypes.NodeID_AllPeer:
|
||||
case mtypes.NodeID_Spread:
|
||||
should_receive = true
|
||||
}
|
||||
}
|
||||
@ -511,7 +511,7 @@ func (peer *Peer) RoutineSequentialReceiver() {
|
||||
should_process = true
|
||||
case mtypes.NodeID_Broadcast:
|
||||
should_process = true
|
||||
case mtypes.NodeID_AllPeer:
|
||||
case mtypes.NodeID_Spread:
|
||||
should_process = true
|
||||
}
|
||||
}
|
||||
@ -534,7 +534,7 @@ func (peer *Peer) RoutineSequentialReceiver() {
|
||||
switch dst_nodeID {
|
||||
case mtypes.NodeID_Broadcast:
|
||||
should_transfer = true
|
||||
case mtypes.NodeID_AllPeer:
|
||||
case mtypes.NodeID_Spread:
|
||||
packet := elem.packet[path.EgHeaderLen:] //packet body
|
||||
if device.CheckNoDup(packet) {
|
||||
should_transfer = true
|
||||
@ -566,7 +566,7 @@ func (peer *Peer) RoutineSequentialReceiver() {
|
||||
EgHeader.SetTTL(l2ttl - 1)
|
||||
if dst_nodeID == mtypes.NodeID_Broadcast { //Regular transfer algorithm
|
||||
device.TransitBoardcastPacket(src_nodeID, peer.ID, elem.Type, elem.packet, MessageTransportOffsetContent)
|
||||
} else if dst_nodeID == mtypes.NodeID_AllPeer { // Control Message will try send to every know node regardless the connectivity
|
||||
} else if dst_nodeID == mtypes.NodeID_Spread { // Control Message will try send to every know node regardless the connectivity
|
||||
skip_list := make(map[mtypes.Vertex]bool)
|
||||
skip_list[src_nodeID] = true //Don't send to conimg peer and source peer
|
||||
skip_list[peer.ID] = true
|
||||
@ -604,12 +604,12 @@ func (peer *Peer) RoutineSequentialReceiver() {
|
||||
if should_receive { // Write message to tap device
|
||||
if packet_type == path.NormalPacket {
|
||||
if len(elem.packet) <= path.EgHeaderLen+12 {
|
||||
device.log.Errorf("Invalid normal packet: Ethernet packet too small from peer %v", peer.ID.ToString())
|
||||
device.log.Errorf("Invalid Normal packet: Ethernet packet too small from peer %v", peer.ID.ToString())
|
||||
goto skip
|
||||
}
|
||||
if device.LogLevel.LogNormal {
|
||||
packet_len := len(elem.packet) - path.EgHeaderLen
|
||||
fmt.Println("Normal: Recv Normal packet From:" + peer.GetEndpointDstStr() + " SrcID:" + src_nodeID.ToString() + " DstID:" + dst_nodeID.ToString() + " Len:" + strconv.Itoa(packet_len))
|
||||
fmt.Printf("Normal: Recv Len:%v S:%v D:%v From:%v IP:%v:\n", strconv.Itoa(packet_len), src_nodeID.ToString(), dst_nodeID.ToString(), peer.ID.ToString(), peer.GetEndpointDstStr())
|
||||
packet := gopacket.NewPacket(elem.packet[path.EgHeaderLen:], layers.LayerTypeEthernet, gopacket.Default)
|
||||
fmt.Println(packet.Dump())
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ func (device *Device) SendPacket(peer *Peer, usage path.Usage, packet []byte, of
|
||||
}
|
||||
if usage == path.NormalPacket && len(packet)-path.EgHeaderLen <= 12 {
|
||||
if device.LogLevel.LogNormal {
|
||||
fmt.Printf("Normal: Send Len:%v Invalid packet: Ethernet packet too small\n", len(packet))
|
||||
fmt.Printf("Normal: Send Len:%v Invalid packet: Ethernet packet too small\n", len(packet)-path.EgHeaderLen)
|
||||
}
|
||||
return
|
||||
}
|
||||
@ -46,7 +46,7 @@ func (device *Device) SendPacket(peer *Peer, usage path.Usage, packet []byte, of
|
||||
if usage == path.NormalPacket && EgHeader.GetSrc() == device.ID {
|
||||
dst_nodeID := EgHeader.GetDst()
|
||||
packet_len := len(packet) - path.EgHeaderLen
|
||||
fmt.Printf("Normal: Send Len%v S:%v D:%v To:%v IP:%v:\n", packet_len, device.ID.ToString(), dst_nodeID.ToString(), peer.ID.ToString(), peer.GetEndpointDstStr())
|
||||
fmt.Printf("Normal: Send Len:%v S:%v D:%v To:%v IP:%v:\n", packet_len, device.ID.ToString(), dst_nodeID.ToString(), peer.ID.ToString(), peer.GetEndpointDstStr())
|
||||
packet := gopacket.NewPacket(packet[path.EgHeaderLen:], layers.LayerTypeEthernet, gopacket.Default)
|
||||
fmt.Println(packet.Dump())
|
||||
}
|
||||
@ -251,7 +251,7 @@ func (device *Device) GeneratePingPacket(src_nodeID mtypes.Vertex, request_reply
|
||||
if err != nil {
|
||||
return nil, path.PingPacket, err
|
||||
}
|
||||
header.SetDst(mtypes.NodeID_AllPeer)
|
||||
header.SetDst(mtypes.NodeID_Spread)
|
||||
header.SetTTL(0)
|
||||
header.SetSrc(device.ID)
|
||||
header.SetPacketLength(uint16(len(body)))
|
||||
@ -359,7 +359,7 @@ func (device *Device) process_ping(peer *Peer, content mtypes.PingMsg) error {
|
||||
device.Send2Super(path.PongPacket, buf, MessageTransportOffsetContent)
|
||||
}
|
||||
if device.EdgeConfig.DynamicRoute.P2P.UseP2P {
|
||||
header.SetDst(mtypes.NodeID_AllPeer)
|
||||
header.SetDst(mtypes.NodeID_Spread)
|
||||
device.SpreadPacket(make(map[mtypes.Vertex]bool), path.PongPacket, buf, MessageTransportOffsetContent)
|
||||
}
|
||||
go device.SendPing(peer, content.RequestReply, 0, 3)
|
||||
@ -707,7 +707,7 @@ func (device *Device) process_RequestPeerMsg(content mtypes.QueryPeerMsg) error
|
||||
}
|
||||
buf := make([]byte, path.EgHeaderLen+len(body))
|
||||
header, _ := path.NewEgHeader(buf[0:path.EgHeaderLen], device.EdgeConfig.Interface.MTU)
|
||||
header.SetDst(mtypes.NodeID_AllPeer)
|
||||
header.SetDst(mtypes.NodeID_Spread)
|
||||
header.SetTTL(device.EdgeConfig.DefaultTTL)
|
||||
header.SetSrc(device.ID)
|
||||
header.SetPacketLength(uint16(len(body)))
|
||||
@ -924,7 +924,7 @@ func (device *Device) RoutinePostPeerInfo(startchan <-chan struct{}) {
|
||||
}
|
||||
pongs = append(pongs, pong)
|
||||
if device.LogLevel.LogControl {
|
||||
fmt.Println("Control: Pack to: Post body " + pong.ToString())
|
||||
fmt.Printf("Control: Pack %v S:%v D:%v To:Post body\n", pong.ToString(), pong.Src_nodeID.ToString(), pong.Dst_nodeID.ToString())
|
||||
}
|
||||
}
|
||||
device.peers.RLock()
|
||||
@ -982,15 +982,19 @@ func (device *Device) RoutinePostPeerInfo(startchan <-chan struct{}) {
|
||||
req.Header.Set("Content-Encoding", "gzip")
|
||||
device.HttpPostCount += 1
|
||||
if device.LogLevel.LogControl {
|
||||
fmt.Println("Control: Post to " + req.URL.RequestURI())
|
||||
fmt.Printf("Control: Post to %v\n", downloadurl)
|
||||
}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
device.log.Errorf("RoutinePostPeerInfo: " + err.Error())
|
||||
} else {
|
||||
if device.LogLevel.LogControl {
|
||||
res, _ := ioutil.ReadAll(resp.Body)
|
||||
fmt.Println("Control: Post result " + string(res))
|
||||
res, err := ioutil.ReadAll(resp.Body)
|
||||
if err == nil {
|
||||
fmt.Printf("Control: Post result %v\n", string(res))
|
||||
} else {
|
||||
fmt.Printf("Control: Post error %v %v\n", err, string(res))
|
||||
}
|
||||
}
|
||||
resp.Body.Close()
|
||||
}
|
||||
|
@ -286,7 +286,8 @@ func (device *Device) RoutineReadFromTUN() {
|
||||
continue
|
||||
}
|
||||
if device.LogLevel.LogNormal {
|
||||
fmt.Println("Normal: Send packet To:" + peer.GetEndpointDstStr() + " SrcID:" + device.ID.ToString() + " DstID:" + dst_nodeID.ToString() + " Len:" + strconv.Itoa(len(elem.packet)))
|
||||
packet_len := len(elem.packet) - path.EgHeaderLen
|
||||
fmt.Printf("Normal: Send Len:%v S:%v D:%v To:%v IP:%v:\n", packet_len, device.ID.ToString(), dst_nodeID.ToString(), peer.ID.ToString(), peer.GetEndpointDstStr())
|
||||
packet := gopacket.NewPacket(elem.packet[path.EgHeaderLen:], layers.LayerTypeEthernet, gopacket.Default)
|
||||
fmt.Println(packet.Dump())
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
"github.com/KusakabeSi/EtherGuard-VPN/tap"
|
||||
)
|
||||
|
||||
const DefaultMTU = 1416
|
||||
const DefaultMTU = 1402
|
||||
|
||||
func (device *Device) RoutineTUNEventReader() {
|
||||
device.log.Verbosef("Routine: event worker - started")
|
||||
|
@ -7,7 +7,7 @@ Interface:
|
||||
IPv4CIDR: 192.168.76.0/24
|
||||
IPv6CIDR: fd95:71cb:a3df:e586::/64
|
||||
IPv6LLPrefix: fe80::a3df:0/112
|
||||
MTU: 1416
|
||||
MTU: 1402
|
||||
RecvAddr: 127.0.0.1:4001
|
||||
SendAddr: 127.0.0.1:5001
|
||||
L2HeaderMode: kbdbg
|
||||
|
@ -7,7 +7,7 @@ Interface:
|
||||
IPv4CIDR: 192.168.76.0/24
|
||||
IPv6CIDR: fd95:71cb:a3df:e586::/64
|
||||
IPv6LLPrefix: fe80::a3df:0/112
|
||||
MTU: 1416
|
||||
MTU: 1402
|
||||
RecvAddr: 127.0.0.1:4001
|
||||
SendAddr: 127.0.0.1:5001
|
||||
L2HeaderMode: kbdbg
|
||||
|
@ -7,7 +7,7 @@ Interface:
|
||||
IPv4CIDR: 192.168.76.0/24
|
||||
IPv6CIDR: fd95:71cb:a3df:e586::/64
|
||||
IPv6LLPrefix: fe80::a3df:0/112
|
||||
MTU: 1416
|
||||
MTU: 1402
|
||||
RecvAddr: 127.0.0.1:4001
|
||||
SendAddr: 127.0.0.1:5001
|
||||
L2HeaderMode: kbdbg
|
||||
|
@ -7,7 +7,7 @@ Interface:
|
||||
IPv4CIDR: 192.168.76.0/24
|
||||
IPv6CIDR: fd95:71cb:a3df:e586::/64
|
||||
IPv6LLPrefix: fe80::a3df:0/112
|
||||
MTU: 1416
|
||||
MTU: 1402
|
||||
RecvAddr: 127.0.0.1:4001
|
||||
SendAddr: 127.0.0.1:5001
|
||||
L2HeaderMode: kbdbg
|
||||
|
@ -7,7 +7,7 @@ Interface:
|
||||
IPv4CIDR: 192.168.76.0/24
|
||||
IPv6CIDR: fd95:71cb:a3df:e586::/64
|
||||
IPv6LLPrefix: fe80::a3df:0/112
|
||||
MTU: 1416
|
||||
MTU: 1402
|
||||
RecvAddr: 127.0.0.1:4001
|
||||
SendAddr: 127.0.0.1:5001
|
||||
L2HeaderMode: kbdbg
|
||||
|
@ -7,7 +7,7 @@ Interface:
|
||||
IPv4CIDR: 192.168.76.0/24
|
||||
IPv6CIDR: fd95:71cb:a3df:e586::/64
|
||||
IPv6LLPrefix: fe80::a3df:0/112
|
||||
MTU: 1416
|
||||
MTU: 1402
|
||||
RecvAddr: 127.0.0.1:4001
|
||||
SendAddr: 127.0.0.1:5001
|
||||
L2HeaderMode: kbdbg
|
||||
|
@ -7,7 +7,7 @@ Interface:
|
||||
IPv4CIDR: 192.168.76.0/24
|
||||
IPv6CIDR: fd95:71cb:a3df:e586::/64
|
||||
IPv6LLPrefix: fe80::a3df:0/112
|
||||
MTU: 1416
|
||||
MTU: 1402
|
||||
RecvAddr: 127.0.0.1:4001
|
||||
SendAddr: 127.0.0.1:5001
|
||||
L2HeaderMode: kbdbg
|
||||
|
@ -7,7 +7,7 @@ Interface:
|
||||
IPv4CIDR: 192.168.76.0/24
|
||||
IPv6CIDR: fd95:71cb:a3df:e586::/64
|
||||
IPv6LLPrefix: fe80::a3df:0/112
|
||||
MTU: 1416
|
||||
MTU: 1402
|
||||
RecvAddr: 127.0.0.1:4001
|
||||
SendAddr: 127.0.0.1:5001
|
||||
L2HeaderMode: kbdbg
|
||||
|
@ -7,7 +7,7 @@ Interface:
|
||||
IPv4CIDR: 192.168.76.0/24
|
||||
IPv6CIDR: fd95:71cb:a3df:e586::/64
|
||||
IPv6LLPrefix: fe80::a3df:0/112
|
||||
MTU: 1416
|
||||
MTU: 1402
|
||||
RecvAddr: 127.0.0.1:4001
|
||||
SendAddr: 127.0.0.1:5001
|
||||
L2HeaderMode: kbdbg
|
||||
|
@ -7,7 +7,7 @@ Interface:
|
||||
IPv4CIDR: 192.168.76.0/24
|
||||
IPv6CIDR: fd95:71cb:a3df:e586::/64
|
||||
IPv6LLPrefix: fe80::a3df:0/112
|
||||
MTU: 1416
|
||||
MTU: 1402
|
||||
RecvAddr: 127.0.0.1:4001
|
||||
SendAddr: 127.0.0.1:5001
|
||||
L2HeaderMode: kbdbg
|
||||
|
@ -7,7 +7,7 @@ Interface:
|
||||
IPv4CIDR: 192.168.76.0/24
|
||||
IPv6CIDR: fd95:71cb:a3df:e586::/64
|
||||
IPv6LLPrefix: fe80::a3df:0/112
|
||||
MTU: 1416
|
||||
MTU: 1402
|
||||
RecvAddr: 127.0.0.1:4001
|
||||
SendAddr: 127.0.0.1:5001
|
||||
L2HeaderMode: kbdbg
|
||||
|
@ -7,7 +7,7 @@ Interface:
|
||||
IPv4CIDR: 192.168.76.0/24
|
||||
IPv6CIDR: fd95:71cb:a3df:e586::/64
|
||||
IPv6LLPrefix: fe80::a3df:0/112
|
||||
MTU: 1416
|
||||
MTU: 1402
|
||||
RecvAddr: 127.0.0.1:4001
|
||||
SendAddr: 127.0.0.1:5001
|
||||
L2HeaderMode: kbdbg
|
||||
|
@ -7,7 +7,7 @@ Interface:
|
||||
IPv4CIDR: 192.168.76.0/24
|
||||
IPv6CIDR: fd95:71cb:a3df:e586::/64
|
||||
IPv6LLPrefix: fe80::a3df:0/112
|
||||
MTU: 1416
|
||||
MTU: 1402
|
||||
RecvAddr: 127.0.0.1:4001
|
||||
SendAddr: 127.0.0.1:5001
|
||||
L2HeaderMode: kbdbg
|
||||
|
@ -7,7 +7,7 @@ Interface:
|
||||
IPv4CIDR: 192.168.76.0/24
|
||||
IPv6CIDR: fd95:71cb:a3df:e586::/64
|
||||
IPv6LLPrefix: fe80::a3df:0/112
|
||||
MTU: 1416
|
||||
MTU: 1402
|
||||
RecvAddr: 127.0.0.1:4002
|
||||
SendAddr: 127.0.0.1:5002
|
||||
L2HeaderMode: kbdbg
|
||||
|
@ -7,7 +7,7 @@ Interface:
|
||||
IPv4CIDR: 192.168.76.0/24
|
||||
IPv6CIDR: fd95:71cb:a3df:e586::/64
|
||||
IPv6LLPrefix: fe80::a3df:0/112
|
||||
MTU: 1416
|
||||
MTU: 1402
|
||||
RecvAddr: 127.0.0.1:4100
|
||||
SendAddr: 127.0.0.1:5100
|
||||
L2HeaderMode: kbdbg
|
||||
|
@ -306,7 +306,7 @@ interface:
|
||||
vppifaceid: 1
|
||||
vppbridgeid: 4242
|
||||
macaddrprefix: AA:BB:CC:DD
|
||||
mtu: 1416
|
||||
mtu: 1402
|
||||
recvaddr: 127.0.0.1:4001
|
||||
sendaddr: 127.0.0.1:5001
|
||||
l2headermode: kbdbg
|
||||
|
@ -4,7 +4,7 @@ interface:
|
||||
vppifaceid: 1
|
||||
vppbridgeid: 4242
|
||||
macaddrprefix: AA:BB:CC:DD
|
||||
mtu: 1416
|
||||
mtu: 1402
|
||||
recvaddr: 127.0.0.1:4001
|
||||
sendaddr: 127.0.0.1:5001
|
||||
l2headermode: kbdbg
|
||||
|
@ -6,6 +6,7 @@
|
||||
package gencfg
|
||||
|
||||
import (
|
||||
"github.com/KusakabeSi/EtherGuard-VPN/device"
|
||||
"github.com/KusakabeSi/EtherGuard-VPN/mtypes"
|
||||
"github.com/KusakabeSi/EtherGuard-VPN/path"
|
||||
)
|
||||
@ -27,7 +28,7 @@ func GetExampleEdgeConf(templatePath string, getDemo bool) mtypes.EdgeConfig {
|
||||
VPPIFaceID: 1,
|
||||
VPPBridgeID: 4242,
|
||||
MacAddrPrefix: "AA:BB:CC:DD",
|
||||
MTU: 1416,
|
||||
MTU: device.DefaultMTU,
|
||||
RecvAddr: "127.0.0.1:4001",
|
||||
SendAddr: "127.0.0.1:5001",
|
||||
L2HeaderMode: "nochg",
|
||||
|
@ -470,7 +470,7 @@ func edge_post_nodeinfo(w http.ResponseWriter, r *http.Request) {
|
||||
continue
|
||||
}
|
||||
|
||||
if info, has := httpobj.http_PeerID2Info[pong_msg.Dst_nodeID]; !has {
|
||||
if info, has := httpobj.http_PeerID2Info[pong_msg.Dst_nodeID]; has {
|
||||
AdditionalCost_use := info.AdditionalCost
|
||||
|
||||
if AdditionalCost_use >= 0 {
|
||||
@ -478,7 +478,7 @@ func edge_post_nodeinfo(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
applied_pones = append(applied_pones, pong_msg)
|
||||
if httpobj.http_sconfig.LogLevel.LogControl {
|
||||
fmt.Println("Control: Unpack from : Post body " + pong_msg.ToString())
|
||||
fmt.Printf("Control: Recv %v S:%v D:%v From: %v(HTTP) IP:%v\n", pong_msg.ToString(), pong_msg.Src_nodeID.ToString(), pong_msg.Dst_nodeID.ToString(), NodeID.ToString(), r.RemoteAddr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ type Vertex uint16
|
||||
|
||||
const (
|
||||
NodeID_Broadcast Vertex = math.MaxUint16 - iota // Normal boardcast, boardcast with route table
|
||||
NodeID_AllPeer Vertex = math.MaxUint16 - iota // p2p mode: boardcast to every know peer and prevent dup. super mode: send to supernode
|
||||
NodeID_Spread Vertex = math.MaxUint16 - iota // p2p mode: boardcast to every know peer and prevent dup. super mode: send to supernode
|
||||
NodeID_SuperNode Vertex = math.MaxUint16 - iota
|
||||
NodeID_Invalid Vertex = math.MaxUint16 - iota
|
||||
NodeID_Special Vertex = NodeID_Invalid
|
||||
@ -110,8 +110,8 @@ func (v *Vertex) ToString() string {
|
||||
switch *v {
|
||||
case NodeID_Broadcast:
|
||||
return "Boardcast"
|
||||
case NodeID_AllPeer:
|
||||
return "AllPeer"
|
||||
case NodeID_Spread:
|
||||
return "Spread"
|
||||
case NodeID_SuperNode:
|
||||
return "Super"
|
||||
case NodeID_Invalid:
|
||||
|
@ -2,7 +2,6 @@ package mtypes
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"encoding/gob"
|
||||
"fmt"
|
||||
"strconv"
|
||||
@ -33,17 +32,16 @@ type RegisterMsg struct {
|
||||
HttpPostCount uint64
|
||||
}
|
||||
|
||||
func Hash2Str(h []byte) string {
|
||||
for _, v := range h {
|
||||
if v != 0 {
|
||||
return base64.StdEncoding.EncodeToString(h)[:10] + "..."
|
||||
func Hash2Str(h string) string {
|
||||
n := 10
|
||||
if len(h) > n-3 {
|
||||
return h[:n] + "..."
|
||||
}
|
||||
}
|
||||
return "\"\""
|
||||
return "\"" + h + "\""
|
||||
}
|
||||
|
||||
func (c *RegisterMsg) ToString() string {
|
||||
return fmt.Sprint("RegisterMsg Node_id:"+c.Node_id.ToString(), " Version:"+c.Version, " PeerHash:"+c.PeerStateHash, " NhHash:"+c.NhStateHash, " SuperParamHash:"+c.SuperParamStateHash)
|
||||
return fmt.Sprint("RegisterMsg Node_id:"+c.Node_id.ToString(), " Version:"+c.Version, " PeerHash:"+Hash2Str(c.PeerStateHash), " NhHash:"+Hash2Str(c.NhStateHash), " SuperParamHash:"+Hash2Str(c.SuperParamStateHash))
|
||||
}
|
||||
|
||||
func ParseRegisterMsg(bin []byte) (StructPlace RegisterMsg, err error) {
|
||||
|
Loading…
Reference in New Issue
Block a user