-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 216cf9b
Showing
7 changed files
with
164 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
*.o | ||
*.dSYM | ||
.vagrant | ||
server | ||
client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
CXX=g++ | ||
CXXOPTIMIZE= -O2 | ||
CXXFLAGS= -g -Wall -pthread -std=c++11 $(CXXOPTIMIZE) | ||
USERID=123456789 | ||
CLASSES= | ||
|
||
all: server client | ||
|
||
server: $(CLASSES) | ||
$(CXX) -o $@ $^ $(CXXFLAGS) $@.cpp | ||
|
||
client: $(CLASSES) | ||
$(CXX) -o $@ $^ $(CXXFLAGS) $@.cpp | ||
|
||
clean: | ||
rm -rf *.o *~ *.gch *.swp *.dSYM server client *.tar.gz | ||
|
||
dist: tarball | ||
tarball: clean | ||
tar -cvf /tmp/$(USERID).tar.gz --exclude=./.vagrant . && mv /tmp/$(USERID).tar.gz . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# CS118 Project 2 | ||
|
||
Template for for [CS118 Spring 2017 Project 2](http://web.cs.ucla.edu/classes/spring17/cs118/project-2.html) | ||
|
||
## Makefile | ||
|
||
This provides a couple make targets for things. | ||
By default (all target), it makes the `server` and `client` executables. | ||
|
||
It provides a `clean` target, and `tarball` target to create the submission file as well. | ||
|
||
You will need to modify the `Makefile` to add your userid for the `.tar.gz` turn-in at the top of the file. | ||
|
||
## Provided Files | ||
|
||
`server.cpp` and `client.cpp` are the entry points for the server and client part of the project. | ||
|
||
## Academic Integrity Note | ||
|
||
You are encouraged to host your code in private repositories on [GitHub](https://github.com/), [GitLab](https://gitlab.com), or other places. At the same time, you are PROHIBITED to make your code for the class project public during the class or any time after the class. If you do so, you will be violating academic honestly policy that you have signed, as well as the student code of conduct and be subject to serious sanctions. | ||
|
||
## Wireshark dissector | ||
|
||
For debugging purposes, you can use the wireshark dissector from `tcp.lua`. The dissector requires | ||
at least version 1.12.6 of Wireshark with LUA support enabled. | ||
|
||
To enable the dissector for Wireshark session, use `-X` command line option, specifying the full | ||
path to the `tcp.lua` script: | ||
|
||
wireshark -X lua_script:./confundo.lua | ||
|
||
## TODO | ||
|
||
########################################################### | ||
## ## | ||
## REPLACE CONTENT OF THIS FILE WITH YOUR PROJECT REPORT ## | ||
## ## | ||
########################################################### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
|
||
$INSTALL_BASE = <<SCRIPT | ||
sudo apt-get update | ||
sudo apt-get install -y build-essential vim emacs | ||
echo "tc qdisc add dev enp0s8 root netem loss 10% delay 20ms" > /set-loss.sh | ||
chmod 755 /set-loss.sh | ||
SCRIPT | ||
|
||
Vagrant.configure(2) do |config| | ||
config.vm.box = "boxcutter/ubuntu1604" | ||
config.vm.provision "shell", inline: $INSTALL_BASE | ||
|
||
# config.vm.provider "virtualbox" do |vb| | ||
# # Display the VirtualBox GUI when booting the machine | ||
# vb.gui = true | ||
# | ||
# # Customize the amount of memory on the VM: | ||
# vb.memory = "1024" | ||
# end | ||
|
||
config.vm.define :client, primary: true do |host| | ||
host.vm.hostname = "client" | ||
host.vm.network "private_network", ip: "10.0.0.2", netmask: "255.255.255.0", | ||
virtualbox__intnet: "cs118" | ||
end | ||
|
||
config.vm.define :server do |host| | ||
host.vm.hostname = "server" | ||
host.vm.network "private_network", ip: "10.0.0.1", netmask: "255.255.255.0", | ||
virtualbox__intnet: "cs118" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include <string> | ||
#include <thread> | ||
#include <iostream> | ||
|
||
int main() | ||
{ | ||
std::cerr << "client is not implemented yet" << std::endl; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
confundo = Proto("confundo", "CS118 TCP") | ||
|
||
local f_seqno = ProtoField.uint32("confundo.seqno", "Sequence Number") | ||
local f_ack = ProtoField.uint32("confundo.ack", "ACK Number") | ||
local f_id = ProtoField.uint16("confundo.connectionId", "Connection ID") | ||
local f_flags = ProtoField.uint16("confundo.flags", "Flags") | ||
|
||
confundo.fields = { f_seqno, f_ack, f_id, f_flags } | ||
|
||
function confundo.dissector(tvb, pInfo, root) -- Tvb, Pinfo, TreeItem | ||
if (tvb:len() ~= tvb:reported_len()) then | ||
return 0 | ||
end | ||
|
||
local t = root:add(confundo, tvb(0,8)) | ||
t:add(f_seqno, tvb(0,4)) | ||
t:add(f_ack, tvb(4,4)) | ||
t:add(f_id, tvb(8,2)) | ||
local f = t:add(f_flags, tvb(10,2)) | ||
|
||
local flag = tvb(7,1):uint() | ||
|
||
if bit.band(flag, 1) ~= 0 then | ||
f:add(tvb(7,2), "FIN") | ||
end | ||
if bit.band(flag, 2) ~= 0 then | ||
f:add(tvb(7,2), "SYN") | ||
end | ||
if bit.band(flag, 4) ~= 0 then | ||
f:add(tvb(7,2), "ACK") | ||
end | ||
|
||
local flag = tvb(6,1):uint() | ||
if bit.band(flag, 1) ~= 0 then | ||
f:add(tvb(6,1), "xFIN") | ||
end | ||
if bit.band(flag, 2) ~= 0 then | ||
f:add(tvb(6,1), "xSYN") | ||
end | ||
if bit.band(flag, 4) ~= 0 then | ||
f:add(tvb(6,1), "xACK") | ||
end | ||
|
||
pInfo.cols.protocol = "Confundo" | ||
end | ||
|
||
local udpDissectorTable = DissectorTable.get("udp.port") | ||
udpDissectorTable:add("5000", confundo) | ||
|
||
io.stderr:write("confundo.lua is successfully loaded\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include <string> | ||
#include <thread> | ||
#include <iostream> | ||
|
||
int main() | ||
{ | ||
std::cerr << "server is not implemented yet" << std::endl; | ||
} |