lab5 done right

This commit is contained in:
ridethepig 2023-02-18 08:54:40 +00:00
parent fe97e171b4
commit 384cc9500f
2 changed files with 5 additions and 5 deletions

View File

@ -17,7 +17,7 @@ void get_URL(const string &host, const string &path) {
// Then you'll need to print out everything the server sends back,
// (not just one call to read() -- everything) until you reach
// the "eof" (end of file).
CS144TCPSocket sock;
FullStackSocket sock;
sock.connect(Address(host, "http"));
string request = "GET " + path + " HTTP/1.1\r\nHost: " + host + "\r\nConnection: close\r\n\r\n";
sock.write(request);

View File

@ -5,11 +5,11 @@
#include "tcp_over_ip.hh"
#include "tun.hh"
#include <list>
#include <map>
#include <optional>
#include <queue>
#include <map>
#include <utility>
#include <list>
//! \brief A "network interface" that connects IP (the internet layer, or network layer)
//! with Ethernet (the network access layer, or link layer).
@ -45,10 +45,10 @@ class NetworkInterface {
//! internal map as arp cache, holding mapping from ipv4(numerical form) to MAC addr with expire time.
//! if optinal<EthnernetAddress> has no value, it means that a ARP has been sent for the IP within 5 seconds
std::map<uint32_t, std::pair<std::optional<EthernetAddress>, size_t> > _arp_cache{};
std::map<uint32_t, std::pair<std::optional<EthernetAddress>, size_t>> _arp_cache{};
//! queue the IP datagrams waiting for ARP reply
std::list<std::pair<InternetDatagram, Address> >_suspended_datagrams{};
std::list<std::pair<InternetDatagram, Address>> _suspended_datagrams{};
public:
//! \brief Construct a network interface with given Ethernet (network-access-layer) and IP (internet-layer) addresses