Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ycai
simbricks
Commits
e15769f9
Commit
e15769f9
authored
Jul 11, 2024
by
Jialin Li
Committed by
Jonas Kaufmann
Jul 12, 2024
Browse files
orchestration/simulators: add basic p4 switch (compiled)
parent
a15b1fd2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
421 additions
and
0 deletions
+421
-0
experiments/simbricks/orchestration/simulators.py
experiments/simbricks/orchestration/simulators.py
+29
-0
sims/net/p4/basic.json
sims/net/p4/basic.json
+392
-0
No files found.
experiments/simbricks/orchestration/simulators.py
View file @
e15769f9
...
@@ -910,6 +910,35 @@ class TofinoNet(NetSim):
...
@@ -910,6 +910,35 @@ class TofinoNet(NetSim):
return
cmd
return
cmd
class
BMV2Net
(
NetSim
):
def
__init__
(
self
):
super
().
__init__
()
self
.
sync
=
False
def
run_cmd
(
self
,
env
):
cmd
=
(
f
'
{
env
.
repodir
}
/sims/external/bmv2'
f
'/targets/simple_switch/simple_switch'
)
cmd
+=
(
f
' --use-simbricks --sync-interval
{
self
.
sync_period
}
'
f
' --link-latency
{
self
.
eth_latency
}
'
)
if
self
.
sync
:
cmd
+=
' --sync-eth'
port
=
0
for
_
,
n
in
self
.
connect_sockets
(
env
):
cmd
+=
f
' -i
{
port
}
@
{
n
}
'
port
+=
1
cmd
+=
' '
+
env
.
repodir
+
'/sims/net/p4/basic.json'
print
(
cmd
)
return
cmd
class
NS3E2ENet
(
NetSim
):
class
NS3E2ENet
(
NetSim
):
def
__init__
(
self
)
->
None
:
def
__init__
(
self
)
->
None
:
...
...
sims/net/p4/basic.json
0 → 100644
View file @
e15769f9
{
"header_types"
:
[
{
"name"
:
"scalars_0"
,
"id"
:
0
,
"fields"
:
[]
},
{
"name"
:
"standard_metadata"
,
"id"
:
1
,
"fields"
:
[
[
"ingress_port"
,
9
,
false
],
[
"egress_spec"
,
9
,
false
],
[
"egress_port"
,
9
,
false
],
[
"instance_type"
,
32
,
false
],
[
"packet_length"
,
32
,
false
],
[
"enq_timestamp"
,
32
,
false
],
[
"enq_qdepth"
,
19
,
false
],
[
"deq_timedelta"
,
32
,
false
],
[
"deq_qdepth"
,
19
,
false
],
[
"ingress_global_timestamp"
,
48
,
false
],
[
"egress_global_timestamp"
,
48
,
false
],
[
"mcast_grp"
,
16
,
false
],
[
"egress_rid"
,
16
,
false
],
[
"checksum_error"
,
1
,
false
],
[
"parser_error"
,
32
,
false
],
[
"priority"
,
3
,
false
],
[
"_padding"
,
3
,
false
]
]
},
{
"name"
:
"ethernet_t"
,
"id"
:
2
,
"fields"
:
[
[
"dstAddr"
,
48
,
false
],
[
"srcAddr"
,
48
,
false
],
[
"etherType"
,
16
,
false
]
]
},
{
"name"
:
"ipv4_t"
,
"id"
:
3
,
"fields"
:
[
[
"version"
,
4
,
false
],
[
"ihl"
,
4
,
false
],
[
"diffserv"
,
8
,
false
],
[
"totalLen"
,
16
,
false
],
[
"identification"
,
16
,
false
],
[
"flags"
,
3
,
false
],
[
"fragOffset"
,
13
,
false
],
[
"ttl"
,
8
,
false
],
[
"protocol"
,
8
,
false
],
[
"hdrChecksum"
,
16
,
false
],
[
"srcAddr"
,
32
,
false
],
[
"dstAddr"
,
32
,
false
]
]
}
],
"headers"
:
[
{
"name"
:
"scalars"
,
"id"
:
0
,
"header_type"
:
"scalars_0"
,
"metadata"
:
true
,
"pi_omit"
:
true
},
{
"name"
:
"standard_metadata"
,
"id"
:
1
,
"header_type"
:
"standard_metadata"
,
"metadata"
:
true
,
"pi_omit"
:
true
},
{
"name"
:
"ethernet"
,
"id"
:
2
,
"header_type"
:
"ethernet_t"
,
"metadata"
:
false
,
"pi_omit"
:
true
},
{
"name"
:
"ipv4"
,
"id"
:
3
,
"header_type"
:
"ipv4_t"
,
"metadata"
:
false
,
"pi_omit"
:
true
}
],
"header_stacks"
:
[],
"header_union_types"
:
[],
"header_unions"
:
[],
"header_union_stacks"
:
[],
"field_lists"
:
[],
"errors"
:
[
[
"NoError"
,
0
],
[
"PacketTooShort"
,
1
],
[
"NoMatch"
,
2
],
[
"StackOutOfBounds"
,
3
],
[
"HeaderTooShort"
,
4
],
[
"ParserTimeout"
,
5
],
[
"ParserInvalidArgument"
,
6
]
],
"enums"
:
[],
"parsers"
:
[
{
"name"
:
"parser"
,
"id"
:
0
,
"init_state"
:
"start"
,
"parse_states"
:
[
{
"name"
:
"start"
,
"id"
:
0
,
"parser_ops"
:
[],
"transitions"
:
[
{
"type"
:
"default"
,
"value"
:
null
,
"mask"
:
null
,
"next_state"
:
null
}
],
"transition_key"
:
[]
}
]
}
],
"parse_vsets"
:
[],
"deparsers"
:
[
{
"name"
:
"deparser"
,
"id"
:
0
,
"source_info"
:
{
"filename"
:
"p4-tutorials/exercises/basic/basic.p4"
,
"line"
:
145
,
"column"
:
8
,
"source_fragment"
:
"MyDeparser"
},
"order"
:
[],
"primitives"
:
[]
}
],
"meter_arrays"
:
[],
"counter_arrays"
:
[],
"register_arrays"
:
[],
"calculations"
:
[
{
"name"
:
"calc"
,
"id"
:
0
,
"source_info"
:
{
"filename"
:
"p4-tutorials/exercises/basic/basic.p4"
,
"line"
:
122
,
"column"
:
8
,
"source_fragment"
:
"update_checksum( ..."
},
"algo"
:
"csum16"
,
"input"
:
[
{
"type"
:
"field"
,
"value"
:
[
"ipv4"
,
"version"
]
},
{
"type"
:
"field"
,
"value"
:
[
"ipv4"
,
"ihl"
]
},
{
"type"
:
"field"
,
"value"
:
[
"ipv4"
,
"diffserv"
]
},
{
"type"
:
"field"
,
"value"
:
[
"ipv4"
,
"totalLen"
]
},
{
"type"
:
"field"
,
"value"
:
[
"ipv4"
,
"identification"
]
},
{
"type"
:
"field"
,
"value"
:
[
"ipv4"
,
"flags"
]
},
{
"type"
:
"field"
,
"value"
:
[
"ipv4"
,
"fragOffset"
]
},
{
"type"
:
"field"
,
"value"
:
[
"ipv4"
,
"ttl"
]
},
{
"type"
:
"field"
,
"value"
:
[
"ipv4"
,
"protocol"
]
},
{
"type"
:
"field"
,
"value"
:
[
"ipv4"
,
"srcAddr"
]
},
{
"type"
:
"field"
,
"value"
:
[
"ipv4"
,
"dstAddr"
]
}
]
}
],
"learn_lists"
:
[],
"actions"
:
[
{
"name"
:
"NoAction"
,
"id"
:
0
,
"runtime_data"
:
[],
"primitives"
:
[]
},
{
"name"
:
"MyIngress.drop"
,
"id"
:
1
,
"runtime_data"
:
[],
"primitives"
:
[
{
"op"
:
"mark_to_drop"
,
"parameters"
:
[
{
"type"
:
"header"
,
"value"
:
"standard_metadata"
}
],
"source_info"
:
{
"filename"
:
"p4-tutorials/exercises/basic/basic.p4"
,
"line"
:
78
,
"column"
:
8
,
"source_fragment"
:
"mark_to_drop(standard_metadata)"
}
}
]
},
{
"name"
:
"MyIngress.ipv4_forward"
,
"id"
:
2
,
"runtime_data"
:
[
{
"name"
:
"dstAddr"
,
"bitwidth"
:
48
},
{
"name"
:
"port"
,
"bitwidth"
:
9
}
],
"primitives"
:
[]
}
],
"pipelines"
:
[
{
"name"
:
"ingress"
,
"id"
:
0
,
"source_info"
:
{
"filename"
:
"p4-tutorials/exercises/basic/basic.p4"
,
"line"
:
74
,
"column"
:
8
,
"source_fragment"
:
"MyIngress"
},
"init_table"
:
"MyIngress.ipv4_lpm"
,
"tables"
:
[
{
"name"
:
"MyIngress.ipv4_lpm"
,
"id"
:
0
,
"source_info"
:
{
"filename"
:
"p4-tutorials/exercises/basic/basic.p4"
,
"line"
:
85
,
"column"
:
10
,
"source_fragment"
:
"ipv4_lpm"
},
"key"
:
[
{
"match_type"
:
"lpm"
,
"name"
:
"hdr.ipv4.dstAddr"
,
"target"
:
[
"ipv4"
,
"dstAddr"
],
"mask"
:
null
}
],
"match_type"
:
"lpm"
,
"type"
:
"simple"
,
"max_size"
:
1024
,
"with_counters"
:
false
,
"support_timeout"
:
false
,
"direct_meters"
:
null
,
"action_ids"
:
[
2
,
1
,
0
],
"actions"
:
[
"MyIngress.ipv4_forward"
,
"MyIngress.drop"
,
"NoAction"
],
"base_default_next"
:
null
,
"next_tables"
:
{
"MyIngress.ipv4_forward"
:
null
,
"MyIngress.drop"
:
null
,
"NoAction"
:
null
},
"default_entry"
:
{
"action_id"
:
0
,
"action_const"
:
false
,
"action_data"
:
[],
"action_entry_const"
:
false
}
}
],
"action_profiles"
:
[],
"conditionals"
:
[]
},
{
"name"
:
"egress"
,
"id"
:
1
,
"source_info"
:
{
"filename"
:
"p4-tutorials/exercises/basic/basic.p4"
,
"line"
:
110
,
"column"
:
8
,
"source_fragment"
:
"MyEgress"
},
"init_table"
:
null
,
"tables"
:
[],
"action_profiles"
:
[],
"conditionals"
:
[]
}
],
"checksums"
:
[
{
"name"
:
"cksum"
,
"id"
:
0
,
"source_info"
:
{
"filename"
:
"p4-tutorials/exercises/basic/basic.p4"
,
"line"
:
122
,
"column"
:
8
,
"source_fragment"
:
"update_checksum( ..."
},
"target"
:
[
"ipv4"
,
"hdrChecksum"
],
"type"
:
"generic"
,
"calculation"
:
"calc"
,
"verify"
:
false
,
"update"
:
true
,
"if_cond"
:
{
"type"
:
"expression"
,
"value"
:
{
"op"
:
"d2b"
,
"left"
:
null
,
"right"
:
{
"type"
:
"field"
,
"value"
:
[
"ipv4"
,
"$valid$"
]
}
}
}
}
],
"force_arith"
:
[],
"extern_instances"
:
[],
"field_aliases"
:
[
[
"queueing_metadata.enq_timestamp"
,
[
"standard_metadata"
,
"enq_timestamp"
]
],
[
"queueing_metadata.enq_qdepth"
,
[
"standard_metadata"
,
"enq_qdepth"
]
],
[
"queueing_metadata.deq_timedelta"
,
[
"standard_metadata"
,
"deq_timedelta"
]
],
[
"queueing_metadata.deq_qdepth"
,
[
"standard_metadata"
,
"deq_qdepth"
]
],
[
"intrinsic_metadata.ingress_global_timestamp"
,
[
"standard_metadata"
,
"ingress_global_timestamp"
]
],
[
"intrinsic_metadata.egress_global_timestamp"
,
[
"standard_metadata"
,
"egress_global_timestamp"
]
],
[
"intrinsic_metadata.mcast_grp"
,
[
"standard_metadata"
,
"mcast_grp"
]
],
[
"intrinsic_metadata.egress_rid"
,
[
"standard_metadata"
,
"egress_rid"
]
],
[
"intrinsic_metadata.priority"
,
[
"standard_metadata"
,
"priority"
]
]
],
"program"
:
"./basic.p4i"
,
"__meta__"
:
{
"version"
:
[
2
,
23
],
"compiler"
:
"https://github.com/p4lang/p4c"
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment